diff --git a/cypress/e2e/account/changeLanguage.feature b/cypress/e2e/dashboard/changeLanguage.feature similarity index 100% rename from cypress/e2e/account/changeLanguage.feature rename to cypress/e2e/dashboard/changeLanguage.feature diff --git a/cypress/support/pages/account/pageAccount.js b/cypress/support/pages/account/pageAccount.js index fc6eb839..9aab1ff7 100644 --- a/cypress/support/pages/account/pageAccount.js +++ b/cypress/support/pages/account/pageAccount.js @@ -5,25 +5,6 @@ class Account { static #settingsButton = '[data-testid="settings"]' static #email = '[data-testid="user_email"]' static #emailReadOnly = '[data-testid="user_email_readonly"]' - static #languageMenu = '#language-menu' - static #selectedLanguage = '#selected-language' - static #listOfAllLanguages = '#available-languages' - static #germanLanguage = '[data-testid="available-language-de"]' - static #spanishLanguage = '[data-testid="available-language-es"]' - static #ukrainianLanguage = '[data-testid="available-language-uk"]' - static #englishLanguage = '[data-testid="available-language-en"]' - static #pageTitle = '#page-title' - - static #testAssertionData = { - german: 'Deutsch', - spanish: 'Español', - ukrainian: 'Yкраїнська', - english: 'English', - overviewInGerman: 'Übersicht', - overviewInSpanish: 'Panel', - overviewInUkrainian: 'Панель керування', - overviewInEnglish: 'Dashboard' - } navigateToAccountSettingsSection () { cy.get(Account.#initialsButton).click() @@ -40,105 +21,5 @@ class Account { cy.get(Account.#emailReadOnly).should('have.attr', 'readonly') } } - - assertNameInitialsIsVisible () { - cy.get(Account.#initialsButton).should('be.visible') - } - - clickInitialsOfName () { - cy.get(Account.#initialsButton) - .should('be.visible') - .then($btn => { - if ($btn.is(':disabled')) { - cy.log('Button exists and is disabled!') - return - } else { - cy.log('Button exists and is enabled!') - cy.wrap($btn).click() - } - }) - } - - clickLanguagesDropDownMenu () { - cy.get(Account.#languageMenu) - .should('be.visible') - .click() - .then(() => { - cy.get(Account.#selectedLanguage).should('be.visible') - cy.get(Account.#listOfAllLanguages).find('li').each($element => { - cy.get($element).should('have.prop', 'value') - cy.get($element).should('be.visible') - }) - }) - } - - changeLanguage (language) { - if (language === 'german') { - return this.selectLanguage( - Account.#germanLanguage, - Account.#testAssertionData.german - ) - } - - if (language === 'spanish') { - return this.selectLanguage( - Account.#spanishLanguage, - Account.#testAssertionData.spanish - ) - } - - if (language === 'ukrainian') { - return this.selectLanguage( - Account.#ukrainianLanguage, - Account.#testAssertionData.ukrainian - ) - } - - return this.selectLanguage( - Account.#englishLanguage, - Account.#testAssertionData.english - ) - } - - selectLanguage (sel, language) { - return cy.contains(sel, language) - .should('be.visible') - .click() - .wait(['@alerts_api']) - } - - assertLanguageUpdate (updatedText) { - cy.wait(300) - .get(Account.#pageTitle) - .invoke('text') - .should('eq', updatedText) - cy.get(Account.#pageTitle) - .invoke('attr', 'data-testid') - .should('eq', updatedText) - } - - verifyLanguageChanged (language) { - if (language === 'german') { - return this.assertLanguageUpdate( - Account.#testAssertionData.overviewInGerman - ) - } - - if (language === 'spanish') { - return this.assertLanguageUpdate( - Account.#testAssertionData.overviewInSpanish - ) - } - - if (language === 'ukrainian') { - return this.assertLanguageUpdate( - Account.#testAssertionData.overviewInUkrainian - ) - } - - return this.assertLanguageUpdate( - Account.#testAssertionData.overviewInEnglish - ) - } } export default Account diff --git a/cypress/support/pages/dashboard/pageDashboard.js b/cypress/support/pages/dashboard/pageDashboard.js index 41aec8b3..8115c18c 100644 --- a/cypress/support/pages/dashboard/pageDashboard.js +++ b/cypress/support/pages/dashboard/pageDashboard.js @@ -2,6 +2,27 @@ class Dashboard { + static #initialsButton = '[data-testid="initials"]' + static #languageMenu = '#language-menu' + static #selectedLanguage = '#selected-language' + static #listOfAllLanguages = '#available-languages' + static #germanLanguage = '[data-testid="available-language-de"]' + static #spanishLanguage = '[data-testid="available-language-es"]' + static #ukrainianLanguage = '[data-testid="available-language-uk"]' + static #englishLanguage = '[data-testid="available-language-en"]' + static #getPageTitle = '#page-title' + + static #testAssertionData = { + german: 'Deutsch', + spanish: 'Español', + ukrainian: 'Yкраїнська', + english: 'English', + overviewInGerman: 'Übersicht', + overviewInSpanish: 'Panel', + overviewInUkrainian: 'Панель керування', + overviewInEnglish: 'Dashboard' + } + static #welcomeMessage = '[data-testid="welcome-section"]' static #dashboardTasksTitle = '[data-testid="dashboard-tasks-title"]' static #dashboardTaskCourseName = '[data-testid="task-course-name"]' @@ -11,6 +32,106 @@ class Dashboard { static #newsSection = '[data-testid="news-section"]' static #titleOnDashboardPage = '[id="page-title"]' + assertNameInitialsIsVisible () { + cy.get(Dashboard.#initialsButton).should('be.visible') + } + + clickInitialsOfName () { + cy.get(Dashboard.#initialsButton) + .should('be.visible') + .then($btn => { + if ($btn.is(':disabled')) { + cy.log('Button exists and is disabled!') + return + } else { + cy.log('Button exists and is enabled!') + cy.wrap($btn).click() + } + }) + } + + clickLanguagesDropDownMenu () { + cy.get(Dashboard.#languageMenu) + .should('be.visible') + .click() + .then(() => { + cy.get(Dashboard.#selectedLanguage).should('be.visible') + cy.get(Dashboard.#listOfAllLanguages).find('li').each($element => { + cy.get($element).should('have.prop', 'value') + cy.get($element).should('be.visible') + }) + }) + } + + changeLanguage (language) { + if (language === 'german') { + return this.selectLanguage( + Dashboard.#germanLanguage, + Dashboard.#testAssertionData.german + ) + } + + if (language === 'spanish') { + return this.selectLanguage( + Dashboard.#spanishLanguage, + Dashboard.#testAssertionData.spanish + ) + } + + if (language === 'ukrainian') { + return this.selectLanguage( + Dashboard.#ukrainianLanguage, + Dashboard.#testAssertionData.ukrainian + ) + } + + return this.selectLanguage( + Dashboard.#englishLanguage, + Dashboard.#testAssertionData.english + ) + } + + selectLanguage (sel, language) { + return cy.contains(sel, language) + .should('be.visible') + .click() + .wait(['@alerts_api']) + } + + assertLanguageUpdate (updatedText) { + cy.wait(300) + .get(Dashboard.#getPageTitle) + .invoke('text') + .should('eq', updatedText) + cy.get(Dashboard.#getPageTitle) + .invoke('attr', 'data-testid') + .should('eq', updatedText) + } + + verifyLanguageChanged (language) { + if (language === 'german') { + return this.assertLanguageUpdate( + Dashboard.#testAssertionData.overviewInGerman + ) + } + + if (language === 'spanish') { + return this.assertLanguageUpdate( + Dashboard.#testAssertionData.overviewInSpanish + ) + } + + if (language === 'ukrainian') { + return this.assertLanguageUpdate( + Dashboard.#testAssertionData.overviewInUkrainian + ) + } + + return this.assertLanguageUpdate( + Dashboard.#testAssertionData.overviewInEnglish + ) + } + arriveOnDashboard() { cy.visit('/dashboard') cy.url() diff --git a/cypress/support/step_definition/account/changeLanguageSteps.spec.js b/cypress/support/step_definition/dashboard/changeLanguageSteps.spec.js similarity index 55% rename from cypress/support/step_definition/account/changeLanguageSteps.spec.js rename to cypress/support/step_definition/dashboard/changeLanguageSteps.spec.js index ba77f7cf..f11df3ab 100644 --- a/cypress/support/step_definition/account/changeLanguageSteps.spec.js +++ b/cypress/support/step_definition/dashboard/changeLanguageSteps.spec.js @@ -1,24 +1,24 @@ const { When, Then } = require("@badeball/cypress-cucumber-preprocessor") -import Account from '../../pages/account/pageAccount' +import Dashboard from '../../pages/dashboard/pageDashboard' -const account = new Account() +const dashboard = new Dashboard() Then('I can see initials of my name', () => { - account.assertNameInitialsIsVisible() + dashboard.assertNameInitialsIsVisible() }) When('I click on initials of my name', () => { - account.clickInitialsOfName() + dashboard.clickInitialsOfName() }) Then('I click on language drop down menu', () => { - account.clickLanguagesDropDownMenu() + dashboard.clickLanguagesDropDownMenu() }) When('I can change language to {string}', language => { - account.changeLanguage(language) + dashboard.changeLanguage(language) }) Then('I can see title in dashboard is changed to {string}', language => { - account.verifyLanguageChanged(language) + dashboard.verifyLanguageChanged(language) }) diff --git a/package-lock.json b/package-lock.json index 8437ae89..760c9cbb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -86,13 +86,13 @@ } }, "node_modules/@babel/generator": { - "version": "7.22.15", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.22.15.tgz", - "integrity": "sha512-Zu9oWARBqeVOW0dZOjXc3JObrzuqothQ3y/n1kUtrjCoCPLkXUwMvOo/F/TCfoHMbWIFlWwpZtkZVb9ga4U2pA==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.23.0.tgz", + "integrity": "sha512-lN85QRR+5IbYrMWM6Y4pE/noaQtg4pNiqeNGX60eqOfo6gtEj6uw/JagelB8vVztSd7R6M5n1+PQkDbHbBRU4g==", "dev": true, "peer": true, "dependencies": { - "@babel/types": "^7.22.15", + "@babel/types": "^7.23.0", "@jridgewell/gen-mapping": "^0.3.2", "@jridgewell/trace-mapping": "^0.3.17", "jsesc": "^2.5.1" @@ -214,14 +214,14 @@ } }, "node_modules/@babel/helper-function-name": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.22.5.tgz", - "integrity": "sha512-wtHSq6jMRE3uF2otvfuD3DIvVhOsSNshQl0Qrd7qC9oQJzHvOL4qQXlQn2916+CXGywIjpGuIkoyZRRxHPiNQQ==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.23.0.tgz", + "integrity": "sha512-OErEqsrxjZTJciZ4Oo+eoZqeW9UIiOcuYKRJA4ZAgV9myA+pOXhhmpfNCKjEH/auVfEYVFJ6y1Tc4r0eIApqiw==", "dev": true, "peer": true, "dependencies": { - "@babel/template": "^7.22.5", - "@babel/types": "^7.22.5" + "@babel/template": "^7.22.15", + "@babel/types": "^7.23.0" }, "engines": { "node": ">=6.9.0" @@ -458,9 +458,9 @@ } }, "node_modules/@babel/parser": { - "version": "7.22.16", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.22.16.tgz", - "integrity": "sha512-+gPfKv8UWeKKeJTUxe59+OobVcrYHETCsORl61EmSkmgymguYk/X5bp7GuUIXaFsc6y++v8ZxPsLSSuujqDphA==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.0.tgz", + "integrity": "sha512-vvPKKdMemU85V9WE/l5wZEmImpCtLqbnTvqDS2U1fJ96KrxoW7KrXhNsNCblQlg8Ck4b85yxdTyelsMUgFUXiw==", "dev": true, "bin": { "parser": "bin/babel-parser.js" @@ -1735,20 +1735,20 @@ } }, "node_modules/@babel/traverse": { - "version": "7.22.20", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.22.20.tgz", - "integrity": "sha512-eU260mPZbU7mZ0N+X10pxXhQFMGTeLb9eFS0mxehS8HZp9o1uSnFeWQuG1UPrlxgA7QoUzFhOnilHDp0AXCyHw==", + "version": "7.23.2", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.2.tgz", + "integrity": "sha512-azpe59SQ48qG6nu2CzcMLbxUudtN+dOM9kDbUqGq3HXUJRlo7i8fvPoxQUzYgLZ4cMVmuZgm8vvBpNeRhd6XSw==", "dev": true, "peer": true, "dependencies": { "@babel/code-frame": "^7.22.13", - "@babel/generator": "^7.22.15", + "@babel/generator": "^7.23.0", "@babel/helper-environment-visitor": "^7.22.20", - "@babel/helper-function-name": "^7.22.5", + "@babel/helper-function-name": "^7.23.0", "@babel/helper-hoist-variables": "^7.22.5", "@babel/helper-split-export-declaration": "^7.22.6", - "@babel/parser": "^7.22.16", - "@babel/types": "^7.22.19", + "@babel/parser": "^7.23.0", + "@babel/types": "^7.23.0", "debug": "^4.1.0", "globals": "^11.1.0" }, @@ -1757,14 +1757,14 @@ } }, "node_modules/@babel/types": { - "version": "7.22.19", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.22.19.tgz", - "integrity": "sha512-P7LAw/LbojPzkgp5oznjE6tQEIWbp4PkkfrZDINTro9zgBRtI324/EYsiSI7lhPbpIQ+DCeR2NNmMWANGGfZsg==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.0.tgz", + "integrity": "sha512-0oIyUfKoI3mSqMvsxBdclDwxXKXAUA8v/apZbc+iSyARYou1o8ZGDxbUYyLFoW2arqS2jDGqJuZvv1d/io1axg==", "dev": true, "peer": true, "dependencies": { "@babel/helper-string-parser": "^7.22.5", - "@babel/helper-validator-identifier": "^7.22.19", + "@babel/helper-validator-identifier": "^7.22.20", "to-fast-properties": "^2.0.0" }, "engines": {