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

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