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",
"pluginsFile": "plugins/index.js",
"env": {
"expectedServerVersion": "8.2.4",
"apiBaseUrl": "http://localhost:7575/api/v8.0/",
"REMOTE_BASE_URL": "https://devtest.onayanova.com/",
"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
=-=-=-=-=-=-=-=-=-=-=-=-
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
//sample users are inteded to be this easy to guess for testing and trial evaluation purposes so not changing it
// /**
// * @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
// 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;
const fs = require('fs')
const path = require('path')
// return launchOptions;
// }
// });
// };
const ABORT_FLAG_PATH = path.join(__dirname, '..', '.abort-run')
// 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) => {
on('before:browser:launch', (browser, launchOptions) => {
if (browser.name === 'chrome') {
@@ -77,5 +19,27 @@ module.exports = (on, config) => {
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";
// Alternatively you can use CommonJS syntax:
// require('./commands')
//unique test run ID for all tests
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,27 +1,46 @@
// Basic smoke test, visit every form to ensure they load
describe("SMOKE SETUP", () => {
before(() => {
cy.request({
url: `${Cypress.env("apiBaseUrl")}version`,
method: "GET"
}).then((resp) => {
const serverVersion = resp.body.data.version
if (serverVersion !== "8.0.0") {
Cypress.env("ABORT_RUN", true)
throw new Error(`Version mismatch: expected 8.0.0 but got ${serverVersion}`)
url: `${Cypress.env("apiBaseUrl")}auth`,
method: "POST",
body: {
login: Cypress.env("admin").login,
password: Cypress.env("admin").password
}
})
.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+)/)
if (!match) {
cy.task('setAbortFlag').then(() => {
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}`)
})
})
})
after(() => {
if (Cypress.env("ABORT_RUN")) {
Cypress.runner.stop()
}
})
it("Generates test data without issue", () => {
cy.request({
url: `${Cypress.env("apiBaseUrl")}auth`,
@@ -32,7 +51,7 @@ describe("SMOKE SETUP", () => {
}
})
.its("body")
.then((res) => {
.then(res => {
cy.request({
method: "POST",
url: `${Cypress.env("apiBaseUrl")}license/permanently-erase-all-data`,
@@ -57,7 +76,7 @@ describe("SMOKE SETUP", () => {
}
})
.its("body")
.then((resjob) => {
.then(resjob => {
cy.log(`resjob is: ${JSON.stringify(resjob)}`);
// expect(resjob.body).to.have.property('jobId');
confirmJobDone(resjob.jobId, res.data.token);
@@ -74,7 +93,7 @@ function confirmJobDone(jobId, authToken) {
auth: {
bearer: authToken
}
}).then((resp) => {
}).then(resp => {
//3 means job done
if (resp.body.data == 3) return;
// else recurse
@@ -83,8 +102,6 @@ function confirmJobDone(jobId, authToken) {
});
}
//===============================================
// describe("SMOKE SETUP", () => {
// it("Generates test data without issue", () => {