Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/origin/cypress-test-config…
Browse files Browse the repository at this point in the history
…' into cypress-test-config
  • Loading branch information
geodem127 committed Jan 10, 2025
2 parents 8818472 + 55bff8d commit 2d2ed9c
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 28 deletions.
13 changes: 6 additions & 7 deletions cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,21 @@ module.exports = defineConfig({
// You may want to clean this up later by importing these.
setupNodeEvents(on, config) {
on("before:browser:launch", (browser, launchOptions) => {
if (browser.name === "chrome" && browser.isHeadless) {
launchOptions.args.push("--headless=old");
}
// if (browser.name === "chrome" && browser.isHeadless) {
// launchOptions.args.push("--headless=old");
// }

return launchOptions;
});

return require("./cypress/plugins/index.js")(on, config);
},
browser: "electron",
baseUrl: "http://8-f48cf3a682-7fthvk.manager.dev.zesty.io:8080/",
specPattern: "cypress/e2e/**/*.{js,jsx,ts,tsx}",
testIsolation: false,
},
defaultCommandTimeout: 30_000,
responseTimeout: 60_000,
defaultCommandTimeout: 50_000,
responseTimeout: 90_000,
retries: 1,
experimentalMemoryManagement: true,
chromeWebSecurity: false,
});
38 changes: 19 additions & 19 deletions cypress/e2e/settings/workflows.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -492,25 +492,25 @@ Cypress.Commands.add("getStatusLabels", () => {
});
});

Cypress.Commands.add(
"apiRequest",
({ method = "GET", url = "", body = undefined }) => {
return cy.getCookie(Cypress.env("COOKIE_NAME")).then((cookie) => {
const token = cookie?.value;
return cy
.request({
url,
method,
headers: { authorization: `Bearer ${token}` },
...(body ? { body: body } : {}),
})
.then((response) => ({
status: response?.isOkStatusCode ? "success" : "error",
data: response?.body?.data,
}));
});
}
);
// Cypress.Commands.add(
// "apiRequest",
// ({ method = "GET", url = "", body = undefined }) => {
// return cy.getCookie(Cypress.env("COOKIE_NAME")).then((cookie) => {
// const token = cookie?.value;
// return cy
// .request({
// url,
// method,
// headers: { authorization: `Bearer ${token}` },
// ...(body ? { body: body } : {}),
// })
// .then((response) => ({
// status: response?.isOkStatusCode ? "success" : "error",
// data: response?.body?.data,
// }));
// });
// }
// );

function parseStatusLabels(statusLabels) {
const { active, deactivated } = statusLabels?.reduce(
Expand Down
6 changes: 4 additions & 2 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ Cypress.Commands.add("login", () => {
.request({
url: `${Cypress.env("API_AUTH")}/login`,
method: "POST",
credentials: "include",
body: formBody,
})
.then(async (res) => {
const response = await new Response(res.body).json();
// We need the cookie value returned reset so it is unsecure and
// accessible by javascript
cy.setCookie(Cypress.env("COOKIE_NAME"), response.meta.token);
})
.then(() => {
return cy.get("body"); // Return a Chainable<JQuery<HTMLElement>>
});
});

Expand All @@ -30,7 +32,7 @@ Cypress.Commands.add("waitOn", (path, cb) => {
cy.blockAnnouncements();
cb();
cy.wait("@waitingOn", {
timeout: 30000,
timeout: 80_000,
});
});

Expand Down
35 changes: 35 additions & 0 deletions cypress/support/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import "./commands";

declare global {
namespace Cypress {
interface Chainable {
waitOn(path: string, cb: () => void): Chainable<JQuery<HTMLElement>>;
login(): Chainable<JQuery<HTMLElement>>;
getBySelector(
selector: string,
...args: any[]
): Chainable<JQuery<HTMLElement>>;
blockLock(): Chainable<JQuery<HTMLElement>>;
assertClipboardValue(value: string): Chainable<JQuery<HTMLElement>>;
blockAnnouncements(): Chainable<JQuery<HTMLElement>>;
apiRequest(params: {
url: string;
method?: "GET" | "POST" | "PUT" | "DELETE";
body?: any;
}): Chainable<{
status: "success" | "error";
data: any;
}>;
goToWorkflowsPage(): Chainable<void>;
cleanTestData(): Chainable<void>;
moreActionEdit(label: string): Chainable<void>;
moreActionDeactivate(label: string): Chainable<void>;
createTestData(): Chainable<void>;
getStatusLabels(): Chainable<any>;
parseStatusLabels(statusLabels: any): {
active: any[];
deactivated: any[];
};
}
}
}

0 comments on commit 2d2ed9c

Please sign in to comment.