mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-11-30 02:32:58 +05:30
Add @testing-library/cypress
This commit is contained in:
parent
e1f15b5d22
commit
97d2841eda
@ -58,6 +58,7 @@ async function polyfillIntl(locale: string): Promise<void> {
|
||||
// resolve issue with RegExp errors
|
||||
// @see https://github.com/mattlewis92/angular-calendar/issues/274
|
||||
// @see https://github.com/mattlewis92/angular-calendar/issues/274
|
||||
// @ts-expect-error
|
||||
Intl.__disableRegExpRestore();
|
||||
|
||||
window.Intl = Intl;
|
||||
|
@ -23,13 +23,13 @@ describe('Forgot / reset password', () => {
|
||||
|
||||
cy.location('pathname').should('eq', '/password');
|
||||
|
||||
cy.getByTestId('auth-controls-secondary')
|
||||
cy.findByTestId('auth-controls-secondary')
|
||||
.contains('Forgot password')
|
||||
.click();
|
||||
|
||||
cy.location('pathname').should('eq', '/forgot-password');
|
||||
|
||||
cy.getByTestId('forgot-password-login').should(
|
||||
cy.findByTestId('forgot-password-login').should(
|
||||
'contain',
|
||||
account1.username,
|
||||
);
|
||||
@ -54,7 +54,7 @@ describe('Forgot / reset password', () => {
|
||||
|
||||
cy.location('pathname').should('eq', '/recover-password');
|
||||
|
||||
cy.getByTestId('auth-body').should('contain', emailMask);
|
||||
cy.findByTestId('auth-body').should('contain', emailMask);
|
||||
});
|
||||
|
||||
it('should allow change login', () => {
|
||||
@ -80,13 +80,13 @@ describe('Forgot / reset password', () => {
|
||||
|
||||
cy.location('pathname').should('eq', '/password');
|
||||
|
||||
cy.getByTestId('auth-controls-secondary')
|
||||
cy.findByTestId('auth-controls-secondary')
|
||||
.contains('Forgot password')
|
||||
.click();
|
||||
|
||||
cy.location('pathname').should('eq', '/forgot-password');
|
||||
|
||||
cy.getByTestId('edit-login').click();
|
||||
cy.findByTestId('edit-login').click();
|
||||
cy.get('[name=login]').should('have.value', account1.username);
|
||||
|
||||
cy.get('[name=login]').type(`{selectall}${login}`);
|
||||
@ -175,22 +175,22 @@ describe('Forgot / reset password', () => {
|
||||
|
||||
cy.location('pathname').should('eq', '/password');
|
||||
|
||||
cy.getByTestId('auth-controls-secondary')
|
||||
cy.findByTestId('auth-controls-secondary')
|
||||
.contains('Forgot password')
|
||||
.click();
|
||||
|
||||
cy.location('pathname').should('eq', '/forgot-password');
|
||||
|
||||
cy.getByTestId('auth-controls-secondary').contains('Already have').click();
|
||||
cy.findByTestId('auth-controls-secondary').contains('Already have').click();
|
||||
|
||||
cy.location('pathname').should('eq', '/recover-password');
|
||||
|
||||
cy.getByTestId('auth-controls-secondary')
|
||||
cy.findByTestId('auth-controls-secondary')
|
||||
.contains('Contact support')
|
||||
.click();
|
||||
cy.getByTestId('feedbackPopup').should('be.visible');
|
||||
cy.getByTestId('feedback-popup-close').click();
|
||||
cy.getByTestId('feedbackPopup').should('not.be.visible');
|
||||
cy.findByTestId('feedbackPopup').should('be.visible');
|
||||
cy.findByTestId('feedback-popup-close').click();
|
||||
cy.findByTestId('feedbackPopup').should('not.be.visible');
|
||||
|
||||
cy.get('[name=key]').type(key);
|
||||
cy.get('[name=newPassword]').type(newPassword);
|
||||
|
@ -49,7 +49,7 @@ describe('User with invalid token and refreshToken', () => {
|
||||
|
||||
cy.url().should('include', '/password');
|
||||
|
||||
cy.getByTestId('toolbar').get('a').contains('Ely.by').click();
|
||||
cy.findByTestId('toolbar').get('a').contains('Ely.by').click();
|
||||
|
||||
cy.url().should('include', '/password');
|
||||
});
|
||||
@ -82,7 +82,7 @@ describe('User with invalid token and refreshToken', () => {
|
||||
|
||||
cy.url().should('include', '/login');
|
||||
|
||||
cy.getByTestId('toolbar').contains('Join');
|
||||
cy.findByTestId('toolbar').contains('Join');
|
||||
});
|
||||
|
||||
it('should allow logout', () => {
|
||||
@ -99,12 +99,12 @@ describe('User with invalid token and refreshToken', () => {
|
||||
|
||||
cy.wait('@account').its('status').should('eq', 401);
|
||||
|
||||
cy.getByTestId('toolbar').contains(account2.username).click();
|
||||
cy.getByTestId('toolbar').contains('Log out').click();
|
||||
cy.findByTestId('toolbar').contains(account2.username).click();
|
||||
cy.findByTestId('toolbar').contains('Log out').click();
|
||||
|
||||
cy.wait('@logout');
|
||||
cy.getByTestId('toolbar').contains(account2.email).should('not.exist');
|
||||
cy.getByTestId('toolbar').contains(account2.username).should('not.exist');
|
||||
cy.findByTestId('toolbar').contains(account2.email).should('not.exist');
|
||||
cy.findByTestId('toolbar').contains(account2.username).should('not.exist');
|
||||
});
|
||||
|
||||
it('should allow enter new login from choose account', () => {
|
||||
@ -151,7 +151,7 @@ describe('User with invalid token and refreshToken', () => {
|
||||
|
||||
cy.url().should('include', '/login');
|
||||
|
||||
cy.getByTestId('toolbar').contains('a', 'Join');
|
||||
cy.findByTestId('toolbar').contains('a', 'Join');
|
||||
});
|
||||
|
||||
it('should ask for password if selected account with bad token', () => {
|
||||
|
@ -47,9 +47,9 @@ describe('OAuth', () => {
|
||||
|
||||
cy.url().should('include', '/oauth/choose-account');
|
||||
|
||||
cy.getByTestId('auth-header').should('contain', 'Choose an account');
|
||||
cy.findByTestId('auth-header').should('contain', 'Choose an account');
|
||||
|
||||
cy.getByTestId('auth-body').contains(account.email).click();
|
||||
cy.findByTestId('auth-body').contains(account.email).click();
|
||||
|
||||
cy.url().should('equal', 'https://dev.ely.by/');
|
||||
},
|
||||
@ -89,7 +89,7 @@ describe('OAuth', () => {
|
||||
|
||||
cy.server({ enable: false });
|
||||
|
||||
cy.getByTestId('auth-controls').contains('Approve').click();
|
||||
cy.findByTestId('auth-controls').contains('Approve').click();
|
||||
|
||||
cy.url().should('match', /^http:\/\/localhost:8080\/?\?code=[^&]+&state=$/);
|
||||
});
|
||||
@ -141,7 +141,7 @@ describe('OAuth', () => {
|
||||
|
||||
cy.server({ enable: false });
|
||||
|
||||
cy.getByTestId('auth-controls-secondary').contains('Decline').click();
|
||||
cy.findByTestId('auth-controls-secondary').contains('Decline').click();
|
||||
|
||||
cy.url().should('include', 'error=access_denied');
|
||||
});
|
||||
@ -214,9 +214,9 @@ describe('OAuth', () => {
|
||||
|
||||
cy.url().should('include', '/oauth/choose-account');
|
||||
|
||||
cy.getByTestId('auth-header').should('contain', 'Choose an account');
|
||||
cy.findByTestId('auth-header').should('contain', 'Choose an account');
|
||||
|
||||
cy.getByTestId('auth-body').contains(account.email).click();
|
||||
cy.findByTestId('auth-body').contains(account.email).click();
|
||||
|
||||
cy.url().should('equal', 'https://dev.ely.by/');
|
||||
});
|
||||
@ -234,7 +234,7 @@ describe('OAuth', () => {
|
||||
|
||||
cy.url().should('include', '/oauth/choose-account');
|
||||
|
||||
cy.getByTestId('auth-controls').contains('another account').click();
|
||||
cy.findByTestId('auth-controls').contains('another account').click();
|
||||
|
||||
cy.url().should('include', '/login');
|
||||
|
||||
@ -261,7 +261,7 @@ describe('OAuth', () => {
|
||||
|
||||
assertPermissions();
|
||||
|
||||
cy.getByTestId('auth-controls').contains('Approve').click();
|
||||
cy.findByTestId('auth-controls').contains('Approve').click();
|
||||
|
||||
cy.url().should(
|
||||
'match',
|
||||
@ -284,7 +284,7 @@ describe('OAuth', () => {
|
||||
|
||||
cy.url().should('include', '/oauth/permissions');
|
||||
|
||||
cy.getByTestId('auth-controls-secondary').contains('Decline').click();
|
||||
cy.findByTestId('auth-controls-secondary').contains('Decline').click();
|
||||
|
||||
cy.url().should('include', 'error=access_denied');
|
||||
});
|
||||
@ -302,13 +302,13 @@ describe('OAuth', () => {
|
||||
|
||||
cy.url().should('include', '/oauth/choose-account');
|
||||
|
||||
cy.getByTestId('auth-header').should('contain', 'Choose an account');
|
||||
cy.findByTestId('auth-header').should('contain', 'Choose an account');
|
||||
|
||||
cy.getByTestId('auth-body').contains(account.email).click();
|
||||
cy.findByTestId('auth-body').contains(account.email).click();
|
||||
|
||||
assertPermissions();
|
||||
|
||||
cy.getByTestId('auth-controls').contains('Approve').click();
|
||||
cy.findByTestId('auth-controls').contains('Approve').click();
|
||||
|
||||
cy.url().should(
|
||||
'match',
|
||||
@ -337,7 +337,7 @@ describe('OAuth', () => {
|
||||
|
||||
assertPermissions();
|
||||
|
||||
cy.getByTestId('auth-controls').contains('Approve').click();
|
||||
cy.findByTestId('auth-controls').contains('Approve').click();
|
||||
|
||||
cy.url().should(
|
||||
'match',
|
||||
@ -390,7 +390,7 @@ describe('OAuth', () => {
|
||||
|
||||
cy.url().should('include', 'oauth/finish#{%22auth_code%22:');
|
||||
|
||||
cy.getByTestId('oauth-code-container').should(
|
||||
cy.findByTestId('oauth-code-container').should(
|
||||
'contain',
|
||||
'provide the following code',
|
||||
);
|
||||
@ -398,7 +398,7 @@ describe('OAuth', () => {
|
||||
// just click on copy, but we won't assert if the string was copied
|
||||
// because it is a little bit complicated
|
||||
// https://github.com/cypress-io/cypress/issues/2752
|
||||
cy.getByTestId('oauth-code-container').contains('Copy').click();
|
||||
cy.findByTestId('oauth-code-container').contains('Copy').click();
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -406,12 +406,12 @@ describe('OAuth', () => {
|
||||
function assertPermissions() {
|
||||
cy.url().should('include', '/oauth/permissions');
|
||||
|
||||
cy.getByTestId('auth-header').should('contain', 'Application permissions');
|
||||
cy.getByTestId('auth-body').should(
|
||||
cy.findByTestId('auth-header').should('contain', 'Application permissions');
|
||||
cy.findByTestId('auth-body').should(
|
||||
'contain',
|
||||
'Access to your profile data (except E‑mail)',
|
||||
);
|
||||
cy.getByTestId('auth-body').should(
|
||||
cy.findByTestId('auth-body').should(
|
||||
'contain',
|
||||
'Access to your E‑mail address',
|
||||
);
|
||||
|
@ -27,7 +27,7 @@ describe('Register', () => {
|
||||
});
|
||||
cy.visit('/');
|
||||
|
||||
cy.getByTestId('toolbar').contains('Join').click();
|
||||
cy.findByTestId('toolbar').contains('Join').click();
|
||||
|
||||
cy.location('pathname').should('eq', '/register');
|
||||
|
||||
@ -89,7 +89,7 @@ describe('Register', () => {
|
||||
});
|
||||
cy.visit('/register');
|
||||
|
||||
cy.getByTestId('auth-controls-secondary').contains('Already have').click();
|
||||
cy.findByTestId('auth-controls-secondary').contains('Already have').click();
|
||||
|
||||
cy.location('pathname').should('eq', '/activation');
|
||||
|
||||
@ -142,7 +142,7 @@ describe('Register', () => {
|
||||
}).as('resend');
|
||||
cy.visit('/register');
|
||||
|
||||
cy.getByTestId('auth-controls-secondary').contains('not received').click();
|
||||
cy.findByTestId('auth-controls-secondary').contains('not received').click();
|
||||
|
||||
cy.location('pathname').should('eq', '/resend-activation');
|
||||
|
||||
|
@ -16,7 +16,7 @@ describe('Sign in / Log out', () => {
|
||||
|
||||
cy.location('pathname').should('eq', '/');
|
||||
|
||||
cy.getByTestId('toolbar')
|
||||
cy.findByTestId('toolbar')
|
||||
.contains(account1.username)
|
||||
.should(() => {
|
||||
const state = JSON.parse(localStorage.getItem('redux-storage') || '');
|
||||
@ -43,7 +43,7 @@ describe('Sign in / Log out', () => {
|
||||
|
||||
cy.location('pathname').should('eq', '/login');
|
||||
|
||||
cy.getByTestId('home-page').click();
|
||||
cy.findByTestId('home-page').click();
|
||||
|
||||
cy.location('pathname').should('eq', '/login');
|
||||
});
|
||||
@ -62,7 +62,7 @@ describe('Sign in / Log out', () => {
|
||||
|
||||
cy.location('pathname').should('eq', '/');
|
||||
|
||||
cy.getByTestId('toolbar')
|
||||
cy.findByTestId('toolbar')
|
||||
.contains(account1.username)
|
||||
.should(() => {
|
||||
const state = JSON.parse(localStorage.getItem('redux-storage') || '');
|
||||
@ -123,12 +123,12 @@ describe('Sign in / Log out', () => {
|
||||
|
||||
cy.visit('/');
|
||||
|
||||
cy.getByTestId('toolbar').contains(account1.username).click();
|
||||
cy.findByTestId('toolbar').contains(account1.username).click();
|
||||
|
||||
cy.getByTestId('active-account').getByTestId('logout-account').click();
|
||||
cy.findByTestId('active-account').findByTestId('logout-account').click();
|
||||
|
||||
cy.location('pathname').should('eq', '/login');
|
||||
cy.getByTestId('toolbar').should('contain', 'Join');
|
||||
cy.findByTestId('toolbar').should('contain', 'Join');
|
||||
});
|
||||
|
||||
describe('multi account', () => {
|
||||
@ -137,12 +137,12 @@ describe('Sign in / Log out', () => {
|
||||
|
||||
cy.visit('/');
|
||||
|
||||
cy.getByTestId('toolbar').contains(account2.username).click();
|
||||
cy.findByTestId('toolbar').contains(account2.username).click();
|
||||
|
||||
cy.getByTestId('active-account').should('have.length', 1);
|
||||
cy.findByTestId('active-account').should('have.length', 1);
|
||||
cy.get('[data-e2e-account-id]').should('have.length', 0);
|
||||
|
||||
cy.getByTestId('add-account').click();
|
||||
cy.findByTestId('add-account').click();
|
||||
|
||||
cy.location('pathname').should('eq', '/login');
|
||||
|
||||
@ -156,12 +156,12 @@ describe('Sign in / Log out', () => {
|
||||
|
||||
cy.location('pathname').should('eq', '/');
|
||||
|
||||
cy.getByTestId('toolbar').contains(account1.username).click();
|
||||
cy.findByTestId('toolbar').contains(account1.username).click();
|
||||
|
||||
cy.getByTestId('active-account').should('have.length', 1);
|
||||
cy.findByTestId('active-account').should('have.length', 1);
|
||||
cy.get('[data-e2e-account-id]').should('have.length', 1);
|
||||
|
||||
cy.get('[data-e2e-account-id]').getByTestId('logout-account').click();
|
||||
cy.get('[data-e2e-account-id]').findByTestId('logout-account').click();
|
||||
});
|
||||
|
||||
it('should go back to profile from login screen', () => {
|
||||
@ -169,9 +169,9 @@ describe('Sign in / Log out', () => {
|
||||
|
||||
cy.visit('/');
|
||||
|
||||
cy.getByTestId('toolbar').contains(account1.username).click();
|
||||
cy.findByTestId('toolbar').contains(account1.username).click();
|
||||
|
||||
cy.getByTestId('add-account').click();
|
||||
cy.findByTestId('add-account').click();
|
||||
|
||||
cy.location('pathname').should('eq', '/login');
|
||||
|
||||
@ -185,14 +185,14 @@ describe('Sign in / Log out', () => {
|
||||
|
||||
cy.visit('/');
|
||||
|
||||
cy.getByTestId('toolbar').contains(account1.username).click();
|
||||
cy.findByTestId('toolbar').contains(account1.username).click();
|
||||
|
||||
cy.getByTestId('active-account').getByTestId('logout-account').click();
|
||||
cy.findByTestId('active-account').findByTestId('logout-account').click();
|
||||
|
||||
cy.getByTestId('toolbar').contains(account2.username).click();
|
||||
cy.findByTestId('toolbar').contains(account2.username).click();
|
||||
cy.get('[data-e2e-account-id]').should('have.length', 0);
|
||||
cy.getByTestId('profile-index').should('not.contain', account1.username);
|
||||
cy.getByTestId('profile-index').should('contain', account2.username);
|
||||
cy.findByTestId('profile-index').should('not.contain', account1.username);
|
||||
cy.findByTestId('profile-index').should('contain', account2.username);
|
||||
});
|
||||
|
||||
it('should not allow log in the same account twice', () => {
|
||||
@ -200,12 +200,12 @@ describe('Sign in / Log out', () => {
|
||||
|
||||
cy.visit('/');
|
||||
|
||||
cy.getByTestId('toolbar').contains(account1.username).click();
|
||||
cy.findByTestId('toolbar').contains(account1.username).click();
|
||||
|
||||
cy.getByTestId('active-account').should('have.length', 1);
|
||||
cy.findByTestId('active-account').should('have.length', 1);
|
||||
cy.get('[data-e2e-account-id]').should('have.length', 0);
|
||||
|
||||
cy.getByTestId('add-account').click();
|
||||
cy.findByTestId('add-account').click();
|
||||
|
||||
cy.location('pathname').should('eq', '/login');
|
||||
|
||||
@ -219,7 +219,7 @@ describe('Sign in / Log out', () => {
|
||||
|
||||
cy.location('pathname').should('eq', '/');
|
||||
|
||||
cy.getByTestId('toolbar').contains(account1.username).click();
|
||||
cy.findByTestId('toolbar').contains(account1.username).click();
|
||||
cy.get('[data-e2e-account-id]').should('have.length', 0);
|
||||
});
|
||||
});
|
||||
|
@ -65,20 +65,20 @@ describe('Applications', () => {
|
||||
cy.contains('Cancel').should('not.exist');
|
||||
|
||||
// test reset client secret
|
||||
cy.getByTestId('client-secret').then(([el]) => {
|
||||
cy.findByTestId('client-secret').then(([el]) => {
|
||||
const prevSecret = el.value;
|
||||
|
||||
cy.getByTestId('client-secret').should('have.value', prevSecret);
|
||||
cy.findByTestId('client-secret').should('have.value', prevSecret);
|
||||
cy.contains('Reset Client Secret').click();
|
||||
cy.contains('Continue').click();
|
||||
cy.wait('@revokeSecret');
|
||||
cy.contains('Cancel').should('not.exist');
|
||||
cy.getByTestId('client-secret').should('not.have.value', prevSecret);
|
||||
cy.findByTestId('client-secret').should('not.have.value', prevSecret);
|
||||
});
|
||||
|
||||
// test delete
|
||||
cy.contains('Delete').click();
|
||||
cy.getByTestId('delete-app').click();
|
||||
cy.findByTestId('delete-app').click();
|
||||
cy.wait('@delete');
|
||||
cy.contains("You don't have any app registered yet.").should(
|
||||
'be.visible',
|
||||
@ -111,7 +111,7 @@ describe('Applications', () => {
|
||||
cy.visit('/dev/applications');
|
||||
|
||||
cy.get('[data-e2e-content] [data-e2e-button="feedbackPopup"]').click();
|
||||
cy.getByTestId('feedbackPopup').should('be.visible');
|
||||
cy.findByTestId('feedbackPopup').should('be.visible');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -58,9 +58,9 @@ describe('Profile — Change Email', () => {
|
||||
|
||||
cy.location('pathname').should('eq', '/profile/change-email/step2');
|
||||
|
||||
cy.getByTestId('step2').should('be.visible');
|
||||
cy.getByTestId('step2').find('[name=key]').type(key);
|
||||
cy.getByTestId('step2')
|
||||
cy.findByTestId('step2').should('be.visible');
|
||||
cy.findByTestId('step2').find('[name=key]').type(key);
|
||||
cy.findByTestId('step2')
|
||||
.find('[name=email]')
|
||||
.type(`${account.email}{enter}`);
|
||||
|
||||
@ -75,9 +75,9 @@ describe('Profile — Change Email', () => {
|
||||
);
|
||||
cy.location('pathname').should('eq', '/profile/change-email/step3');
|
||||
|
||||
cy.getByTestId('step3').find('[name=key]').should('be.visible');
|
||||
cy.getByTestId('step3').find('[name=key]').should('have.value', '');
|
||||
cy.getByTestId('step3').find('[name=key]').type(`${key2}{enter}`);
|
||||
cy.findByTestId('step3').find('[name=key]').should('be.visible');
|
||||
cy.findByTestId('step3').find('[name=key]').should('have.value', '');
|
||||
cy.findByTestId('step3').find('[name=key]').type(`${key2}{enter}`);
|
||||
|
||||
cy.wait('@saveEmail')
|
||||
.its('requestBody')
|
||||
@ -118,9 +118,9 @@ describe('Profile — Change Email', () => {
|
||||
|
||||
cy.visit(`/profile/change-email/step2/${key}`);
|
||||
|
||||
cy.getByTestId('step2').find('[name=key]').should('have.value', key);
|
||||
cy.getByTestId('step2').find('[name=key]').should('be.disabled');
|
||||
cy.getByTestId('step2')
|
||||
cy.findByTestId('step2').find('[name=key]').should('have.value', key);
|
||||
cy.findByTestId('step2').find('[name=key]').should('be.disabled');
|
||||
cy.findByTestId('step2')
|
||||
.find('[name=email]')
|
||||
.type(`${account.email}{enter}`);
|
||||
|
||||
@ -134,7 +134,7 @@ describe('Profile — Change Email', () => {
|
||||
}).toString(),
|
||||
);
|
||||
cy.location('pathname').should('eq', '/profile/change-email/step3');
|
||||
cy.getByTestId('step3').find('[name=key]').should('have.value', '');
|
||||
cy.findByTestId('step3').find('[name=key]').should('have.value', '');
|
||||
});
|
||||
});
|
||||
|
||||
@ -151,10 +151,10 @@ describe('Profile — Change Email', () => {
|
||||
|
||||
cy.visit(`/profile/change-email/step3/${key}`);
|
||||
|
||||
cy.getByTestId('step3').find('[name=key]').should('have.value', key);
|
||||
cy.getByTestId('step3').find('[name=key]').should('be.disabled');
|
||||
cy.findByTestId('step3').find('[name=key]').should('have.value', key);
|
||||
cy.findByTestId('step3').find('[name=key]').should('be.disabled');
|
||||
|
||||
cy.getByTestId('change-email').find('[type=submit]').click();
|
||||
cy.findByTestId('change-email').find('[type=submit]').click();
|
||||
|
||||
cy.wait('@saveEmail').its('requestBody').should(
|
||||
'eq',
|
||||
|
@ -82,7 +82,7 @@ describe('Profile — Change password', () => {
|
||||
|
||||
confirmWithPassword(account.password);
|
||||
|
||||
cy.getByTestId('password-request-form').should('not.be.visible');
|
||||
cy.findByTestId('password-request-form').should('not.be.visible');
|
||||
cy.contains('The passwords does not match').should('be.visible');
|
||||
});
|
||||
});
|
||||
|
@ -66,9 +66,9 @@ describe('Profile — Change Username', () => {
|
||||
);
|
||||
|
||||
cy.location('pathname').should('eq', '/');
|
||||
cy.getByTestId('profile-item').should('contain', account.username);
|
||||
cy.getByTestId('toolbar').contains(account.username).click();
|
||||
cy.getByTestId('active-account').should('contain', account.username);
|
||||
cy.findAllByTestId('profile-item').should('contain', account.username);
|
||||
cy.findByTestId('toolbar').contains(account.username).click();
|
||||
cy.findByTestId('active-account').should('contain', account.username);
|
||||
});
|
||||
});
|
||||
|
||||
@ -77,7 +77,7 @@ describe('Profile — Change Username', () => {
|
||||
|
||||
cy.visit('/profile/change-username');
|
||||
|
||||
cy.getByTestId('back-to-profile').click();
|
||||
cy.findByTestId('back-to-profile').click();
|
||||
|
||||
cy.location('pathname').should('eq', '/');
|
||||
});
|
||||
|
@ -16,32 +16,32 @@ describe('feedback popup', () => {
|
||||
|
||||
cy.visit('/');
|
||||
|
||||
cy.getByTestId('footer').contains('Contact Us').click();
|
||||
cy.getByTestId('feedbackPopup').should('be.visible');
|
||||
cy.findByTestId('footer').contains('Contact Us').click();
|
||||
cy.findByTestId('feedbackPopup').should('be.visible');
|
||||
|
||||
cy.get('[name=subject]').type(subject);
|
||||
cy.get('[name=email]').should('have.value', account1.email);
|
||||
cy.get('[name=message]').type(message);
|
||||
|
||||
cy.get('[data-e2e-select-name=category]')
|
||||
.getByTestId('select-label')
|
||||
.findByTestId('select-label')
|
||||
.should('contain', 'What are you interested');
|
||||
cy.get('[data-e2e-select-name=category]').click();
|
||||
cy.get('[data-e2e-select-name=category]').contains('bug').click();
|
||||
cy.get('[data-e2e-select-name=category]')
|
||||
.getByTestId('select-label')
|
||||
.findByTestId('select-label')
|
||||
.should('contain', 'bug');
|
||||
|
||||
cy.getByTestId('feedbackPopup').get('[type=submit]').click();
|
||||
cy.findByTestId('feedbackPopup').get('[type=submit]').click();
|
||||
|
||||
cy.getByTestId('feedbackPopup').should(
|
||||
cy.findByTestId('feedbackPopup').should(
|
||||
'contain',
|
||||
'Your message was received',
|
||||
);
|
||||
cy.getByTestId('feedbackPopup').should('contain', account1.email);
|
||||
cy.findByTestId('feedbackPopup').should('contain', account1.email);
|
||||
|
||||
cy.getByTestId('feedback-popup-close-button').click();
|
||||
cy.findByTestId('feedback-popup-close-button').click();
|
||||
|
||||
cy.getByTestId('feedbackPopup').should('not.be.visible');
|
||||
cy.findByTestId('feedbackPopup').should('not.be.visible');
|
||||
});
|
||||
});
|
||||
|
@ -2,32 +2,32 @@ describe('Change locale', () => {
|
||||
it('should change locale from footer', () => {
|
||||
cy.visit('/');
|
||||
|
||||
cy.getByTestId('footer').contains('Site language').click();
|
||||
cy.findByTestId('footer').contains('Site language').click();
|
||||
|
||||
cy.getByTestId('language-switcher').should('be.visible');
|
||||
cy.getByTestId('language-switcher').should(
|
||||
cy.findByTestId('language-switcher').should('be.visible');
|
||||
cy.findByTestId('language-switcher').should(
|
||||
'have.attr',
|
||||
'data-e2e-active-locale',
|
||||
'en',
|
||||
);
|
||||
|
||||
cy.getByTestId('language-list').contains('Belarusian').click();
|
||||
cy.findByTestId('language-list').contains('Belarusian').click();
|
||||
|
||||
cy.getByTestId('language-switcher').should('not.be.visible');
|
||||
cy.findByTestId('language-switcher').should('not.be.visible');
|
||||
|
||||
cy.getByTestId('footer').contains('Мова сайта').click();
|
||||
cy.findByTestId('footer').contains('Мова сайта').click();
|
||||
|
||||
cy.getByTestId('language-switcher').should('be.visible');
|
||||
cy.getByTestId('language-switcher').should(
|
||||
cy.findByTestId('language-switcher').should('be.visible');
|
||||
cy.findByTestId('language-switcher').should(
|
||||
'have.attr',
|
||||
'data-e2e-active-locale',
|
||||
'be',
|
||||
);
|
||||
|
||||
cy.getByTestId('language-list').contains('English').click();
|
||||
cy.findByTestId('language-list').contains('English').click();
|
||||
|
||||
cy.getByTestId('language-switcher').should('not.be.visible');
|
||||
cy.getByTestId('footer').should('contain', 'Site language');
|
||||
cy.findByTestId('language-switcher').should('not.be.visible');
|
||||
cy.findByTestId('footer').should('contain', 'Site language');
|
||||
});
|
||||
|
||||
it('should change locale from profile', () => {
|
||||
@ -42,20 +42,20 @@ describe('Change locale', () => {
|
||||
|
||||
cy.visit('/');
|
||||
|
||||
cy.getByTestId('profile-index').contains('English').click();
|
||||
cy.findByTestId('profile-index').contains('English').click();
|
||||
|
||||
cy.getByTestId('language-switcher').should('be.visible');
|
||||
cy.getByTestId('language-switcher').should(
|
||||
cy.findByTestId('language-switcher').should('be.visible');
|
||||
cy.findByTestId('language-switcher').should(
|
||||
'have.attr',
|
||||
'data-e2e-active-locale',
|
||||
'en',
|
||||
);
|
||||
|
||||
cy.getByTestId('language-list').contains('Belarusian').click();
|
||||
cy.findByTestId('language-list').contains('Belarusian').click();
|
||||
|
||||
cy.wait('@language').its('requestBody').should('eq', 'lang=be');
|
||||
|
||||
cy.getByTestId('language-switcher').should('not.be.visible');
|
||||
cy.getByTestId('profile-index').should('contain', 'Беларуская');
|
||||
cy.findByTestId('language-switcher').should('not.be.visible');
|
||||
cy.findByTestId('profile-index').should('contain', 'Беларуская');
|
||||
});
|
||||
});
|
||||
|
@ -31,7 +31,7 @@ describe('Profile — mfa', () => {
|
||||
|
||||
cy.location('pathname').should('eq', '/profile/mfa/step2');
|
||||
|
||||
cy.getByTestId('secret').should('not.be.empty');
|
||||
cy.findByTestId('secret').should('not.be.empty');
|
||||
|
||||
cy.contains('Ready').click();
|
||||
|
||||
@ -170,9 +170,9 @@ describe('Profile — mfa', () => {
|
||||
});
|
||||
|
||||
function assertOs(name: string, os: string) {
|
||||
cy.getByTestId('os-tile').contains(name).click();
|
||||
cy.findAllByTestId('os-tile').contains(name).click();
|
||||
|
||||
cy.getByTestId('os-instruction').should('have.attr', 'data-os', os);
|
||||
cy.findByTestId('os-instruction').should('have.attr', 'data-os', os);
|
||||
|
||||
cy.getByTestId('os-tile').contains(name).click();
|
||||
cy.findAllByTestId('os-tile').contains(name).click();
|
||||
}
|
||||
|
@ -1,16 +1,16 @@
|
||||
export function getSectionByName(name: string) {
|
||||
return cy
|
||||
.getByTestId('profile-item')
|
||||
.findAllByTestId('profile-item')
|
||||
.contains(name)
|
||||
.closest('[data-testid="profile-item"]');
|
||||
}
|
||||
|
||||
export function openSectionByName(name: string) {
|
||||
return getSectionByName(name).getByTestId('profile-action').click();
|
||||
return getSectionByName(name).findByTestId('profile-action').click();
|
||||
}
|
||||
|
||||
export function confirmWithPassword(password: string) {
|
||||
cy.getByTestId('password-request-form').should('be.visible');
|
||||
cy.findByTestId('password-request-form').should('be.visible');
|
||||
cy.get('[name=password]').type(password);
|
||||
cy.getByTestId('password-request-form').find('[type=submit]').click();
|
||||
cy.findByTestId('password-request-form').find('[type=submit]').click();
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
import '@testing-library/cypress/add-commands';
|
||||
|
||||
import { account1, account2 } from '../fixtures/accounts';
|
||||
|
||||
// ***********************************************
|
||||
@ -83,20 +85,6 @@ Cypress.Commands.add(
|
||||
},
|
||||
);
|
||||
|
||||
Cypress.Commands.add(
|
||||
'getByTestId',
|
||||
{ prevSubject: 'optional' },
|
||||
(subject, id, options) => {
|
||||
const selector = `[data-testid=${id}]`;
|
||||
|
||||
if (subject) {
|
||||
return cy.wrap(subject.find(selector));
|
||||
}
|
||||
|
||||
return cy.get(selector, options);
|
||||
},
|
||||
);
|
||||
|
||||
function createState(accounts) {
|
||||
return {
|
||||
accounts: {
|
||||
|
@ -13,6 +13,8 @@
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@cypress/webpack-preprocessor": "^5.4.1",
|
||||
"@testing-library/cypress": "^6.0.0",
|
||||
"@types/testing-library__cypress": "^5.0.5",
|
||||
"cypress": "^4.5.0"
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
"noEmit": true,
|
||||
"moduleResolution": "node",
|
||||
"lib": ["es6", "dom"],
|
||||
"types": ["cypress"],
|
||||
"types": ["cypress", "@types/testing-library__cypress"],
|
||||
"resolveJsonModule": true,
|
||||
"noImplicitAny": false
|
||||
},
|
||||
|
66
yarn.lock
66
yarn.lock
@ -1809,7 +1809,7 @@
|
||||
dependencies:
|
||||
regenerator-runtime "^0.13.2"
|
||||
|
||||
"@babel/runtime@^7.8.4", "@babel/runtime@^7.9.2", "@babel/runtime@^7.9.6":
|
||||
"@babel/runtime@^7.8.4", "@babel/runtime@^7.8.7", "@babel/runtime@^7.9.2", "@babel/runtime@^7.9.6":
|
||||
version "7.9.6"
|
||||
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.9.6.tgz#a9102eb5cadedf3f31d08a9ecf294af7827ea29f"
|
||||
integrity sha512-64AF1xY3OAkFHqOb9s4jpgk1Mm5vDZ4L3acHvAml+53nO1XbXLuDodsVpO4OIUsmemlUHMxNdYMNJmsvOwLrvQ==
|
||||
@ -2891,7 +2891,16 @@
|
||||
"@svgr/plugin-svgo" "^4.3.1"
|
||||
loader-utils "^1.2.3"
|
||||
|
||||
"@testing-library/dom@^7.2.2":
|
||||
"@testing-library/cypress@^6.0.0":
|
||||
version "6.0.0"
|
||||
resolved "https://registry.yarnpkg.com/@testing-library/cypress/-/cypress-6.0.0.tgz#935f7716e0e495f02fd753a42621e4d350097dce"
|
||||
integrity sha512-vWPQtPsIDk5STOH2XdJbJoYq9gxOSAItP0ail+MlylK230zNkf3ODKd6eqWnDdruuqrhTF3CyqvPNMA8Xks/UQ==
|
||||
dependencies:
|
||||
"@babel/runtime" "^7.8.7"
|
||||
"@testing-library/dom" "^7.0.2"
|
||||
"@types/testing-library__cypress" "^5.0.3"
|
||||
|
||||
"@testing-library/dom@^7.0.2", "@testing-library/dom@^7.2.2":
|
||||
version "7.5.7"
|
||||
resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-7.5.7.tgz#c4bf683a65083d4a78644588cfa4ad684c113fc7"
|
||||
integrity sha512-835MiwAxQE7xjSrhpeJbv41UQRmsPJQ0tGfzWiJMdZj2LBbdG5cT8Z44Viv11/XucCmJHr/v8q7VpZnuSimscg==
|
||||
@ -3325,7 +3334,7 @@
|
||||
resolved "https://registry.yarnpkg.com/@types/sinon/-/sinon-7.5.1.tgz#d27b81af0d1cfe1f9b24eebe7a24f74ae40f5b7c"
|
||||
integrity sha512-EZQUP3hSZQyTQRfiLqelC9NMWd1kqLcmQE0dMiklxBkgi84T+cHOhnKpgk4NnOWpGX863yE6+IaGnOXUNFqDnQ==
|
||||
|
||||
"@types/sinonjs__fake-timers@*":
|
||||
"@types/sinonjs__fake-timers@*", "@types/sinonjs__fake-timers@6.0.1":
|
||||
version "6.0.1"
|
||||
resolved "https://registry.yarnpkg.com/@types/sinonjs__fake-timers/-/sinonjs__fake-timers-6.0.1.tgz#681df970358c82836b42f989188d133e218c458e"
|
||||
integrity sha512-yYezQwGWty8ziyYLdZjwxyMb0CZR49h8JALHGrxjQHWlqGgc8kLdHEgWrgL0uZ29DMvEVBDnHU2Wg36zKSIUtA==
|
||||
@ -3350,6 +3359,14 @@
|
||||
resolved "https://registry.yarnpkg.com/@types/tapable/-/tapable-1.0.5.tgz#9adbc12950582aa65ead76bffdf39fe0c27a3c02"
|
||||
integrity sha512-/gG2M/Imw7cQFp8PGvz/SwocNrmKFjFsm5Pb8HdbHkZ1K8pmuPzOX4VeVoiEecFCVf4CsN1r3/BRvx+6sNqwtQ==
|
||||
|
||||
"@types/testing-library__cypress@^5.0.3", "@types/testing-library__cypress@^5.0.5":
|
||||
version "5.0.5"
|
||||
resolved "https://registry.yarnpkg.com/@types/testing-library__cypress/-/testing-library__cypress-5.0.5.tgz#ca2a23eb03c48ecb50f411b3d5e62a218ac6b03b"
|
||||
integrity sha512-FXRE98G+jkru7Dag6dFWs3M90BGMzDEBzox8Uro+7M70UcB1YVUetNVRyqYShFDLIDv+z3ZjV4ZeUmdgPuuyNw==
|
||||
dependencies:
|
||||
"@types/testing-library__dom" "*"
|
||||
cypress "*"
|
||||
|
||||
"@types/testing-library__dom@*":
|
||||
version "7.0.2"
|
||||
resolved "https://registry.yarnpkg.com/@types/testing-library__dom/-/testing-library__dom-7.0.2.tgz#2906f8a0dce58b0746c6ab606f786bd06fe6940e"
|
||||
@ -6256,6 +6273,49 @@ cyclist@^1.0.1:
|
||||
resolved "https://registry.yarnpkg.com/cyclist/-/cyclist-1.0.1.tgz#596e9698fd0c80e12038c2b82d6eb1b35b6224d9"
|
||||
integrity sha1-WW6WmP0MgOEgOMK4LW6xs1tiJNk=
|
||||
|
||||
cypress@*:
|
||||
version "4.6.0"
|
||||
resolved "https://registry.yarnpkg.com/cypress/-/cypress-4.6.0.tgz#ac76786500580df1347a0a50be63e5c59ffbef59"
|
||||
integrity sha512-vIPXAceRP+Nxvnm/O9ruY9EQaRGmVVybtk9F1sfC9mH3067YbitrdBTynaaLuHFj90p9e0U2ZCV7OkX4x4V/Wg==
|
||||
dependencies:
|
||||
"@cypress/listr-verbose-renderer" "0.4.1"
|
||||
"@cypress/request" "2.88.5"
|
||||
"@cypress/xvfb" "1.2.4"
|
||||
"@types/sinonjs__fake-timers" "6.0.1"
|
||||
"@types/sizzle" "2.3.2"
|
||||
arch "2.1.1"
|
||||
bluebird "3.7.2"
|
||||
cachedir "2.3.0"
|
||||
chalk "2.4.2"
|
||||
check-more-types "2.24.0"
|
||||
cli-table3 "0.5.1"
|
||||
commander "4.1.0"
|
||||
common-tags "1.8.0"
|
||||
debug "4.1.1"
|
||||
eventemitter2 "4.1.2"
|
||||
execa "1.0.0"
|
||||
executable "4.1.1"
|
||||
extract-zip "1.7.0"
|
||||
fs-extra "8.1.0"
|
||||
getos "3.1.4"
|
||||
is-ci "2.0.0"
|
||||
is-installed-globally "0.1.0"
|
||||
lazy-ass "1.6.0"
|
||||
listr "0.14.3"
|
||||
lodash "4.17.15"
|
||||
log-symbols "3.0.0"
|
||||
minimist "1.2.5"
|
||||
moment "2.24.0"
|
||||
ospath "1.2.2"
|
||||
pretty-bytes "5.3.0"
|
||||
ramda "0.26.1"
|
||||
request-progress "3.0.0"
|
||||
supports-color "7.1.0"
|
||||
tmp "0.1.0"
|
||||
untildify "4.0.0"
|
||||
url "0.11.0"
|
||||
yauzl "2.10.0"
|
||||
|
||||
cypress@^4.5.0:
|
||||
version "4.5.0"
|
||||
resolved "https://registry.yarnpkg.com/cypress/-/cypress-4.5.0.tgz#01940d085f6429cec3c87d290daa47bb976a7c7b"
|
||||
|
Loading…
Reference in New Issue
Block a user