feat: show queued prompt count badge in the task sidebar (#2354)
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
/**
|
||||
* Mobile parity for the sidebar queued prompt count badge.
|
||||
*
|
||||
* The mobile task-switcher sheet renders through the same TaskItem rows as
|
||||
* the desktop sidebar, so the mail badge must appear there too, without any
|
||||
* hover dependency. Lives in `mobile-*.spec.ts` so the `mobile-chrome`
|
||||
* Playwright project applies the mobile device automatically.
|
||||
*/
|
||||
import { test, expect } from "../../fixtures/test-base";
|
||||
import { SessionPage } from "../../pages/session-page";
|
||||
|
||||
test.describe("Mobile sidebar — queued prompt count", () => {
|
||||
test("shows the queued count badge in the task switcher sheet", async ({
|
||||
testPage,
|
||||
apiClient,
|
||||
seedData,
|
||||
}) => {
|
||||
const task = await apiClient.createTask(seedData.workspaceId, "Mobile Queued Badge Task", {
|
||||
workflow_id: seedData.workflowId,
|
||||
workflow_step_id: seedData.startStepId,
|
||||
repository_ids: [seedData.repositoryId],
|
||||
});
|
||||
const { session_id: sessionId } = await apiClient.seedTaskSession(task.id, {
|
||||
state: "IDLE",
|
||||
agentProfileId: seedData.agentProfileId,
|
||||
});
|
||||
await apiClient.queueMessage(task.id, sessionId, "Mobile queued prompt");
|
||||
|
||||
await testPage.goto(`/t/${task.id}`);
|
||||
const session = new SessionPage(testPage);
|
||||
await session.waitForLoad();
|
||||
|
||||
// Open the task switcher sheet from the mobile session top bar.
|
||||
await testPage.getByTestId("mobile-session-menu").click();
|
||||
const sheet = testPage.getByRole("dialog");
|
||||
await expect(sheet.getByText("Mobile Queued Badge Task")).toBeVisible({ timeout: 10_000 });
|
||||
|
||||
const badge = sheet
|
||||
.locator(`[data-testid='sortable-task-block'][data-task-id='${task.id}']`)
|
||||
.getByTestId("sidebar-task-queued-count");
|
||||
await expect(badge).toBeVisible({ timeout: 10_000 });
|
||||
await expect(badge).toHaveText("1");
|
||||
|
||||
await testPage.screenshot({
|
||||
path: "e2e/test-results/screenshots/sidebar-queued-count-mobile.png",
|
||||
fullPage: false,
|
||||
});
|
||||
|
||||
// No horizontal overflow from the badge on a phone viewport: the badge
|
||||
// stays within the sheet's horizontal bounds.
|
||||
const [sheetBox, badgeBox] = await Promise.all([sheet.boundingBox(), badge.boundingBox()]);
|
||||
expect(sheetBox).not.toBeNull();
|
||||
expect(badgeBox).not.toBeNull();
|
||||
expect(badgeBox!.x).toBeGreaterThanOrEqual(sheetBox!.x);
|
||||
expect(badgeBox!.x + badgeBox!.width).toBeLessThanOrEqual(sheetBox!.x + sheetBox!.width);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
* E2E for the sidebar queued prompt count badge.
|
||||
*
|
||||
* Every task and subtask row in the left task view shows a mail badge with
|
||||
* the number of prompts en-queued for that task. Covers:
|
||||
* - Badge appears with the right count after prompts are queued
|
||||
* - Badge disappears live (no reload) when the queue is cleared
|
||||
* - No badge on a task with an empty queue
|
||||
* - Subtask rows get the same badge treatment
|
||||
*/
|
||||
import { test, expect } from "../../fixtures/test-base";
|
||||
import { SessionPage } from "../../pages/session-page";
|
||||
|
||||
const stepOpts = (seedData: { workflowId: string; startStepId: string }) => ({
|
||||
workflow_id: seedData.workflowId,
|
||||
workflow_step_id: seedData.startStepId,
|
||||
});
|
||||
|
||||
function queuedBadge(page: SessionPage, taskId: string) {
|
||||
return page.sidebar
|
||||
.locator(`[data-testid='sortable-task-block'][data-task-id='${taskId}']`)
|
||||
.getByTestId("sidebar-task-queued-count");
|
||||
}
|
||||
|
||||
test.describe("Sidebar queued prompt count", () => {
|
||||
test("shows a mail badge with the queued count and clears live", async ({
|
||||
testPage,
|
||||
apiClient,
|
||||
seedData,
|
||||
}) => {
|
||||
const task = await apiClient.createTask(seedData.workspaceId, "Queued Badge Task", {
|
||||
...stepOpts(seedData),
|
||||
repository_ids: [seedData.repositoryId],
|
||||
});
|
||||
const { session_id: sessionId } = await apiClient.seedTaskSession(task.id, {
|
||||
state: "IDLE",
|
||||
agentProfileId: seedData.agentProfileId,
|
||||
});
|
||||
for (let index = 0; index < 3; index++) {
|
||||
await apiClient.queueMessage(task.id, sessionId, `Queued prompt ${index + 1}`);
|
||||
}
|
||||
|
||||
await testPage.goto(`/t/${task.id}`);
|
||||
const session = new SessionPage(testPage);
|
||||
await session.waitForLoad();
|
||||
await expect(session.sidebar).toBeVisible({ timeout: 10_000 });
|
||||
|
||||
const badge = queuedBadge(session, task.id);
|
||||
await expect(badge).toBeVisible({ timeout: 10_000 });
|
||||
await expect(badge).toHaveText("3");
|
||||
await expect(badge.locator("svg")).toHaveCount(1);
|
||||
|
||||
await testPage.screenshot({
|
||||
path: "e2e/test-results/screenshots/sidebar-queued-count-desktop.png",
|
||||
fullPage: false,
|
||||
});
|
||||
|
||||
// Clearing the queue must remove the badge without a reload (live path
|
||||
// through the status-summary broadcast).
|
||||
await apiClient.clearQueue(sessionId);
|
||||
await expect(badge).not.toBeVisible({ timeout: 10_000 });
|
||||
});
|
||||
|
||||
test("shows no badge for a task with an empty queue", async ({
|
||||
testPage,
|
||||
apiClient,
|
||||
seedData,
|
||||
}) => {
|
||||
const task = await apiClient.createTask(seedData.workspaceId, "Empty Queue Task", {
|
||||
...stepOpts(seedData),
|
||||
repository_ids: [seedData.repositoryId],
|
||||
});
|
||||
|
||||
await testPage.goto(`/t/${task.id}`);
|
||||
const session = new SessionPage(testPage);
|
||||
await session.waitForLoad();
|
||||
|
||||
await expect(session.sidebar.getByText("Empty Queue Task")).toBeVisible({ timeout: 10_000 });
|
||||
await expect(queuedBadge(session, task.id)).toHaveCount(0);
|
||||
});
|
||||
|
||||
test("shows the badge on a subtask row", async ({ testPage, apiClient, seedData }) => {
|
||||
const parent = await apiClient.createTask(seedData.workspaceId, "Badge Parent Task", {
|
||||
...stepOpts(seedData),
|
||||
repository_ids: [seedData.repositoryId],
|
||||
});
|
||||
const child = await apiClient.createTask(seedData.workspaceId, "Badge Child Task", {
|
||||
...stepOpts(seedData),
|
||||
parent_id: parent.id,
|
||||
});
|
||||
const { session_id: sessionId } = await apiClient.seedTaskSession(child.id, {
|
||||
state: "IDLE",
|
||||
agentProfileId: seedData.agentProfileId,
|
||||
});
|
||||
await apiClient.queueMessage(child.id, sessionId, "Subtask queued prompt");
|
||||
|
||||
await testPage.goto(`/t/${parent.id}`);
|
||||
const session = new SessionPage(testPage);
|
||||
await session.waitForLoad();
|
||||
|
||||
const badge = queuedBadge(session, child.id);
|
||||
await expect(badge).toBeVisible({ timeout: 10_000 });
|
||||
await expect(badge).toHaveText("1");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user