From 4fe90668a6bedc5342726167dd648dba92a72873 Mon Sep 17 00:00:00 2001 From: Grzegorz Leoniec Date: Fri, 21 Dec 2018 15:27:11 +0100 Subject: [PATCH] Improved internationalization tests --- .../integration/Internationalization.feature | 18 ++++++++++-------- cypress/integration/common/steps.js | 14 +++----------- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/cypress/integration/Internationalization.feature b/cypress/integration/Internationalization.feature index cf679b982..ac2d40218 100644 --- a/cypress/integration/Internationalization.feature +++ b/cypress/integration/Internationalization.feature @@ -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 "" in the language menu and see "" + When I select "" in the language menu + Then the whole user interface appears in "" + Then I see a button with the label "" - 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 diff --git a/cypress/integration/common/steps.js b/cypress/integration/common/steps.js index 91f0906d4..6ea35c48f 100644 --- a/cypress/integration/common/steps.js +++ b/cypress/integration/common/steps.js @@ -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()