test(e2e): extract shared page test setup hooks
This commit is contained in:
@@ -1,18 +1,12 @@
|
|||||||
/// <reference types="cypress" />
|
/// <reference types="cypress" />
|
||||||
|
|
||||||
|
import { setupCommonPageTestHooks } from "../support/testHooks";
|
||||||
|
|
||||||
describe("/boards", () => {
|
describe("/boards", () => {
|
||||||
const apiBase = "**/api/v1";
|
const apiBase = "**/api/v1";
|
||||||
const email = "local-auth-user@example.com";
|
const email = "local-auth-user@example.com";
|
||||||
|
|
||||||
const originalDefaultCommandTimeout = Cypress.config("defaultCommandTimeout");
|
setupCommonPageTestHooks(apiBase);
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
Cypress.config("defaultCommandTimeout", 20_000);
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
Cypress.config("defaultCommandTimeout", originalDefaultCommandTimeout);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("auth negative: signed-out user is shown local auth login", () => {
|
it("auth negative: signed-out user is shown local auth login", () => {
|
||||||
cy.visit("/boards");
|
cy.visit("/boards");
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
/// <reference types="cypress" />
|
/// <reference types="cypress" />
|
||||||
|
|
||||||
|
import { setupCommonPageTestHooks } from "../support/testHooks";
|
||||||
|
|
||||||
// Clerk/Next.js occasionally triggers a hydration mismatch on auth routes in CI.
|
// Clerk/Next.js occasionally triggers a hydration mismatch on auth routes in CI.
|
||||||
// This is non-deterministic UI noise for these tests; ignore it so assertions can proceed.
|
// This is non-deterministic UI noise for these tests; ignore it so assertions can proceed.
|
||||||
Cypress.on("uncaught:exception", (err) => {
|
Cypress.on("uncaught:exception", (err) => {
|
||||||
@@ -13,25 +15,7 @@ describe("Global approvals", () => {
|
|||||||
const apiBase = "**/api/v1";
|
const apiBase = "**/api/v1";
|
||||||
const email = Cypress.env("CLERK_TEST_EMAIL") || "jane+clerk_test@example.com";
|
const email = Cypress.env("CLERK_TEST_EMAIL") || "jane+clerk_test@example.com";
|
||||||
|
|
||||||
const originalDefaultCommandTimeout = Cypress.config("defaultCommandTimeout");
|
setupCommonPageTestHooks(apiBase);
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
Cypress.config("defaultCommandTimeout", 20_000);
|
|
||||||
|
|
||||||
cy.intercept("GET", "**/healthz", {
|
|
||||||
statusCode: 200,
|
|
||||||
body: { ok: true },
|
|
||||||
}).as("healthz");
|
|
||||||
|
|
||||||
cy.intercept("GET", `${apiBase}/organizations/me/member*`, {
|
|
||||||
statusCode: 200,
|
|
||||||
body: { organization_id: "org1", role: "owner" },
|
|
||||||
}).as("orgMeMember");
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
Cypress.config("defaultCommandTimeout", originalDefaultCommandTimeout);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("can render a pending approval and approve it", () => {
|
it("can render a pending approval and approve it", () => {
|
||||||
const approval = {
|
const approval = {
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
/// <reference types="cypress" />
|
/// <reference types="cypress" />
|
||||||
|
|
||||||
|
import { setupCommonPageTestHooks } from "../support/testHooks";
|
||||||
|
|
||||||
// Clerk/Next.js occasionally triggers a hydration mismatch on auth routes in CI.
|
// Clerk/Next.js occasionally triggers a hydration mismatch on auth routes in CI.
|
||||||
// This is non-deterministic UI noise for these tests; ignore it so assertions can proceed.
|
// This is non-deterministic UI noise for these tests; ignore it so assertions can proceed.
|
||||||
Cypress.on("uncaught:exception", (err) => {
|
Cypress.on("uncaught:exception", (err) => {
|
||||||
@@ -13,25 +15,7 @@ describe("Skill packs", () => {
|
|||||||
const apiBase = "**/api/v1";
|
const apiBase = "**/api/v1";
|
||||||
const email = Cypress.env("CLERK_TEST_EMAIL") || "jane+clerk_test@example.com";
|
const email = Cypress.env("CLERK_TEST_EMAIL") || "jane+clerk_test@example.com";
|
||||||
|
|
||||||
const originalDefaultCommandTimeout = Cypress.config("defaultCommandTimeout");
|
setupCommonPageTestHooks(apiBase);
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
Cypress.config("defaultCommandTimeout", 20_000);
|
|
||||||
|
|
||||||
cy.intercept("GET", "**/healthz", {
|
|
||||||
statusCode: 200,
|
|
||||||
body: { ok: true },
|
|
||||||
}).as("healthz");
|
|
||||||
|
|
||||||
cy.intercept("GET", `${apiBase}/organizations/me/member*`, {
|
|
||||||
statusCode: 200,
|
|
||||||
body: { organization_id: "org1", role: "owner" },
|
|
||||||
}).as("orgMeMember");
|
|
||||||
});
|
|
||||||
|
|
||||||
afterEach(() => {
|
|
||||||
Cypress.config("defaultCommandTimeout", originalDefaultCommandTimeout);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("can sync a pack and surface warnings", () => {
|
it("can sync a pack and surface warnings", () => {
|
||||||
cy.intercept("GET", `${apiBase}/skills/packs*`, {
|
cy.intercept("GET", `${apiBase}/skills/packs*`, {
|
||||||
|
|||||||
32
frontend/cypress/support/testHooks.ts
Normal file
32
frontend/cypress/support/testHooks.ts
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
/// <reference types="cypress" />
|
||||||
|
|
||||||
|
type CommonPageTestHooksOptions = {
|
||||||
|
timeoutMs?: number;
|
||||||
|
orgMemberRole?: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
export function setupCommonPageTestHooks(
|
||||||
|
apiBase: string,
|
||||||
|
options: CommonPageTestHooksOptions = {},
|
||||||
|
): void {
|
||||||
|
const { timeoutMs = 20_000, orgMemberRole = "owner" } = options;
|
||||||
|
const originalDefaultCommandTimeout = Cypress.config("defaultCommandTimeout");
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
Cypress.config("defaultCommandTimeout", timeoutMs);
|
||||||
|
|
||||||
|
cy.intercept("GET", "**/healthz", {
|
||||||
|
statusCode: 200,
|
||||||
|
body: { ok: true },
|
||||||
|
}).as("healthz");
|
||||||
|
|
||||||
|
cy.intercept("GET", `${apiBase}/organizations/me/member*`, {
|
||||||
|
statusCode: 200,
|
||||||
|
body: { organization_id: "org1", role: orgMemberRole },
|
||||||
|
}).as("orgMeMember");
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
Cypress.config("defaultCommandTimeout", originalDefaultCommandTimeout);
|
||||||
|
});
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user