accounts-frontend/tests-e2e/cypress/integration/profile/i18n.test.ts

62 lines
1.8 KiB
TypeScript
Raw Normal View History

describe('Change locale', () => {
it('should change locale from footer', () => {
cy.visit('/');
2020-05-22 00:07:35 +05:30
cy.findByTestId('footer').contains('Site language').click();
2020-05-22 00:07:35 +05:30
cy.findByTestId('language-switcher').should('be.visible');
cy.findByTestId('language-switcher').should(
'have.attr',
'data-e2e-active-locale',
'en',
);
2020-05-22 00:07:35 +05:30
cy.findByTestId('language-list').contains('Belarusian').click();
2020-05-22 00:07:35 +05:30
cy.findByTestId('language-switcher').should('not.be.visible');
2020-05-22 00:07:35 +05:30
cy.findByTestId('footer').contains('Мова сайта').click();
2020-05-22 00:07:35 +05:30
cy.findByTestId('language-switcher').should('be.visible');
cy.findByTestId('language-switcher').should(
'have.attr',
'data-e2e-active-locale',
'be',
);
2020-05-22 00:07:35 +05:30
cy.findByTestId('language-list').contains('English').click();
2020-05-22 00:07:35 +05:30
cy.findByTestId('language-switcher').should('not.be.visible');
cy.findByTestId('footer').should('contain', 'Site language');
});
it('should change locale from profile', () => {
cy.login({ accounts: ['default'] }).then(({ accounts: [account] }) => {
cy.server();
cy.route({
method: 'POST',
url: `/api/v1/accounts/${account.id}/language`,
response: { success: true },
}).as('language');
});
cy.visit('/');
2020-05-22 00:07:35 +05:30
cy.findByTestId('profile-index').contains('English').click();
2020-05-22 00:07:35 +05:30
cy.findByTestId('language-switcher').should('be.visible');
cy.findByTestId('language-switcher').should(
'have.attr',
'data-e2e-active-locale',
'en',
);
2020-05-22 00:07:35 +05:30
cy.findByTestId('language-list').contains('Belarusian').click();
cy.wait('@language').its('requestBody').should('eq', 'lang=be');
2020-05-22 00:07:35 +05:30
cy.findByTestId('language-switcher').should('not.be.visible');
cy.findByTestId('profile-index').should('contain', 'Беларуская');
});
});