|
| 1 | +describe('Localization', () => { |
| 2 | + it('should use sub routing to determine current locale', () => { |
| 3 | + cy.visit('/') |
| 4 | + |
| 5 | + cy.findByText('The current locale is en') |
| 6 | + |
| 7 | + cy.visit('/fr') |
| 8 | + cy.findByText('The current locale is fr') |
| 9 | + }) |
| 10 | + |
| 11 | + it('should use the NEXT_LOCALE cookie to determine the default locale', () => { |
| 12 | + cy.setCookie('NEXT_LOCALE', 'fr') |
| 13 | + cy.visit('/') |
| 14 | + |
| 15 | + cy.url().should('eq', `${Cypress.config().baseUrl}/fr/`) |
| 16 | + cy.findByText('The current locale is fr') |
| 17 | + }) |
| 18 | + |
| 19 | + it('should use the nf_lang cookie to determine the default locale', () => { |
| 20 | + cy.setCookie('nf_lang', 'fr') |
| 21 | + cy.visit('/') |
| 22 | + |
| 23 | + cy.url().should('eq', `${Cypress.config().baseUrl}/fr/`) |
| 24 | + cy.findByText('The current locale is fr') |
| 25 | + }) |
| 26 | + |
| 27 | + it('should use Accept-Language to choose a locale', () => { |
| 28 | + cy.visit('/', { |
| 29 | + headers: { |
| 30 | + 'Accept-Language': 'fr-FR,fr;q=0.5', |
| 31 | + }, |
| 32 | + }) |
| 33 | + cy.url().should('eq', `${Cypress.config().baseUrl}/fr/`) |
| 34 | + cy.findByText('The current locale is fr') |
| 35 | + }) |
| 36 | + |
| 37 | + it('should use the NEXT_LOCALE cookie over Accept-Language header to determine the default locale', () => { |
| 38 | + cy.setCookie('NEXT_LOCALE', 'en') |
| 39 | + cy.visit({ |
| 40 | + url: '/', |
| 41 | + headers: { |
| 42 | + 'Accept-Language': 'fr-FR,fr;q=0.5', |
| 43 | + }, |
| 44 | + }) |
| 45 | + cy.url().should('eq', `${Cypress.config().baseUrl}/`) |
| 46 | + cy.findByText('The current locale is en') |
| 47 | + }) |
| 48 | +}) |
0 commit comments