test(e2e): align critical-flow specs with local auth CI

This commit is contained in:
Abhimanyu Saharan
2026-03-04 22:29:47 +05:30
parent 39f314cd8c
commit b6aff9c796
3 changed files with 62 additions and 32 deletions

View File

@@ -3,13 +3,26 @@
type CommonPageTestHooksOptions = {
timeoutMs?: number;
orgMemberRole?: string;
organizationId?: string;
organizationName?: string;
userId?: string;
userEmail?: string;
userName?: string;
};
export function setupCommonPageTestHooks(
apiBase: string,
options: CommonPageTestHooksOptions = {},
): void {
const { timeoutMs = 20_000, orgMemberRole = "owner" } = options;
const {
timeoutMs = 20_000,
orgMemberRole = "owner",
organizationId = "org1",
organizationName = "Testing Org",
userId = "u1",
userEmail = "local-auth-user@example.com",
userName = "Local User",
} = options;
const originalDefaultCommandTimeout = Cypress.config("defaultCommandTimeout");
beforeEach(() => {
@@ -20,9 +33,41 @@ export function setupCommonPageTestHooks(
body: { ok: true },
}).as("healthz");
cy.intercept("GET", `${apiBase}/users/me*`, {
statusCode: 200,
body: {
id: userId,
clerk_user_id: "local-auth-user",
email: userEmail,
name: userName,
preferred_name: userName,
timezone: "UTC",
},
}).as("usersMe");
cy.intercept("GET", `${apiBase}/organizations/me/list*`, {
statusCode: 200,
body: [
{
id: organizationId,
name: organizationName,
is_active: true,
role: orgMemberRole,
},
],
}).as("organizationsList");
cy.intercept("GET", `${apiBase}/organizations/me/member*`, {
statusCode: 200,
body: { organization_id: "org1", role: orgMemberRole },
body: {
id: "membership-1",
organization_id: organizationId,
user_id: userId,
role: orgMemberRole,
all_boards_read: true,
all_boards_write: true,
board_access: [],
},
}).as("orgMeMember");
});