mirror of https://github.com/rancher/dashboard.git
Update Cypress to version 10 (#6146)
* Run Cypress migration scripts; Update failing parts * Move env var assignments to Cypress configuration; Correct env patterns * Correct imports within the Cypress tests * Correct TS linting configuration errors after update * Return directly spec path in cypress configuration
This commit is contained in:
parent
647b917ed3
commit
a71dee857e
|
|
@ -0,0 +1,44 @@
|
||||||
|
import { defineConfig } from 'cypress';
|
||||||
|
require('dotenv').config();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filter test spec paths based on env var configuration
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
const getSpecPattern = (): string[] => {
|
||||||
|
const optionalPaths = [
|
||||||
|
{
|
||||||
|
path: 'cypress/e2e/tests/setup/**/*.spec.ts',
|
||||||
|
active: process.env.TEST_SKIP_SETUP !== 'true'
|
||||||
|
}
|
||||||
|
];
|
||||||
|
const activePaths = optionalPaths.filter(({ active }) => Boolean(active)).map(({ path }) => path);
|
||||||
|
|
||||||
|
return [
|
||||||
|
...activePaths,
|
||||||
|
'cypress/e2e/tests/pages/**/*.spec.ts',
|
||||||
|
'cypress/e2e/tests/navigation/**/*.spec.ts'
|
||||||
|
];
|
||||||
|
};
|
||||||
|
const baseUrl = (process.env.TEST_BASE_URL || 'https://localhost:8005').replace(/\/$/, '');
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
defaultCommandTimeout: 60000,
|
||||||
|
trashAssetsBeforeRuns: true,
|
||||||
|
env: {
|
||||||
|
baseUrl,
|
||||||
|
username: process.env.TEST_USERNAME,
|
||||||
|
password: process.env.TEST_PASSWORD,
|
||||||
|
bootstrapPassword: process.env.CATTLE_BOOTSTRAP_PASSWORD,
|
||||||
|
},
|
||||||
|
e2e: {
|
||||||
|
// 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.ts')(on, config);
|
||||||
|
},
|
||||||
|
experimentalSessionAndOrigin: true,
|
||||||
|
specPattern: getSpecPattern(),
|
||||||
|
baseUrl
|
||||||
|
},
|
||||||
|
});
|
||||||
10
cypress.json
10
cypress.json
|
|
@ -1,10 +0,0 @@
|
||||||
{
|
|
||||||
"experimentalSessionAndOrigin": true,
|
|
||||||
"trashAssetsBeforeRuns": true,
|
|
||||||
"testFiles": [
|
|
||||||
"tests/setup/**/*.spec.ts",
|
|
||||||
"tests/pages/**/*.spec.ts",
|
|
||||||
"tests/navigation/**/*.spec.ts"
|
|
||||||
],
|
|
||||||
"defaultCommandTimeout": 60000
|
|
||||||
}
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import ComponentPo from '@/cypress/integration/po/components/component.po';
|
import ComponentPo from '@/cypress/e2e/po/components/component.po';
|
||||||
|
|
||||||
export default class AsyncButtonPo extends ComponentPo {
|
export default class AsyncButtonPo extends ComponentPo {
|
||||||
click(): Cypress.Chainable {
|
click(): Cypress.Chainable {
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import ComponentPo from '@/cypress/integration/po/components/component.po';
|
import ComponentPo from '@/cypress/e2e/po/components/component.po';
|
||||||
|
|
||||||
export default class CheckboxInputPo extends ComponentPo {
|
export default class CheckboxInputPo extends ComponentPo {
|
||||||
/**
|
/**
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { CypressChainable } from '@/cypress/integration/po/po.types';
|
import { CypressChainable } from '@/cypress/e2e/po/po.types';
|
||||||
|
|
||||||
export default class ComponentPo {
|
export default class ComponentPo {
|
||||||
public self: () => CypressChainable
|
public self: () => CypressChainable
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import ComponentPo from '@/cypress/integration/po/components/component.po';
|
import ComponentPo from '@/cypress/e2e/po/components/component.po';
|
||||||
|
|
||||||
export default class FormPo extends ComponentPo {
|
export default class FormPo extends ComponentPo {
|
||||||
/**
|
/**
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import ComponentPo from '@/cypress/integration/po/components/component.po';
|
import ComponentPo from '@/cypress/e2e/po/components/component.po';
|
||||||
|
|
||||||
export default class LabeledInputPo extends ComponentPo {
|
export default class LabeledInputPo extends ComponentPo {
|
||||||
/**
|
/**
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import ComponentPo from '@/cypress/integration/po/components/component.po';
|
import ComponentPo from '@/cypress/e2e/po/components/component.po';
|
||||||
|
|
||||||
export default class PasswordPo extends ComponentPo {
|
export default class PasswordPo extends ComponentPo {
|
||||||
/**
|
/**
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import ComponentPo from '@/cypress/integration/po/components/component.po';
|
import ComponentPo from '@/cypress/e2e/po/components/component.po';
|
||||||
|
|
||||||
export default class RadioGroupInputPo extends ComponentPo {
|
export default class RadioGroupInputPo extends ComponentPo {
|
||||||
/**
|
/**
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import ComponentPo from '@/cypress/integration/po/components/component.po';
|
import ComponentPo from '@/cypress/e2e/po/components/component.po';
|
||||||
|
|
||||||
export default class RadioInputPo extends ComponentPo {
|
export default class RadioInputPo extends ComponentPo {
|
||||||
/**
|
/**
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import PagePo from '@/cypress/integration/po/pages/page.po';
|
import PagePo from '@/cypress/e2e/po/pages/page.po';
|
||||||
|
|
||||||
export default class HomePagePo extends PagePo {
|
export default class HomePagePo extends PagePo {
|
||||||
static url: string = '/home'
|
static url: string = '/home'
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import PagePo from '@/cypress/integration/po/pages/page.po';
|
import PagePo from '@/cypress/e2e/po/pages/page.po';
|
||||||
import LabeledInputPo from '@/cypress/integration/po/components/labeled-input.po';
|
import LabeledInputPo from '@/cypress/e2e/po/components/labeled-input.po';
|
||||||
import AsyncButtonPo from '@/cypress/integration/po/components/async-button.po';
|
import AsyncButtonPo from '@/cypress/e2e/po/components/async-button.po';
|
||||||
import PasswordPo from '~/cypress/integration/po/components/password.po';
|
import PasswordPo from '@/cypress/e2e/po/components/password.po';
|
||||||
|
|
||||||
export class LoginPagePo extends PagePo {
|
export class LoginPagePo extends PagePo {
|
||||||
static url: string = '/auth/login'
|
static url: string = '/auth/login'
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import ComponentPo from '@/cypress/integration/po/components/component.po';
|
import ComponentPo from '@/cypress/e2e/po/components/component.po';
|
||||||
|
|
||||||
export default class PagePo extends ComponentPo {
|
export default class PagePo extends ComponentPo {
|
||||||
constructor(private path: string, selector: string = '.dashboard-root') {
|
constructor(private path: string, selector: string = '.dashboard-root') {
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import PagePo from '@/cypress/integration/po/pages/page.po';
|
import PagePo from '@/cypress/e2e/po/pages/page.po';
|
||||||
import LabeledInputPo from '@/cypress/integration/po/components/labeled-input.po';
|
import LabeledInputPo from '@/cypress/e2e/po/components/labeled-input.po';
|
||||||
import CheckboxInputPo from '@/cypress/integration/po/components/checkbox-input.po';
|
import CheckboxInputPo from '@/cypress/e2e/po/components/checkbox-input.po';
|
||||||
import RadioGroupInputPo from '@/cypress/integration/po/components/radio-group-input.po';
|
import RadioGroupInputPo from '@/cypress/e2e/po/components/radio-group-input.po';
|
||||||
import AsyncButtonPo from '@/cypress/integration/po/components/async-button.po';
|
import AsyncButtonPo from '@/cypress/e2e/po/components/async-button.po';
|
||||||
import PasswordPo from '~/cypress/integration/po/components/password.po';
|
import PasswordPo from '@/cypress/e2e/po/components/password.po';
|
||||||
|
|
||||||
export class RancherSetupAuthVerifyPage extends PagePo {
|
export class RancherSetupAuthVerifyPage extends PagePo {
|
||||||
static url: string = '/auth/login'
|
static url: string = '/auth/login'
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import PagePo from '@/cypress/integration/po/pages/page.po';
|
import PagePo from '@/cypress/e2e/po/pages/page.po';
|
||||||
import AsyncButtonPo from '@/cypress/integration/po/components/async-button.po';
|
import AsyncButtonPo from '@/cypress/e2e/po/components/async-button.po';
|
||||||
import FormPo from '@/cypress/integration/po/components/form.po';
|
import FormPo from '@/cypress/e2e/po/components/form.po';
|
||||||
import PasswordPo from '~/cypress/integration/po/components/password.po';
|
import PasswordPo from '@/cypress/e2e/po/components/password.po';
|
||||||
|
|
||||||
export class RancherSetupPagePo extends PagePo {
|
export class RancherSetupPagePo extends PagePo {
|
||||||
static url: string = '/auth/login'
|
static url: string = '/auth/login'
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import ComponentPo from '@/cypress/integration/po/components/component.po';
|
import ComponentPo from '@/cypress/e2e/po/components/component.po';
|
||||||
|
|
||||||
export default class BurgerMenuPo extends ComponentPo {
|
export default class BurgerMenuPo extends ComponentPo {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import ComponentPo from '@/cypress/integration/po/components/component.po';
|
import ComponentPo from '@/cypress/e2e/po/components/component.po';
|
||||||
|
|
||||||
export default class PageActionsPo extends ComponentPo {
|
export default class PageActionsPo extends ComponentPo {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import ComponentPo from '@/cypress/integration/po/components/component.po';
|
import ComponentPo from '@/cypress/e2e/po/components/component.po';
|
||||||
|
|
||||||
export default class ProductNavPo extends ComponentPo {
|
export default class ProductNavPo extends ComponentPo {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import PageActions from '@/cypress/integration/po/side-bars/page-actions.po';
|
import PageActions from '@/cypress/e2e/po/side-bars/page-actions.po';
|
||||||
import HomePagePo from '@/cypress/integration/po/pages/home.po';
|
import HomePagePo from '@/cypress/e2e/po/pages/home.po';
|
||||||
|
|
||||||
describe('Page Actions', () => {
|
describe('Page Actions', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import HomePagePo from '@/cypress/integration/po/pages/home.po';
|
import HomePagePo from '@/cypress/e2e/po/pages/home.po';
|
||||||
import BurgerMenuPo from '@/cypress/integration/po/side-bars/burger-side-menu.po';
|
import BurgerMenuPo from '@/cypress/e2e/po/side-bars/burger-side-menu.po';
|
||||||
|
|
||||||
Cypress.config();
|
Cypress.config();
|
||||||
describe('Side Menu: main', () => {
|
describe('Side Menu: main', () => {
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import HomePagePo from '@/cypress/integration/po/pages/home.po';
|
import HomePagePo from '@/cypress/e2e/po/pages/home.po';
|
||||||
import BurgerMenuPo from '@/cypress/integration/po/side-bars/burger-side-menu.po';
|
import BurgerMenuPo from '@/cypress/e2e/po/side-bars/burger-side-menu.po';
|
||||||
import ProductNavPo from '@/cypress/integration/po/side-bars/product-side-nav.po';
|
import ProductNavPo from '@/cypress/e2e/po/side-bars/product-side-nav.po';
|
||||||
|
|
||||||
Cypress.config();
|
Cypress.config();
|
||||||
describe('Side navigation: Cluster ', () => {
|
describe('Side navigation: Cluster ', () => {
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import HomePagePo from '@/cypress/integration/po/pages/home.po';
|
import HomePagePo from '@/cypress/e2e/po/pages/home.po';
|
||||||
import BurgerMenuPo from '@/cypress/integration/po/side-bars/burger-side-menu.po';
|
import BurgerMenuPo from '@/cypress/e2e/po/side-bars/burger-side-menu.po';
|
||||||
import PageActions from '@/cypress/integration/po/side-bars/page-actions.po';
|
import PageActions from '@/cypress/e2e/po/side-bars/page-actions.po';
|
||||||
|
|
||||||
describe('Home Page', () => {
|
describe('Home Page', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { LoginPagePo } from '@/cypress/integration/po/pages/login-page.po';
|
import { LoginPagePo } from '@/cypress/e2e/po/pages/login-page.po';
|
||||||
|
|
||||||
describe('Local authentication', () => {
|
describe('Local authentication', () => {
|
||||||
it('Log in with valid credentials', () => {
|
it('Log in with valid credentials', () => {
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import { RancherSetupPagePo } from '@/cypress/integration/po/pages/rancher-setup.po';
|
import { RancherSetupPagePo } from '@/cypress/e2e/po/pages/rancher-setup.po';
|
||||||
import { RancherSetupAuthVerifyPage } from '@/cypress/integration/po/pages/rancher-setup-auth-verify.po';
|
import { RancherSetupAuthVerifyPage } from '@/cypress/e2e/po/pages/rancher-setup-auth-verify.po';
|
||||||
|
|
||||||
describe('Rancher setup', () => {
|
describe('Rancher setup', () => {
|
||||||
it('Requires initial setup', () => {
|
it('Requires initial setup', () => {
|
||||||
|
|
@ -11,39 +11,9 @@ module.exports = (
|
||||||
on: Cypress.PluginEvents,
|
on: Cypress.PluginEvents,
|
||||||
config: Cypress.PluginConfigOptions
|
config: Cypress.PluginConfigOptions
|
||||||
) => {
|
) => {
|
||||||
// Disabled due freezing issues related to the CI machine resources
|
|
||||||
// deletePassedVideos(on);
|
|
||||||
|
|
||||||
// `on` is used to hook into various events Cypress emits
|
|
||||||
// `config` is the resolved Cypress config
|
|
||||||
const url = process.env.TEST_BASE_URL || 'https://localhost:8005';
|
|
||||||
|
|
||||||
config.baseUrl = url.replace(/\/$/, '');
|
|
||||||
|
|
||||||
config.env.username = process.env.TEST_USERNAME;
|
|
||||||
config.env.password = process.env.TEST_PASSWORD;
|
|
||||||
config.env.bootstrapPassword = process.env.CATTLE_BOOTSTRAP_PASSWORD;
|
|
||||||
config.env.skip_setup = process.env.TEST_SKIP_SETUP;
|
|
||||||
config.testFiles = skipSetup(config);
|
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove setup files from the Cypress config
|
|
||||||
* @param config Cypress config file
|
|
||||||
* @returns
|
|
||||||
*/
|
|
||||||
const skipSetup = (config: Cypress.PluginConfigOptions) => {
|
|
||||||
if (config.env.skip_setup === 'true') {
|
|
||||||
return (config.testFiles as string[]).filter(
|
|
||||||
path => !path.includes('tests/setup/')
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return config.testFiles;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Only upload videos for specs with failing
|
* Only upload videos for specs with failing
|
||||||
* Run this function after every spec to delete passed tests video
|
* Run this function after every spec to delete passed tests video
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { LoginPagePo } from '@/cypress/integration/po/pages/login-page.po';
|
import { LoginPagePo } from '@/cypress/e2e/po/pages/login-page.po';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Login local authentication, including first login and bootstrap if not cached
|
* Login local authentication, including first login and bootstrap if not cached
|
||||||
|
|
|
||||||
|
|
@ -125,8 +125,8 @@
|
||||||
"@babel/plugin-proposal-optional-chaining": "^7.14.5",
|
"@babel/plugin-proposal-optional-chaining": "^7.14.5",
|
||||||
"@babel/plugin-proposal-private-property-in-object": "^7.14.5",
|
"@babel/plugin-proposal-private-property-in-object": "^7.14.5",
|
||||||
"@babel/preset-typescript": "^7.15.0",
|
"@babel/preset-typescript": "^7.15.0",
|
||||||
"@cypress/vue": "^3.1.1",
|
"@cypress/vue": "^4.0.0",
|
||||||
"@cypress/webpack-dev-server": "^1.8.4",
|
"@cypress/webpack-dev-server": "^2.0.0",
|
||||||
"@nuxt/types": "2.14.6",
|
"@nuxt/types": "2.14.6",
|
||||||
"@nuxt/typescript-build": "^2.1.0",
|
"@nuxt/typescript-build": "^2.1.0",
|
||||||
"@nuxtjs/eslint-config-typescript": "^6.0.1",
|
"@nuxtjs/eslint-config-typescript": "^6.0.1",
|
||||||
|
|
@ -153,7 +153,7 @@
|
||||||
"core-js": "^3.20.3",
|
"core-js": "^3.20.3",
|
||||||
"css-loader": "4.3.0",
|
"css-loader": "4.3.0",
|
||||||
"csv-loader": "^3.0.3",
|
"csv-loader": "^3.0.3",
|
||||||
"cypress": "^9.6.0",
|
"cypress": "^10.3.1",
|
||||||
"eslint": "^7.32.0",
|
"eslint": "^7.32.0",
|
||||||
"eslint-config-standard": ">=12.0.0",
|
"eslint-config-standard": ">=12.0.0",
|
||||||
"eslint-import-resolver-node": "0.3.4",
|
"eslint-import-resolver-node": "0.3.4",
|
||||||
|
|
|
||||||
|
|
@ -3,5 +3,14 @@
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"types": ["@types/node", "@types/jest", "@nuxt/types"]
|
"types": ["@types/node", "@types/jest", "@nuxt/types"]
|
||||||
},
|
},
|
||||||
"exclude": ["node_modules", ".nuxt", "dist", "dist-pkg", "cypress", "shell/creators"]
|
"exclude": [
|
||||||
|
"node_modules",
|
||||||
|
".nuxt",
|
||||||
|
"dist",
|
||||||
|
"dist-pkg",
|
||||||
|
"cypress",
|
||||||
|
"shell/creators",
|
||||||
|
"cypress",
|
||||||
|
"./cypress.config.ts"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue