diff --git a/src/pybind/mgr/dashboard/frontend/cypress.config.ts b/src/pybind/mgr/dashboard/frontend/cypress.config.ts index ba3bdaab035d4c..fa334988305b64 100644 --- a/src/pybind/mgr/dashboard/frontend/cypress.config.ts +++ b/src/pybind/mgr/dashboard/frontend/cypress.config.ts @@ -1,4 +1,4 @@ -import { defineConfig } from "cypress"; +import { defineConfig } from 'cypress'; export default defineConfig({ video: true, @@ -7,22 +7,22 @@ export default defineConfig({ responseTimeout: 45000, viewportHeight: 1080, viewportWidth: 1920, - projectId: "k7ab29", - reporter: "cypress-multi-reporters", + projectId: 'k7ab29', + reporter: 'cypress-multi-reporters', reporterOptions: { - reporterEnabled: "spec, mocha-junit-reporter", + reporterEnabled: 'spec, mocha-junit-reporter', mochaJunitReporterReporterOptions: { - mochaFile: "cypress/reports/results-[hash].xml", - }, + mochaFile: 'cypress/reports/results-[hash].xml' + } }, retries: 1, env: { - LOGIN_USER: "admin", - LOGIN_PWD: "admin", - CEPH2_URL: "https://localhost:4202/", + LOGIN_USER: 'admin', + LOGIN_PWD: 'admin', + CEPH2_URL: 'https://localhost:4202/' }, chromeWebSecurity: false, @@ -37,19 +37,19 @@ export default defineConfig({ // We've imported your old cypress plugins here. // You may want to clean this up later by importing these. setupNodeEvents(on, config) { - return require("./cypress/plugins/index.js")(on, config); + return require('./cypress/plugins/index.js')(on, config); }, - baseUrl: "https://localhost:4200/", - excludeSpecPattern: ["*.po.ts", "**/orchestrator/**"], + baseUrl: 'https://localhost:4200/', + excludeSpecPattern: ['*.po.ts', '**/orchestrator/**'], experimentalSessionAndOrigin: true, - specPattern: "cypress/e2e/**/*-spec.{js,jsx,ts,tsx,feature}", + specPattern: 'cypress/e2e/**/*-spec.{js,jsx,ts,tsx,feature}' }, component: { devServer: { - framework: "angular", - bundler: "webpack", + framework: 'angular', + bundler: 'webpack' }, - specPattern: "**/*.cy.ts", - }, + specPattern: '**/*.cy.ts' + } }); diff --git a/src/pybind/mgr/dashboard/frontend/cypress/support/commands.ts b/src/pybind/mgr/dashboard/frontend/cypress/support/commands.ts index 2ab1b50025b849..09a2788eb00429 100644 --- a/src/pybind/mgr/dashboard/frontend/cypress/support/commands.ts +++ b/src/pybind/mgr/dashboard/frontend/cypress/support/commands.ts @@ -86,8 +86,14 @@ function requestAuth(username: string, password: string, url = '') { } // @ts-ignore -Cypress.Commands.add('text', { prevSubject: true }, (subject: any) => { - return subject.text(); +Cypress.Commands.add('text', { prevSubject: true }, ($element: JQuery) => { + cy.wrap($element).scrollIntoView(); + return cy + .wrap($element) + .invoke('text') + .then((text: string) => { + return text.toString(); + }); }); Cypress.Commands.add('logToConsole', (message: string, optional?: any) => {