test(e2e): extract shared page test setup hooks

This commit is contained in:
Abhimanyu Saharan
2026-03-04 22:24:35 +05:30
parent d1b08b4777
commit 39f314cd8c
4 changed files with 41 additions and 47 deletions

View File

@@ -1,18 +1,12 @@
/// <reference types="cypress" />
import { setupCommonPageTestHooks } from "../support/testHooks";
describe("/boards", () => {
const apiBase = "**/api/v1";
const email = "local-auth-user@example.com";
const originalDefaultCommandTimeout = Cypress.config("defaultCommandTimeout");
beforeEach(() => {
Cypress.config("defaultCommandTimeout", 20_000);
});
afterEach(() => {
Cypress.config("defaultCommandTimeout", originalDefaultCommandTimeout);
});
setupCommonPageTestHooks(apiBase);
it("auth negative: signed-out user is shown local auth login", () => {
cy.visit("/boards");

View File

@@ -1,5 +1,7 @@
/// <reference types="cypress" />
import { setupCommonPageTestHooks } from "../support/testHooks";
// 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.
Cypress.on("uncaught:exception", (err) => {
@@ -13,25 +15,7 @@ describe("Global approvals", () => {
const apiBase = "**/api/v1";
const email = Cypress.env("CLERK_TEST_EMAIL") || "jane+clerk_test@example.com";
const originalDefaultCommandTimeout = Cypress.config("defaultCommandTimeout");
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);
});
setupCommonPageTestHooks(apiBase);
it("can render a pending approval and approve it", () => {
const approval = {

View File

@@ -1,5 +1,7 @@
/// <reference types="cypress" />
import { setupCommonPageTestHooks } from "../support/testHooks";
// 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.
Cypress.on("uncaught:exception", (err) => {
@@ -13,25 +15,7 @@ describe("Skill packs", () => {
const apiBase = "**/api/v1";
const email = Cypress.env("CLERK_TEST_EMAIL") || "jane+clerk_test@example.com";
const originalDefaultCommandTimeout = Cypress.config("defaultCommandTimeout");
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);
});
setupCommonPageTestHooks(apiBase);
it("can sync a pack and surface warnings", () => {
cy.intercept("GET", `${apiBase}/skills/packs*`, {

View 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);
});
}