Merge pull request #115 from abhi1693/ci/fix-e2e-stability

test(e2e): stabilize activity feed + Clerk auth flake
This commit is contained in:
Abhimanyu Saharan
2026-02-12 19:28:57 +05:30
committed by GitHub
2 changed files with 61 additions and 45 deletions

View File

@@ -14,6 +14,13 @@ export default defineConfig({
baseUrl: "http://localhost:3000", baseUrl: "http://localhost:3000",
specPattern: "cypress/e2e/**/*.cy.{js,jsx,ts,tsx}", specPattern: "cypress/e2e/**/*.cy.{js,jsx,ts,tsx}",
supportFile: "cypress/support/e2e.ts", supportFile: "cypress/support/e2e.ts",
// Clerk helpers perform async work inside `cy.then()`. CI can be slow enough
// that Cypress' 4s default command timeout flakes.
defaultCommandTimeout: 20_000,
retries: {
runMode: 2,
openMode: 0,
},
setupNodeEvents(on, config) { setupNodeEvents(on, config) {
return clerkSetup({ config }); return clerkSetup({ config });
}, },

View File

@@ -4,30 +4,14 @@ describe("/activity feed", () => {
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"); function stubSseEmpty(pathGlob: string, alias: string) {
cy.intercept("GET", pathGlob, {
beforeEach(() => { statusCode: 200,
// Clerk's Cypress helpers perform async work inside `cy.then()`. headers: {
// CI can be slow enough that the default 4s command timeout flakes. "content-type": "text/event-stream",
Cypress.config("defaultCommandTimeout", 20_000);
});
afterEach(() => {
Cypress.config("defaultCommandTimeout", originalDefaultCommandTimeout);
});
function stubStreamEmpty() {
cy.intercept(
"GET",
`${apiBase}/activity/task-comments/stream*`,
{
statusCode: 200,
headers: {
"content-type": "text/event-stream",
},
body: "",
}, },
).as("activityStream"); body: "",
}).as(alias);
} }
function assertSignedInAndLanded() { function assertSignedInAndLanded() {
@@ -35,35 +19,52 @@ describe("/activity feed", () => {
cy.contains(/live feed/i).should("be.visible"); cy.contains(/live feed/i).should("be.visible");
} }
it("auth negative: signed-out user cannot access /activity", () => { it("auth negative: signed-out user is redirected to sign-in", () => {
// Story: signed-out user tries to visit /activity and is redirected to sign-in. // SignedOutPanel runs in redirect mode on this page.
cy.visit("/activity"); cy.visit("/activity");
cy.location("pathname", { timeout: 20_000 }).should("match", /\/sign-in/); cy.location("pathname", { timeout: 20_000 }).should("match", /\/sign-in/);
}); });
it("happy path: renders task comment cards", () => { it("happy path: renders feed items from the activity endpoint", () => {
cy.intercept("GET", `${apiBase}/activity/task-comments*`, { cy.intercept("GET", `${apiBase}/boards*`, {
statusCode: 200,
body: {
items: [{ id: "b1", name: "Testing", updated_at: "2026-02-07T00:00:00Z" }],
},
}).as("boardsList");
cy.intercept("GET", `${apiBase}/boards/b1/snapshot*`, {
statusCode: 200,
body: {
tasks: [{ id: "t1", title: "CI hardening" }],
agents: [],
approvals: [],
chat_messages: [],
},
}).as("boardSnapshot");
cy.intercept("GET", `${apiBase}/activity*`, {
statusCode: 200, statusCode: 200,
body: { body: {
items: [ items: [
{ {
id: "c1", id: "evt-1",
message: "Hello world",
agent_name: "Kunal",
agent_role: "QA 2",
board_id: "b1",
board_name: "Testing",
task_id: "t1",
task_title: "CI hardening",
created_at: "2026-02-07T00:00:00Z", created_at: "2026-02-07T00:00:00Z",
event_type: "task.comment",
message: "Hello world",
agent_id: null,
task_id: "t1",
}, },
], ],
}, },
}).as("activityList"); }).as("activityList");
stubStreamEmpty(); // Prevent SSE connections from hanging the test.
stubSseEmpty(`${apiBase}/boards/b1/tasks/stream*`, "tasksStream");
stubSseEmpty(`${apiBase}/boards/b1/approvals/stream*`, "approvalsStream");
stubSseEmpty(`${apiBase}/boards/b1/memory/stream*`, "memoryStream");
stubSseEmpty(`${apiBase}/agents/stream*`, "agentsStream");
// Story: user signs in, then visits /activity and sees the live feed.
cy.visit("/sign-in"); cy.visit("/sign-in");
cy.clerkLoaded(); cy.clerkLoaded();
cy.clerkSignIn({ strategy: "email_code", identifier: email }); cy.clerkSignIn({ strategy: "email_code", identifier: email });
@@ -76,14 +77,18 @@ describe("/activity feed", () => {
}); });
it("empty state: shows waiting message when no items", () => { it("empty state: shows waiting message when no items", () => {
cy.intercept("GET", `${apiBase}/activity/task-comments*`, { cy.intercept("GET", `${apiBase}/boards*`, {
statusCode: 200,
body: { items: [] },
}).as("boardsList");
cy.intercept("GET", `${apiBase}/activity*`, {
statusCode: 200, statusCode: 200,
body: { items: [] }, body: { items: [] },
}).as("activityList"); }).as("activityList");
stubStreamEmpty(); stubSseEmpty(`${apiBase}/agents/stream*`, "agentsStream");
// Story: user signs in, then visits /activity and sees an empty-state message.
cy.visit("/sign-in"); cy.visit("/sign-in");
cy.clerkLoaded(); cy.clerkLoaded();
cy.clerkSignIn({ strategy: "email_code", identifier: email }); cy.clerkSignIn({ strategy: "email_code", identifier: email });
@@ -91,18 +96,22 @@ describe("/activity feed", () => {
cy.visit("/activity"); cy.visit("/activity");
assertSignedInAndLanded(); assertSignedInAndLanded();
cy.contains(/waiting for new comments/i).should("be.visible"); cy.contains(/waiting for new activity/i).should("be.visible");
}); });
it("error state: shows failure UI when API errors", () => { it("error state: shows failure UI when API errors", () => {
cy.intercept("GET", `${apiBase}/activity/task-comments*`, { cy.intercept("GET", `${apiBase}/boards*`, {
statusCode: 200,
body: { items: [] },
}).as("boardsList");
cy.intercept("GET", `${apiBase}/activity*`, {
statusCode: 500, statusCode: 500,
body: { detail: "boom" }, body: { detail: "boom" },
}).as("activityList"); }).as("activityList");
stubStreamEmpty(); stubSseEmpty(`${apiBase}/agents/stream*`, "agentsStream");
// Story: user signs in, then visits /activity; API fails and user sees an error.
cy.visit("/sign-in"); cy.visit("/sign-in");
cy.clerkLoaded(); cy.clerkLoaded();
cy.clerkSignIn({ strategy: "email_code", identifier: email }); cy.clerkSignIn({ strategy: "email_code", identifier: email });
@@ -110,6 +119,6 @@ describe("/activity feed", () => {
cy.visit("/activity"); cy.visit("/activity");
assertSignedInAndLanded(); assertSignedInAndLanded();
cy.contains(/unable to load feed|boom/i).should("be.visible"); cy.contains(/unable to load activity feed|boom/i).should("be.visible");
}); });
}); });