Improved internationalization test

This commit is contained in:
Grzegorz Leoniec 2018-12-20 20:09:13 +01:00
parent 8b0823e01b
commit 3626fb2fa0
No known key found for this signature in database
GPG Key ID: 3AA43686D4EB1377
2 changed files with 32 additions and 24 deletions

View File

@ -3,14 +3,17 @@ Feature: Internationalization
I would like to see the user interface translated to my preferred language
In order to be able to understand the interface
Scenario: See english loginpage
When I visit the "/login" page
Then I can see the english is selected
Background:
When I visit the "login" page
Scenario: See german loginpage
When I visit the "/login" page
And I select german
Then I can see the german is selected
Then There should be a locale cooke set to de
When I refresh the page
Then I can see the german is selected
Scenario: Change the language
When I select "Deutsch" in the language menu
Then The whole user interface appears in "Deutsch"
When I select "English" in the language menu
Then The whole user interface appears in "English"
Scenario: Keep preferred language after refresh
When I select "Deutsch" in the language menu
And I refresh the page
Then The whole user interface appears in "Deutsch"

View File

@ -1,8 +1,11 @@
import { Given, When, Then } from 'cypress-cucumber-preprocessor/steps'
import find from 'lodash/find'
const baseUrl = 'http://localhost:3000'
const username = 'Peter Lustig'
const locales = require('../../../locales')
const login = (email, password) => {
cy.visit(`${baseUrl}/login`)
cy.get('input[name=email]')
@ -40,9 +43,15 @@ Given('my user account has the role {string}', (role) => {
When('I log out', logout)
When(`I visit the {string} page`, route => {
When('I visit the {string} page', route => {
if (route === 'main') {
route = ''
}
cy.visit(`${baseUrl}/${route}`)
})
Given('I am on the {string} page', page => {
cy.location('pathname').should('contain', `/${page}`)
})
When('I fill in my email and password combination and click submit', () => {
login('admin@example.org', 1234)
@ -79,22 +88,18 @@ Then('I am still logged in', () => {
cy.get('.avatar-menu-popover').contains(username)
})
When('I can see the english is selected', () => {
cy.get('.login-locale-switch img[alt="English"]')
})
When('I can see the german is selected', () => {
cy.get('.login-locale-switch img[alt="Deutsch"]')
})
When('I select german', () => {
When('I select {string} in the language menu', name => {
cy.get('.login-locale-switch a')
.click()
.wait(50)
cy.get('.locale-menu-popover a.de')
const code = find(locales, ['name', name]).code
cy.get(`.locale-menu-popover a.${code}`)
.click()
.wait(500)
})
Then(`There should be a locale cooke set to de`, () => {
cy.getCookie('locale').should('have.property', 'value', 'de')
Then('The whole user interface appears in {string}', name => {
const code = find(locales, ['name', name]).code
cy.getCookie('locale').should('have.property', 'value', code)
})
When('I navigate to the administration dashboard', () => {
@ -104,11 +109,11 @@ When('I navigate to the administration dashboard', () => {
.click()
})
When(`I click on {string}`, (linkOrButton) => {
When('I click on {string}', linkOrButton => {
cy.contains(linkOrButton).click()
})
Then('I can see a list of categories ordered by post count:', (table) => {
Then('I can see a list of categories ordered by post count:', table => {
// TODO: match the table in the feature with the html table
cy.get('thead').find('tr th').should('have.length', 3)
const last_column = cy.get('tbody').find('tr td:last-child').then((last_column) => {
@ -119,7 +124,7 @@ Then('I can see a list of categories ordered by post count:', (table) => {
})
})
Then('I can see a list of tags ordered by user and post count:', (table) => {
Then('I can see a list of tags ordered by user and post count:', table => {
// TODO: match the table in the feature with the html table
cy.get('thead').find('tr th').should('have.length', 4)
const last_column = cy.get('tbody').find('tr td:last-child').then((last_column) => {