From 1e1864277d7159f16897e4c9f1d44686859c6d78 Mon Sep 17 00:00:00 2001 From: Grzegorz Leoniec Date: Fri, 21 Dec 2018 15:31:07 +0100 Subject: [PATCH] Improved intarnationalization test --- cypress/integration/Internationalization.feature | 4 +--- cypress/integration/common/steps.js | 12 ++++++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/cypress/integration/Internationalization.feature b/cypress/integration/Internationalization.feature index ac2d40218..375fc03aa 100644 --- a/cypress/integration/Internationalization.feature +++ b/cypress/integration/Internationalization.feature @@ -19,8 +19,6 @@ Feature: Internationalization | Nederlands | Inloggen | Scenario: Keep preferred language after refresh - When I select "Deutsch" in the language menu - Then the whole user interface appears in "Deutsch" - + Given I previously switched the language to "Deutsch" And I refresh the page Then the whole user interface appears in "Deutsch" diff --git a/cypress/integration/common/steps.js b/cypress/integration/common/steps.js index 6ea35c48f..4d03766bc 100644 --- a/cypress/integration/common/steps.js +++ b/cypress/integration/common/steps.js @@ -20,6 +20,11 @@ const openPage = function(page) { cy.visit(`${baseUrl}/${page}`) } +const switchLanguage = function(name) { + cy.get('.login-locale-switch a').click() + cy.contains('.locale-menu-popover a', name).click() +} + const login = (email, password) => { cy.visit(`${baseUrl}/login`) cy.get('input[name=email]') @@ -55,6 +60,7 @@ Given('my user account has the role {string}', (role) => { // TODO: use db factories instead of seed data }) + When('I log out', logout) When('I visit the {string} page', page => { @@ -100,8 +106,10 @@ Then('I am still logged in', () => { }) When('I select {string} in the language menu', name => { - cy.get('.login-locale-switch a').click() - cy.contains('.locale-menu-popover a', name).click() + switchLanguage(name) +}) +Given('I previously switched the language to {string}', name => { + switchLanguage(name) }) Then('the whole user interface appears in {string}', name => { const lang = getLangByName(name)