mirror of https://github.com/rancher/dashboard.git
E2E Tests: Add logging for env vars (#7858)
* E2E Tests: Add logging for env vars * Fix lint issues
This commit is contained in:
parent
18f1f1dec4
commit
6d6c9d4e20
|
|
@ -2,6 +2,8 @@ import { defineConfig } from 'cypress';
|
|||
// Required for env vars to be available in cypress
|
||||
require('dotenv').config();
|
||||
|
||||
const skipSetup = process.env.TEST_SKIP_SETUP === 'true';
|
||||
|
||||
/**
|
||||
* Filter test spec paths based on env var configuration
|
||||
* @returns
|
||||
|
|
@ -10,7 +12,7 @@ const getSpecPattern = (): string[] => {
|
|||
const optionalPaths = [
|
||||
{
|
||||
path: 'cypress/e2e/tests/setup/**/*.spec.ts',
|
||||
active: process.env.TEST_SKIP_SETUP !== 'true'
|
||||
active: !skipSetup
|
||||
}
|
||||
];
|
||||
const activePaths = optionalPaths.filter(({ active }) => Boolean(active)).map(({ path }) => path);
|
||||
|
|
@ -23,6 +25,43 @@ const getSpecPattern = (): string[] => {
|
|||
};
|
||||
const baseUrl = (process.env.TEST_BASE_URL || 'https://localhost:8005').replace(/\/$/, '');
|
||||
|
||||
// Default user name, if TEST_USERNAME is not provided
|
||||
const DEFAULT_USERNAME = 'admin';
|
||||
|
||||
// Log summary of the environment variables that we have detected (or are going ot use) - we won't show any passwords
|
||||
console.log('E2E Test Configuration'); // eslint-disable-line no-console
|
||||
console.log(''); // eslint-disable-line no-console
|
||||
|
||||
if (process.env.TEST_USERNAME) {
|
||||
console.log(` Username: ${ process.env.TEST_USERNAME }`); // eslint-disable-line no-console
|
||||
} else {
|
||||
console.log(` Username: ${ DEFAULT_USERNAME } (TEST_USERNAME not set, using default)`); // eslint-disable-line no-console
|
||||
}
|
||||
|
||||
if (process.env.CATTLE_BOOTSTRAP_PASSWORD && process.env.TEST_PASSWORD) {
|
||||
console.log(' ❌ You should not set both CATTLE_BOOTSTRAP_PASSWORD and TEST_PASSWORD - CATTLE_BOOTSTRAP_PASSWORD will be used'); // eslint-disable-line no-console
|
||||
}
|
||||
|
||||
if (!skipSetup && !process.env.CATTLE_BOOTSTRAP_PASSWORD) {
|
||||
console.log(' ❌ You must provide CATTLE_BOOTSTRAP_PASSWORD when running setup tests'); // eslint-disable-line no-console
|
||||
}
|
||||
|
||||
if (!process.env.CATTLE_BOOTSTRAP_PASSWORD && !process.env.TEST_PASSWORD) {
|
||||
console.log(' ❌ You must provide one of CATTLE_BOOTSTRAP_PASSWORD or TEST_PASSWORD'); // eslint-disable-line no-console
|
||||
}
|
||||
|
||||
if (skipSetup && !process.env.TEST_PASSWORD) {
|
||||
console.log(' ❌ You should provide TEST_PASSWORD when running the tests without the setup tests'); // eslint-disable-line no-console
|
||||
}
|
||||
|
||||
if (skipSetup) {
|
||||
console.log(` Setup tests will NOT be run`); // eslint-disable-line no-console
|
||||
} else {
|
||||
console.log(` Setup tests will be run`); // eslint-disable-line no-console
|
||||
}
|
||||
|
||||
console.log(` Dashboard URL: ${ baseUrl }`); // eslint-disable-line no-console
|
||||
|
||||
export default defineConfig({
|
||||
projectId: process.env.TEST_PROJECT_ID,
|
||||
defaultCommandTimeout: process.env.TEST_TIMEOUT ? +process.env.TEST_TIMEOUT : 60000,
|
||||
|
|
@ -45,8 +84,8 @@ export default defineConfig({
|
|||
'pkg/rancher-components/src/components/**/*.{vue,ts,js}',
|
||||
]
|
||||
},
|
||||
username: process.env.TEST_USERNAME,
|
||||
password: process.env.TEST_PASSWORD,
|
||||
username: process.env.TEST_USERNAME || DEFAULT_USERNAME,
|
||||
password: process.env.CATTLE_BOOTSTRAP_PASSWORD || process.env.TEST_PASSWORD,
|
||||
bootstrapPassword: process.env.CATTLE_BOOTSTRAP_PASSWORD,
|
||||
},
|
||||
e2e: {
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@
|
|||
"start:prod": "DEV_PORTS=true NODE_ENV=production yarn start",
|
||||
"generate": "./node_modules/.bin/nuxt generate",
|
||||
"dev-debug": "node --inspect ./node_modules/.bin/nuxt",
|
||||
"cy:e2e": "cypress open --e2e --browser chrome",
|
||||
"cy:open": "cypress open",
|
||||
"cy:run": "cypress run --browser chrome",
|
||||
"cy:run:sorry": "./scripts/e2e",
|
||||
|
|
|
|||
Loading…
Reference in New Issue