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