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

@@ -2,18 +2,8 @@
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) => {
if (err.message?.includes("Hydration failed")) {
return false;
}
return true;
});
describe("Global approvals", () => {
const apiBase = "**/api/v1";
const email = Cypress.env("CLERK_TEST_EMAIL") || "jane+clerk_test@example.com";
setupCommonPageTestHooks(apiBase);
@@ -62,14 +52,20 @@ describe("Global approvals", () => {
body: { ...approval, status: "approved" },
}).as("approvalUpdate");
cy.visit("/sign-in");
cy.clerkLoaded();
cy.clerkSignIn({ strategy: "email_code", identifier: email });
cy.loginWithLocalAuth();
cy.visit("/approvals");
cy.waitForAppLoaded();
cy.wait(["@boardsList", "@approvalsList"], { timeout: 20_000 });
cy.wait(
[
"@usersMe",
"@organizationsList",
"@orgMeMember",
"@boardsList",
"@approvalsList",
],
{ timeout: 20_000 },
);
// Pending approval should be visible in the list.
cy.contains(/unapproved tasks/i).should("be.visible");

View File

@@ -2,18 +2,8 @@
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) => {
if (err.message?.includes("Hydration failed")) {
return false;
}
return true;
});
describe("Skill packs", () => {
const apiBase = "**/api/v1";
const email = Cypress.env("CLERK_TEST_EMAIL") || "jane+clerk_test@example.com";
setupCommonPageTestHooks(apiBase);
@@ -41,14 +31,13 @@ describe("Skill packs", () => {
},
}).as("packSync");
cy.visit("/sign-in");
cy.clerkLoaded();
cy.clerkSignIn({ strategy: "email_code", identifier: email });
cy.loginWithLocalAuth();
cy.visit("/skills/packs");
cy.waitForAppLoaded();
cy.wait("@packsList", { timeout: 20_000 });
cy.wait(["@usersMe", "@organizationsList", "@orgMeMember", "@packsList"], {
timeout: 20_000,
});
cy.contains(/openclaw skills/i).should("be.visible");
cy.contains("button", /^sync$/i).click();

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