diff --git a/cypress/integration/internationalization/.Internationalization.feature b/cypress/integration/Internationalization.feature similarity index 89% rename from cypress/integration/internationalization/.Internationalization.feature rename to cypress/integration/Internationalization.feature index 18070d888..5eb6bbc3f 100644 --- a/cypress/integration/internationalization/.Internationalization.feature +++ b/cypress/integration/Internationalization.feature @@ -4,7 +4,7 @@ Feature: Internationalization In order to be able to understand the interface Background: - Given I am on the "login" page + Given I navigate to page "/login" Scenario Outline: I select "" in the language menu and see "" When I select "" in the language menu @@ -18,6 +18,6 @@ Feature: Internationalization | English | Login | Scenario: Keep preferred language after refresh - Given I previously switched the language to "Français" + When I select "Français" in the language menu And I refresh the page Then the whole user interface appears in "Français" diff --git a/cypress/integration/Internationalization/I_see_a_button_with_the_label_{string}.js b/cypress/integration/Internationalization/I_see_a_button_with_the_label_{string}.js new file mode 100644 index 000000000..a67f9d7df --- /dev/null +++ b/cypress/integration/Internationalization/I_see_a_button_with_the_label_{string}.js @@ -0,0 +1,5 @@ +import { Then } from "cypress-cucumber-preprocessor/steps"; + +Then("I see a button with the label {string}", label => { + cy.contains("button", label); +}); \ No newline at end of file diff --git a/cypress/integration/Internationalization/I_select_{string}_in_the_language_menu.js b/cypress/integration/Internationalization/I_select_{string}_in_the_language_menu.js new file mode 100644 index 000000000..b850a7573 --- /dev/null +++ b/cypress/integration/Internationalization/I_select_{string}_in_the_language_menu.js @@ -0,0 +1,8 @@ +import { When } from "cypress-cucumber-preprocessor/steps"; + +When("I select {string} in the language menu", language => { + cy.get(".locale-menu") + .click(); + cy.contains(".locale-menu-popover a", language) + .click(); +}); \ No newline at end of file diff --git a/cypress/integration/Internationalization/the_whole_user_interface_appears_in_{string}.js b/cypress/integration/Internationalization/the_whole_user_interface_appears_in_{string}.js new file mode 100644 index 000000000..4d80b8a0d --- /dev/null +++ b/cypress/integration/Internationalization/the_whole_user_interface_appears_in_{string}.js @@ -0,0 +1,8 @@ +import { Then } from "cypress-cucumber-preprocessor/steps"; +import locales from '../../../webapp/locales' + +Then("the whole user interface appears in {string}", language => { + const { code } = locales.find((entry) => entry.name === language); + cy.get(`html[lang=${code}]`); + cy.getCookie("locale").should("have.property", "value", code); +}); \ No newline at end of file diff --git a/cypress/integration/common/.steps.js b/cypress/integration/common/.steps.js index e18f0d09b..5a503985a 100644 --- a/cypress/integration/common/.steps.js +++ b/cypress/integration/common/.steps.js @@ -52,26 +52,6 @@ When("a blocked user visits the post page of one of my authored posts", () => { cy.openPage('post/previously-created-post') }) -When("I select {string} in the language menu", name => { - cy.switchLanguage(name, true); -}); - -Given("I previously switched the language to {string}", name => { - cy.switchLanguage(name, true); -}); - -Then("the whole user interface appears in {string}", name => { - const { - code - } = helpers.getLangByName(name); - cy.get(`html[lang=${code}]`); - cy.getCookie("locale").should("have.property", "value", code); -}); - -Then("I see a button with the label {string}", label => { - cy.contains("button", label); -}); - When(`I click on the menu item {string}`, linkOrButton => { cy.contains(".ds-menu-item", linkOrButton).click(); }); diff --git a/cypress/integration/User.Authentication/I_refresh_the_page.js b/cypress/integration/common/I_refresh_the_page.js similarity index 100% rename from cypress/integration/User.Authentication/I_refresh_the_page.js rename to cypress/integration/common/I_refresh_the_page.js diff --git a/cypress/support/commands.js b/cypress/support/commands.js index eb91b800f..686bf3352 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -19,11 +19,6 @@ import { GraphQLClient, request } from 'graphql-request' import { gql } from '../../backend/src/helpers/jest' import config from '../../backend/src/config' -const switchLang = name => { - cy.get(".locale-menu").click(); - cy.contains(".locale-menu-popover a", name).click(); -}; - const authenticatedHeaders = (variables) => { const mutation = gql` mutation($email: String!, $password: String!) { @@ -37,19 +32,6 @@ const authenticatedHeaders = (variables) => { }) } -Cypress.Commands.add("switchLanguage", (name, force) => { - const { code } = helpers.getLangByName(name); - if (force) { - switchLang(name); - } else { - cy.get("html").then($html => { - if ($html && $html.attr("lang") !== code) { - switchLang(name); - } - }); - } -}); - Cypress.Commands.add("logout", () => { cy.visit(`/logout`); cy.location("pathname").should("contain", "/login"); // we're out diff --git a/cypress/support/helpers.js b/cypress/support/helpers.js deleted file mode 100644 index 7d66af5d6..000000000 --- a/cypress/support/helpers.js +++ /dev/null @@ -1,8 +0,0 @@ -import find from 'lodash/find' -import locales from '../../webapp/locales' - -export default { - getLangByName(name) { - return find(locales, { name }) - } -}