mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Improved integration tests
This commit is contained in:
parent
c45be5f39b
commit
02ed3db6fc
@ -13,12 +13,11 @@ Feature: Internationalization
|
|||||||
|
|
||||||
Examples: Login Button
|
Examples: Login Button
|
||||||
| language | buttonLabel |
|
| language | buttonLabel |
|
||||||
| English | Login |
|
|
||||||
| Deutsch | Einloggen |
|
|
||||||
| Français | Connexion |
|
| Français | Connexion |
|
||||||
| Nederlands | Inloggen |
|
| Deutsch | Einloggen |
|
||||||
|
| English | Login |
|
||||||
|
|
||||||
Scenario: Keep preferred language after refresh
|
Scenario: Keep preferred language after refresh
|
||||||
Given I previously switched the language to "Deutsch"
|
Given I previously switched the language to "Français"
|
||||||
And I refresh the page
|
And I refresh the page
|
||||||
Then the whole user interface appears in "Deutsch"
|
Then the whole user interface appears in "Français"
|
||||||
|
|||||||
@ -17,8 +17,8 @@ const lastColumnIsSortedInDescendingOrder = () => {
|
|||||||
|
|
||||||
When('I navigate to the administration dashboard', () => {
|
When('I navigate to the administration dashboard', () => {
|
||||||
cy.get('.avatar-menu').click()
|
cy.get('.avatar-menu').click()
|
||||||
cy.get('.avatar-menu-popover a')
|
cy.get('.avatar-menu-popover')
|
||||||
.contains('Admin')
|
.find('a[href="/admin"]')
|
||||||
.click()
|
.click()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -7,8 +7,9 @@ let myLocation
|
|||||||
let myName
|
let myName
|
||||||
|
|
||||||
const matchNameInUserMenu = name => {
|
const matchNameInUserMenu = name => {
|
||||||
cy.get('.avatar-menu').click()
|
cy.get('.avatar-menu').click() // open
|
||||||
cy.get('.avatar-menu-popover').contains(name)
|
cy.get('.avatar-menu-popover').contains(name)
|
||||||
|
cy.get('.avatar-menu').click() // close again
|
||||||
}
|
}
|
||||||
|
|
||||||
const setUserName = name => {
|
const setUserName = name => {
|
||||||
@ -66,3 +67,8 @@ Then('they can see the location in the info box below my avatar', () => {
|
|||||||
Then('my new username is still there', () => {
|
Then('my new username is still there', () => {
|
||||||
matchNameInUserMenu(myName)
|
matchNameInUserMenu(myName)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Then(
|
||||||
|
'I can see my new name {string} when I click on my profile picture in the top right',
|
||||||
|
name => matchNameInUserMenu(name)
|
||||||
|
)
|
||||||
|
|||||||
@ -48,8 +48,7 @@ When('I refresh the page', () => {
|
|||||||
When('I log out through the menu in the top right corner', () => {
|
When('I log out through the menu in the top right corner', () => {
|
||||||
cy.get('.avatar-menu').click()
|
cy.get('.avatar-menu').click()
|
||||||
cy.get('.avatar-menu-popover')
|
cy.get('.avatar-menu-popover')
|
||||||
.find('a')
|
.find('a[href="/logout"]')
|
||||||
.contains('Logout')
|
|
||||||
.click()
|
.click()
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -64,7 +63,6 @@ Then('I can see my name {string} in the dropdown menu', () => {
|
|||||||
|
|
||||||
Then('I see the login screen again', () => {
|
Then('I see the login screen again', () => {
|
||||||
cy.location('pathname').should('contain', '/login')
|
cy.location('pathname').should('contain', '/login')
|
||||||
cy.contains('If you already have a human-connection account, login here.')
|
|
||||||
})
|
})
|
||||||
|
|
||||||
Then('I am still logged in', () => {
|
Then('I am still logged in', () => {
|
||||||
|
|||||||
@ -17,21 +17,25 @@
|
|||||||
import { getLangByName } from './helpers'
|
import { getLangByName } from './helpers'
|
||||||
|
|
||||||
const switchLang = name => {
|
const switchLang = name => {
|
||||||
cy.get('.login-locale-switch a').click()
|
cy.get('.locale-menu').click()
|
||||||
cy.contains('.locale-menu-popover a', name).click()
|
cy.contains('.locale-menu-popover a', name).click()
|
||||||
}
|
}
|
||||||
|
|
||||||
Cypress.Commands.add('switchLanguage', (name, force) => {
|
Cypress.Commands.add('switchLanguage', (name, force) => {
|
||||||
const code = getLangByName(name).code
|
const code = getLangByName(name).code
|
||||||
if (force || !cy.get(`html[lang=${code}]`)) {
|
if (force) {
|
||||||
switchLang(name)
|
switchLang(name)
|
||||||
|
} else {
|
||||||
|
cy.get('html').then($html => {
|
||||||
|
if ($html && $html.attr('lang') !== code) {
|
||||||
|
switchLang(name)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
Cypress.Commands.add('visitMyProfile', () => {
|
Cypress.Commands.add('visitMyProfile', () => {
|
||||||
if (!cy.get('.avatar-menu-popover')) {
|
cy.get('.avatar-menu').click()
|
||||||
cy.get('.avatar-menu').click()
|
|
||||||
}
|
|
||||||
cy.get('.avatar-menu-popover')
|
cy.get('.avatar-menu-popover')
|
||||||
.find('a[href^="/profile/"]')
|
.find('a[href^="/profile/"]')
|
||||||
.click()
|
.click()
|
||||||
@ -39,7 +43,6 @@ Cypress.Commands.add('visitMyProfile', () => {
|
|||||||
|
|
||||||
Cypress.Commands.add('login', (email, password) => {
|
Cypress.Commands.add('login', (email, password) => {
|
||||||
cy.visit(`/login`)
|
cy.visit(`/login`)
|
||||||
cy.switchLanguage('English')
|
|
||||||
cy.get('input[name=email]')
|
cy.get('input[name=email]')
|
||||||
.trigger('focus')
|
.trigger('focus')
|
||||||
.type(email)
|
.type(email)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user