From 946ad9f155709d0e9f2699ba68b127b537d0bb8a Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Sun, 15 Feb 2026 11:27:52 -0800 Subject: [PATCH] 4643 --- e2e/.vscode/tasks.json | 16 ++++ e2e/notes.txt | 72 ++++++++++++++ .../0-setup/000-generate-test-db.cy.js | 93 ++++++++++++++++--- .../regression/1-smoke/014-nav-menu.cy.js | 2 +- .../service-user/0100-workorder.cy.js | 2 +- 5 files changed, 169 insertions(+), 16 deletions(-) create mode 100644 e2e/.vscode/tasks.json diff --git a/e2e/.vscode/tasks.json b/e2e/.vscode/tasks.json new file mode 100644 index 0000000..693bd4d --- /dev/null +++ b/e2e/.vscode/tasks.json @@ -0,0 +1,16 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "type": "npm", + "script": "open", + "problemMatcher": [], + "label": "npm: open", + "detail": "./node_modules/.bin/cypress open", + "group": { + "kind": "build", + "isDefault": true + } + } + ] +} \ No newline at end of file diff --git a/e2e/notes.txt b/e2e/notes.txt index d9ddce3..5ca544f 100644 --- a/e2e/notes.txt +++ b/e2e/notes.txt @@ -1,4 +1,76 @@ +Password breach warning error mitigation: + +To suppress Chrome's "password exposed in breach" warning during Cypress tests with intentional weak test passwords, **disable Chrome's password leak detection features via browser launch flags**. This is the cleanest, most reliable solution for test environments. + +### ✅ Recommended Fix (Cypress Config) +Add this to your Cypress configuration to disable the relevant Chrome features: + +#### For Cypress v10+ (`cypress.config.js`): +```javascript +const { defineConfig } = require('cypress'); + +module.exports = defineConfig({ + e2e: { + setupNodeEvents(on, config) { + on('before:browser:launch', (browser, launchOptions) => { + if (browser.name === 'chrome') { + // Disable password breach warnings + related features + launchOptions.args.push( + '--disable-features=PasswordLeakDetection,PasswordManagerLeakDetection,PasswordCheck,InsecureCredentialsWarning' + ); + // Optional: Disable password manager entirely if warnings persist + // launchOptions.args.push('--disable-blink-features=PasswordManager'); + } + return launchOptions; + }); + }, + }, +}); +``` + +#### For Cypress ≤ v9 (`cypress/plugins/index.js`): +```javascript +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; + }); +}; +``` + +### 🔑 Why this works: +- `PasswordLeakDetection` / `PasswordManagerLeakDetection`: Blocks breach-checking logic +- `PasswordCheck`: Disables Chrome's "Password Checkup" feature +- `InsecureCredentialsWarning`: Suppresses "insecure password" UI warnings (critical for obvious passwords like "Accounting") +- Flags are **non-intrusive**—they don’t alter your app’s behavior or test logic +- Works in both headed and headless Chrome modes +- Zero maintenance vs. fragile DOM-interaction workarounds + +### ⚠️ Important Notes: +1. **Test passwords remain intentionally weak**—this solution *only* silences Chrome's UI warning. + 🔒 *Never use these passwords outside isolated test environments.* +2. If warnings persist: + - Update Chrome flags based on your Chrome version (check `chrome://version` → "Command Line") + - Temporarily add `--disable-blink-features=PasswordManager` (disables entire password manager; use only if tests don’t rely on autofill) +3. **Do NOT**: + - Try clicking away the warning in tests (flaky, slows tests, fragile selector) + - Disable Safe Browsing globally (`--safebrowsing-disable-auto-update`)—overly broad security risk + - Modify system Chrome settings (Cypress uses isolated profiles) + +### 💡 Pro Tip: +For future-proofing, consider generating **unique strong passwords per test run** (e.g., `Accounting_${Date.now()}`) and resetting them between tests. This avoids breach warnings *and* aligns with security best practices—but the flag solution above is perfect for your current constraint of fixed sample passwords. 😊 + + + + + + +=-=-=-=-=-=-=-=-=-=-=-=- From the olden times years ago: diff --git a/e2e/tests/regression/0-setup/000-generate-test-db.cy.js b/e2e/tests/regression/0-setup/000-generate-test-db.cy.js index 681ba89..70f53d5 100644 --- a/e2e/tests/regression/0-setup/000-generate-test-db.cy.js +++ b/e2e/tests/regression/0-setup/000-generate-test-db.cy.js @@ -14,22 +14,34 @@ describe("SMOKE SETUP", () => { .then((res) => { cy.request({ method: "POST", - url: `${Cypress.env("apiBaseUrl")}trial/seed`, + url: `${Cypress.env("apiBaseUrl")}license/permanently-erase-all-data`, auth: { bearer: res.data.token - }, ///small/-7/true - body: { - seedLevel: "small", - timeZoneOffset: -7, - e2e: true - } - }) - .its("body") - .then((resjob) => { - cy.log(`resjob is: ${JSON.stringify(resjob)}`); - // expect(resjob.body).to.have.property('jobId'); - confirmJobDone(resjob.jobId, res.data.token); - }); + }, + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify("I understand") + }).then(() => { + cy.request({ + method: "POST", + url: `${Cypress.env("apiBaseUrl")}trial/seed`, + auth: { + bearer: res.data.token + }, ///small/-7/true + body: { + seedLevel: "small", + timeZoneOffset: -7, + e2e: true + } + }) + .its("body") + .then((resjob) => { + cy.log(`resjob is: ${JSON.stringify(resjob)}`); + // expect(resjob.body).to.have.property('jobId'); + confirmJobDone(resjob.jobId, res.data.token); + }); + }); }); //----------------------------------------------------- }); @@ -49,3 +61,56 @@ function confirmJobDone(jobId, authToken) { confirmJobDone(jobId, authToken); }); } + + + +//=============================================== +// describe("SMOKE SETUP", () => { +// it("Generates test data without issue", () => { +// cy.request({ +// 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: "POST", +// url: `${Cypress.env("apiBaseUrl")}trial/seed`, +// auth: { +// bearer: res.data.token +// }, ///small/-7/true +// body: { +// seedLevel: "small", +// timeZoneOffset: -7, +// e2e: true +// } +// }) +// .its("body") +// .then((resjob) => { +// cy.log(`resjob is: ${JSON.stringify(resjob)}`); +// // expect(resjob.body).to.have.property('jobId'); +// confirmJobDone(resjob.jobId, res.data.token); +// }); +// }); +// //----------------------------------------------------- +// }); +// }); +// function confirmJobDone(jobId, authToken) { +// cy.request({ +// method: "GET", +// url: `${Cypress.env("apiBaseUrl")}job-operations/status/${jobId}`, +// auth: { +// bearer: authToken +// } +// }).then((resp) => { +// //3 means job done +// if (resp.body.data == 3) return; +// // else recurse +// cy.wait(1000); +// confirmJobDone(jobId, authToken); +// }); +// } diff --git a/e2e/tests/regression/1-smoke/014-nav-menu.cy.js b/e2e/tests/regression/1-smoke/014-nav-menu.cy.js index 6a5a3f5..d39d337 100644 --- a/e2e/tests/regression/1-smoke/014-nav-menu.cy.js +++ b/e2e/tests/regression/1-smoke/014-nav-menu.cy.js @@ -5,7 +5,7 @@ describe("SMOKE NAV", () => { cy.get("[data-cy=navicon]").click(); cy.get("[data-cy=home]").click(); - cy.get("[data-cy='nav/home-dashboard']").click(); + cy.get("[data-cy='nav/home-dashboard']").click();//26fail Timed out retrying after 5000ms: Expected to find element: [data-cy='nav/home-dashboard'], but never found it. cy.get("[data-cy=generalerror]").should("not.exist"); cy.get("[data-cy=navicon]").click(); diff --git a/e2e/tests/regression/service-user/0100-workorder.cy.js b/e2e/tests/regression/service-user/0100-workorder.cy.js index aeb1ca4..30a85dc 100644 --- a/e2e/tests/regression/service-user/0100-workorder.cy.js +++ b/e2e/tests/regression/service-user/0100-workorder.cy.js @@ -62,7 +62,7 @@ describe("Workorder creation", () => { cy.ayChooseGZPickList("projectId", "e2e"); cy.get("[data-cy='serviceDate:date']").type(dayjs().format("YYYY-MM-DD")); cy.get("[data-cy='serviceDate:time']").type(dayjs().format("HH:mm")); - cy.get("[data-cy=customerContactName]").type(`Jayne Smith`); + cy.get("[data-cy=customerContactName]").type(`Jayne Smith`);//26fail Timed out retrying after 5000ms: Expected to find element: [data-cy=customerContactName], but never found it. cy.get("[data-cy=customerReferenceNumber]").type( `cref-${Cypress.config("cyid")}` );