2019-12-29 18:56:07 +05:30
|
|
|
describe('Change locale', () => {
|
2020-07-06 21:59:56 +05:30
|
|
|
it('should change locale from the footer', () => {
|
2020-05-24 04:38:24 +05:30
|
|
|
cy.visit('/');
|
2019-12-28 16:43:11 +05:30
|
|
|
|
2020-05-24 04:38:24 +05:30
|
|
|
cy.findByTestId('footer').contains('Site language').click();
|
2019-12-28 16:43:11 +05:30
|
|
|
|
2020-05-24 04:38:24 +05:30
|
|
|
cy.findByTestId('language-switcher').should('be.visible');
|
|
|
|
cy.findByTestId('language-switcher').should('have.attr', 'data-e2e-active-locale', 'en');
|
2019-12-28 16:43:11 +05:30
|
|
|
|
2020-07-06 21:59:56 +05:30
|
|
|
cy.findByTestId('languages-list-item').contains('Belarusian').click();
|
2019-12-28 16:43:11 +05:30
|
|
|
|
2020-05-24 04:38:24 +05:30
|
|
|
cy.findByTestId('language-switcher').should('not.be.visible');
|
2019-12-28 16:43:11 +05:30
|
|
|
|
2020-05-24 04:38:24 +05:30
|
|
|
cy.findByTestId('footer').contains('Мова сайта').click();
|
2019-12-28 16:43:11 +05:30
|
|
|
|
2020-05-24 04:38:24 +05:30
|
|
|
cy.findByTestId('language-switcher').should('be.visible');
|
|
|
|
cy.findByTestId('language-switcher').should('have.attr', 'data-e2e-active-locale', 'be');
|
2019-12-28 16:43:11 +05:30
|
|
|
|
2020-07-06 21:59:56 +05:30
|
|
|
cy.findByTestId('languages-list-item').contains('English').click();
|
2019-12-28 16:43:11 +05:30
|
|
|
|
2020-05-24 04:38:24 +05:30
|
|
|
cy.findByTestId('language-switcher').should('not.be.visible');
|
|
|
|
cy.findByTestId('footer').should('contain', 'Site language');
|
2019-12-28 16:43:11 +05:30
|
|
|
});
|
|
|
|
|
2020-07-06 21:59:56 +05:30
|
|
|
it('should change locale from the profile', () => {
|
2020-05-24 04:38:24 +05:30
|
|
|
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('/');
|
2019-12-28 16:43:11 +05:30
|
|
|
|
2020-05-24 04:38:24 +05:30
|
|
|
cy.findByTestId('profile-index').contains('English').click();
|
2019-12-28 16:43:11 +05:30
|
|
|
|
2020-05-24 04:38:24 +05:30
|
|
|
cy.findByTestId('language-switcher').should('be.visible');
|
|
|
|
cy.findByTestId('language-switcher').should('have.attr', 'data-e2e-active-locale', 'en');
|
2019-12-28 16:43:11 +05:30
|
|
|
|
2020-07-06 21:59:56 +05:30
|
|
|
cy.findByTestId('languages-list-item').contains('Belarusian').click();
|
2019-12-28 16:43:11 +05:30
|
|
|
|
2020-05-24 04:38:24 +05:30
|
|
|
cy.wait('@language').its('requestBody').should('eq', 'lang=be');
|
2019-12-28 16:43:11 +05:30
|
|
|
|
2020-05-24 04:38:24 +05:30
|
|
|
cy.findByTestId('language-switcher').should('not.be.visible');
|
|
|
|
cy.findByTestId('profile-index').should('contain', 'Беларуская');
|
|
|
|
});
|
2019-12-28 16:43:11 +05:30
|
|
|
});
|