mirror of
https://github.com/elyby/accounts-frontend.git
synced 2025-05-31 14:11:58 +05:30
Add @testing-library/cypress
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
Reference in New Issue
Block a user