This commit is contained in:
2026-02-16 14:39:46 -08:00
parent ea6e5361be
commit 5e04bde2f1
6 changed files with 75 additions and 102 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/e2e/.abort-run

View File

@@ -7,6 +7,7 @@
"supportFile": "support/e2e.js", "supportFile": "support/e2e.js",
"pluginsFile": "plugins/index.js", "pluginsFile": "plugins/index.js",
"env": { "env": {
"expectedServerVersion": "8.2.4",
"apiBaseUrl": "http://localhost:7575/api/v8.0/", "apiBaseUrl": "http://localhost:7575/api/v8.0/",
"REMOTE_BASE_URL": "https://devtest.onayanova.com/", "REMOTE_BASE_URL": "https://devtest.onayanova.com/",
"REMOTE_API_URL": "https://devtest.onayanova.com/api/v8.0/", "REMOTE_API_URL": "https://devtest.onayanova.com/api/v8.0/",

View File

@@ -6,7 +6,6 @@ honestly though this may be enough to move to the next stage
- also include the version to test against in the command line as well. Put it in the pre-data generation and erasure block so it just aborts right away without modifying anything. Maybe just looks at the login page itself - also include the version to test against in the command line as well. Put it in the pre-data generation and erasure block so it just aborts right away without modifying anything. Maybe just looks at the login page itself
=-=-=-=-=-=-=-=-=-=-=-=- =-=-=-=-=-=-=-=-=-=-=-=-
From the olden times years ago: From the olden times years ago:

View File

@@ -1,66 +1,8 @@
//my sample users use obvious passwords "service/service", "accounting/accounting" triggering annoying your password is used in a hack warning in chrome const fs = require('fs')
//sample users are inteded to be this easy to guess for testing and trial evaluation purposes so not changing it const path = require('path')
// /**
// * @type {Cypress.PluginConfig}
// */
// module.exports = (on, config) => {
// on('before:browser:launch', (browser = {}, launchOptions) => {
// // Check if we are using Chrome or a Chromium-based browser
// if (browser.family === 'chromium' && browser.name !== 'electron') {
// // 1. Disable the specific password leak detection feature const ABORT_FLAG_PATH = path.join(__dirname, '..', '.abort-run')
// launchOptions.args.push('--disable-features=PasswordLeakDetection');
// // 2. Disable the "Save Password" and "Check Passwords" prompts
// launchOptions.preferences.default['credentials_enable_service'] = false;
// launchOptions.preferences.default['profile.password_manager_enabled'] = false;
// // 3. Specifically target the leak detection toggle in preferences
// launchOptions.preferences.default['profile.password_manager_leak_detection'] = false;
// return launchOptions;
// }
// });
// };
// module.exports = (on, config) => {
// on('before:browser:launch', (browser, launchOptions) => {
// if (browser.name === 'chrome') {
// launchOptions.args.push(
// '--disable-features=PasswordLeakDetection,PasswordManagerLeakDetection,PasswordCheck,InsecureCredentialsWarning'
// );
// }
// return launchOptions;
// });
// };
// /// <reference types="cypress" />
// // ***********************************************************
// // This example plugins/index.js can be used to load plugins
// //
// // You can change the location of this file or turn off loading
// // the plugins file with the 'pluginsFile' configuration option.
// //
// // You can read more here:
// // https://on.cypress.io/plugins-guide
// // ***********************************************************
// // This function is called when a project is opened or re-opened (e.g. due to
// // the project's config changing)
// /**
// * @type {Cypress.PluginConfig}
// */
// // eslint-disable-next-line no-unused-vars
// module.exports = (on, config) => {
// // `on` is used to hook into various events Cypress emits
// // `config` is the resolved Cypress config
// }
module.exports = (on, config) => { module.exports = (on, config) => {
on('before:browser:launch', (browser, launchOptions) => { on('before:browser:launch', (browser, launchOptions) => {
if (browser.name === 'chrome') { if (browser.name === 'chrome') {
@@ -77,5 +19,27 @@ module.exports = (on, config) => {
config.env.apiBaseUrl = config.env.REMOTE_API_URL config.env.apiBaseUrl = config.env.REMOTE_API_URL
} }
return config // <-- critical, must return config // Task to set abort flag
on('task', {
setAbortFlag() {
fs.writeFileSync(ABORT_FLAG_PATH, 'ABORTED')
return null
},
checkAbortFlag() {
return fs.existsSync(ABORT_FLAG_PATH)
},
clearAbortFlag() {
if (fs.existsSync(ABORT_FLAG_PATH)) {
fs.unlinkSync(ABORT_FLAG_PATH)
}
return null
}
})
// Clean up abort flag at start of run
if (fs.existsSync(ABORT_FLAG_PATH)) {
fs.unlinkSync(ABORT_FLAG_PATH)
}
return config
} }

View File

@@ -1,24 +1,15 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************
// Import commands.js using ES2015 syntax: // Import commands.js using ES2015 syntax:
import "./commands"; import "./commands";
// Alternatively you can use CommonJS syntax:
// require('./commands')
//unique test run ID for all tests //unique test run ID for all tests
Cypress.config("cyid", `cy${new Date().getTime()}`); Cypress.config("cyid", `cy${new Date().getTime()}`);
// Global guard: halt all tests if abort flag exists
beforeEach(function () {
cy.task("checkAbortFlag").then(shouldAbort => {
if (shouldAbort) {
Cypress.runner.stop();
this.skip();
}
});
});

View File

@@ -1,26 +1,45 @@
// Basic smoke test, visit every form to ensure they load // Basic smoke test, visit every form to ensure they load
describe("SMOKE SETUP", () => { describe("SMOKE SETUP", () => {
before(() => { before(() => {
cy.request({ cy.request({
url: `${Cypress.env("apiBaseUrl")}version`, url: `${Cypress.env("apiBaseUrl")}auth`,
method: "GET" method: "POST",
}).then((resp) => { body: {
const serverVersion = resp.body.data.version login: Cypress.env("admin").login,
if (serverVersion !== "8.0.0") { password: Cypress.env("admin").password
Cypress.env("ABORT_RUN", true)
throw new Error(`Version mismatch: expected 8.0.0 but got ${serverVersion}`)
} }
}) })
}) .its("body")
.then((res) => {
cy.request({
method: "GET",
url: `${Cypress.env("apiBaseUrl")}server-info`,
auth: { bearer: res.data.token }
}).then((resp) => {
const raw = resp.body.data.serverVersion
const match = raw.match(/(\d+\.\d+\.\d+)/)
after(() => { if (!match) {
if (Cypress.env("ABORT_RUN")) { cy.task('setAbortFlag').then(() => {
Cypress.runner.stop() throw new Error(`Could not parse version from: "${raw}"`)
} })
}) return // prevent further execution
}
const version = match[1]
const expected = Cypress.env("expectedServerVersion")
if (version !== expected) {
cy.task('setAbortFlag').then(() => {
throw new Error(`❌ Version mismatch: server is ${version}, expected ${expected}. ABORTING ALL TESTS.`)
})
return // prevent further execution
}
cy.log(`✓ Server version confirmed: ${version}`)
})
})
})
it("Generates test data without issue", () => { it("Generates test data without issue", () => {
cy.request({ cy.request({
@@ -32,7 +51,7 @@ describe("SMOKE SETUP", () => {
} }
}) })
.its("body") .its("body")
.then((res) => { .then(res => {
cy.request({ cy.request({
method: "POST", method: "POST",
url: `${Cypress.env("apiBaseUrl")}license/permanently-erase-all-data`, url: `${Cypress.env("apiBaseUrl")}license/permanently-erase-all-data`,
@@ -57,7 +76,7 @@ describe("SMOKE SETUP", () => {
} }
}) })
.its("body") .its("body")
.then((resjob) => { .then(resjob => {
cy.log(`resjob is: ${JSON.stringify(resjob)}`); cy.log(`resjob is: ${JSON.stringify(resjob)}`);
// expect(resjob.body).to.have.property('jobId'); // expect(resjob.body).to.have.property('jobId');
confirmJobDone(resjob.jobId, res.data.token); confirmJobDone(resjob.jobId, res.data.token);
@@ -74,7 +93,7 @@ function confirmJobDone(jobId, authToken) {
auth: { auth: {
bearer: authToken bearer: authToken
} }
}).then((resp) => { }).then(resp => {
//3 means job done //3 means job done
if (resp.body.data == 3) return; if (resp.body.data == 3) return;
// else recurse // else recurse
@@ -83,8 +102,6 @@ function confirmJobDone(jobId, authToken) {
}); });
} }
//=============================================== //===============================================
// describe("SMOKE SETUP", () => { // describe("SMOKE SETUP", () => {
// it("Generates test data without issue", () => { // it("Generates test data without issue", () => {