Improved internationalization tests

This commit is contained in:
Grzegorz Leoniec 2018-12-21 15:27:11 +01:00
parent 4a0d03e011
commit 4fe90668a6
No known key found for this signature in database
GPG Key ID: 3AA43686D4EB1377
2 changed files with 13 additions and 19 deletions

View File

@ -6,15 +6,17 @@ Feature: Internationalization
Background:
Given I am on the "login" page
Scenario: Change the language
When I select "Deutsch" in the language menu
Then the whole user interface appears in "Deutsch"
Scenario Outline: I select "<language>" in the language menu and see "<buttonLabel>"
When I select "<language>" in the language menu
Then the whole user interface appears in "<language>"
Then I see a button with the label "<buttonLabel>"
When I select "Français" in the language menu
Then the whole user interface appears in "Français"
When I select "English" in the language menu
Then the whole user interface appears in "English"
Examples: Login Button
| language | buttonLabel |
| English | Login |
| Deutsch | Einloggen |
| Français | Connexion |
| Nederlands | Inloggen |
Scenario: Keep preferred language after refresh
When I select "Deutsch" in the language menu

View File

@ -8,14 +8,6 @@ const baseUrl = 'http://localhost:3000'
const username = 'Peter Lustig'
const locales = require('../../../locales')
// TODO: use the native locale files
const localeStrings = {
login: {
English: 'Login',
Deutsch: 'Einloggen',
Français: 'Connexion'
}
}
const getLangByName = function(name) {
return find(locales, { name })
@ -26,7 +18,6 @@ const openPage = function(page) {
page = ''
}
cy.visit(`${baseUrl}/${page}`)
cy.get('html[data-n-head]')
}
const login = (email, password) => {
@ -115,10 +106,11 @@ When('I select {string} in the language menu', name => {
Then('the whole user interface appears in {string}', name => {
const lang = getLangByName(name)
cy.get(`html[lang=${lang.code}]`)
cy.contains('button', localeStrings.login[name])
cy.get(`html[lang=${getLangByName(name).code}]`).as('lang')
cy.getCookie('locale').should('have.property', 'value', lang.code)
})
Then('I see a button with the label {string}', label => {
cy.contains('button', label)
})
When('I navigate to the administration dashboard', () => {
cy.get('.avatar-menu').click()