test(e2e): update /activity feed stubs for new /api/v1/activity
This commit is contained in:
@@ -4,28 +4,47 @@ 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";
|
||||||
|
|
||||||
function stubSseEmpty(pathGlob: string, alias: string) {
|
const originalDefaultCommandTimeout = Cypress.config("defaultCommandTimeout");
|
||||||
cy.intercept("GET", pathGlob, {
|
|
||||||
statusCode: 200,
|
|
||||||
headers: {
|
|
||||||
"content-type": "text/event-stream",
|
|
||||||
},
|
|
||||||
body: "",
|
|
||||||
}).as(alias);
|
|
||||||
}
|
|
||||||
|
|
||||||
function assertSignedInAndLanded() {
|
beforeEach(() => {
|
||||||
cy.waitForAppLoaded();
|
// Clerk's Cypress helpers perform async work inside `cy.then()`.
|
||||||
cy.contains(/live feed/i).should("be.visible");
|
// CI can be slow enough that the default 4s command timeout flakes.
|
||||||
}
|
Cypress.config("defaultCommandTimeout", 20_000);
|
||||||
|
|
||||||
it("auth negative: signed-out user is redirected to sign-in", () => {
|
|
||||||
// SignedOutPanel runs in redirect mode on this page.
|
|
||||||
cy.visit("/activity");
|
|
||||||
cy.location("pathname", { timeout: 20_000 }).should("match", /\/sign-in/);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("happy path: renders feed items from the activity endpoint", () => {
|
afterEach(() => {
|
||||||
|
Cypress.config("defaultCommandTimeout", originalDefaultCommandTimeout);
|
||||||
|
});
|
||||||
|
|
||||||
|
function stubStreamsEmpty() {
|
||||||
|
// The activity page connects multiple SSE streams (tasks/approvals/agents/board memory).
|
||||||
|
// In E2E we keep them empty to avoid flake and keep assertions deterministic.
|
||||||
|
const emptySse = {
|
||||||
|
statusCode: 200,
|
||||||
|
headers: { "content-type": "text/event-stream" },
|
||||||
|
body: "",
|
||||||
|
};
|
||||||
|
|
||||||
|
cy.intercept("GET", `${apiBase}/boards/*/tasks/stream*`, emptySse).as(
|
||||||
|
"tasksStream",
|
||||||
|
);
|
||||||
|
cy.intercept("GET", `${apiBase}/boards/*/approvals/stream*`, emptySse).as(
|
||||||
|
"approvalsStream",
|
||||||
|
);
|
||||||
|
cy.intercept("GET", `${apiBase}/boards/*/memory/stream*`, emptySse).as(
|
||||||
|
"memoryStream",
|
||||||
|
);
|
||||||
|
cy.intercept("GET", `${apiBase}/agents/stream*`, emptySse).as("agentsStream");
|
||||||
|
}
|
||||||
|
|
||||||
|
function stubBoardBootstrap() {
|
||||||
|
// Some app bootstraps happen before we get to the /activity call.
|
||||||
|
// Keep these stable so the page always reaches the activity request.
|
||||||
|
cy.intercept("GET", `${apiBase}/organizations/me/member*`, {
|
||||||
|
statusCode: 200,
|
||||||
|
body: { organization_id: "org1", role: "owner" },
|
||||||
|
}).as("orgMeMember");
|
||||||
|
|
||||||
cy.intercept("GET", `${apiBase}/boards*`, {
|
cy.intercept("GET", `${apiBase}/boards*`, {
|
||||||
statusCode: 200,
|
statusCode: 200,
|
||||||
body: {
|
body: {
|
||||||
@@ -42,28 +61,42 @@ describe("/activity feed", () => {
|
|||||||
chat_messages: [],
|
chat_messages: [],
|
||||||
},
|
},
|
||||||
}).as("boardSnapshot");
|
}).as("boardSnapshot");
|
||||||
|
}
|
||||||
|
|
||||||
|
function assertSignedInAndLanded() {
|
||||||
|
cy.waitForAppLoaded();
|
||||||
|
cy.contains(/live feed/i).should("be.visible");
|
||||||
|
}
|
||||||
|
|
||||||
|
it("auth negative: signed-out user is redirected to sign-in", () => {
|
||||||
|
// SignedOutPanel runs in redirect mode on this page.
|
||||||
|
cy.visit("/activity");
|
||||||
|
cy.location("pathname", { timeout: 20_000 }).should("match", /\/sign-in/);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("happy path: renders task comment cards", () => {
|
||||||
|
stubBoardBootstrap();
|
||||||
|
|
||||||
cy.intercept("GET", `${apiBase}/activity*`, {
|
cy.intercept("GET", `${apiBase}/activity*`, {
|
||||||
statusCode: 200,
|
statusCode: 200,
|
||||||
body: {
|
body: {
|
||||||
items: [
|
items: [
|
||||||
{
|
{
|
||||||
id: "evt-1",
|
id: "e1",
|
||||||
created_at: "2026-02-07T00:00:00Z",
|
|
||||||
event_type: "task.comment",
|
event_type: "task.comment",
|
||||||
message: "Hello world",
|
message: "Hello world",
|
||||||
agent_id: null,
|
agent_id: null,
|
||||||
|
agent_name: "Kunal",
|
||||||
|
created_at: "2026-02-07T00:00:00Z",
|
||||||
task_id: "t1",
|
task_id: "t1",
|
||||||
|
task_title: "CI hardening",
|
||||||
|
agent_role: "QA 2",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
}).as("activityList");
|
}).as("activityList");
|
||||||
|
|
||||||
// Prevent SSE connections from hanging the test.
|
stubStreamsEmpty();
|
||||||
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");
|
|
||||||
|
|
||||||
cy.visit("/sign-in");
|
cy.visit("/sign-in");
|
||||||
cy.clerkLoaded();
|
cy.clerkLoaded();
|
||||||
@@ -72,22 +105,19 @@ describe("/activity feed", () => {
|
|||||||
cy.visit("/activity");
|
cy.visit("/activity");
|
||||||
assertSignedInAndLanded();
|
assertSignedInAndLanded();
|
||||||
|
|
||||||
cy.contains("CI hardening").should("be.visible");
|
cy.contains(/ci hardening/i).should("be.visible");
|
||||||
cy.contains("Hello world").should("be.visible");
|
cy.contains(/hello world/i).should("be.visible");
|
||||||
});
|
});
|
||||||
|
|
||||||
it("empty state: shows waiting message when no items", () => {
|
it("empty state: shows waiting message when no items", () => {
|
||||||
cy.intercept("GET", `${apiBase}/boards*`, {
|
stubBoardBootstrap();
|
||||||
statusCode: 200,
|
|
||||||
body: { items: [] },
|
|
||||||
}).as("boardsList");
|
|
||||||
|
|
||||||
cy.intercept("GET", `${apiBase}/activity*`, {
|
cy.intercept("GET", `${apiBase}/activity*`, {
|
||||||
statusCode: 200,
|
statusCode: 200,
|
||||||
body: { items: [] },
|
body: { items: [] },
|
||||||
}).as("activityList");
|
}).as("activityList");
|
||||||
|
|
||||||
stubSseEmpty(`${apiBase}/agents/stream*`, "agentsStream");
|
stubStreamsEmpty();
|
||||||
|
|
||||||
cy.visit("/sign-in");
|
cy.visit("/sign-in");
|
||||||
cy.clerkLoaded();
|
cy.clerkLoaded();
|
||||||
@@ -100,17 +130,14 @@ describe("/activity feed", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("error state: shows failure UI when API errors", () => {
|
it("error state: shows failure UI when API errors", () => {
|
||||||
cy.intercept("GET", `${apiBase}/boards*`, {
|
stubBoardBootstrap();
|
||||||
statusCode: 200,
|
|
||||||
body: { items: [] },
|
|
||||||
}).as("boardsList");
|
|
||||||
|
|
||||||
cy.intercept("GET", `${apiBase}/activity*`, {
|
cy.intercept("GET", `${apiBase}/activity*`, {
|
||||||
statusCode: 500,
|
statusCode: 500,
|
||||||
body: { detail: "boom" },
|
body: { detail: "boom" },
|
||||||
}).as("activityList");
|
}).as("activityList");
|
||||||
|
|
||||||
stubSseEmpty(`${apiBase}/agents/stream*`, "agentsStream");
|
stubStreamsEmpty();
|
||||||
|
|
||||||
cy.visit("/sign-in");
|
cy.visit("/sign-in");
|
||||||
cy.clerkLoaded();
|
cy.clerkLoaded();
|
||||||
@@ -119,6 +146,6 @@ describe("/activity feed", () => {
|
|||||||
cy.visit("/activity");
|
cy.visit("/activity");
|
||||||
assertSignedInAndLanded();
|
assertSignedInAndLanded();
|
||||||
|
|
||||||
cy.contains(/unable to load activity feed|boom/i).should("be.visible");
|
cy.contains(/unable to load activity feed/i).should("be.visible");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user