Files
PaperClipAI/tests/runner-e2e/product-journeys/task-document-flow.ts
T
DottaandClaude Opus 5.5 92308f839d test(e2e): use the Coordinator task panel, inbox and plan controls in QA journeys (#21701)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - The QA Cloud product journeys check real user paths on a hosted test
stack
> - #19360 (2026-11-05) made the Coordinator workspace standard; its
task side panel starts with no tabs, and the header control opens a tab
chooser
> - The journeys were written for the classic panel, which opened
straight on Properties, and for older inbox and plan controls
> - On QA the smoke suite passed 8 of 24 journeys; 13 failures trace to
these out-of-date journey steps
> - This pull request updates the journeys to use the shipped
Coordinator controls the way a person does
> - The benefit is that the QA journeys test the product again instead
of failing on removed controls

## Linked Issues or Issue Description

**What happened?**
The QA staging smoke suite passed 8 of 24 journeys. 13 failures come
from journey steps that target the classic UI:
- Task side panel: the journeys click "Show properties" and expect
property rows. In Coordinator the click opens a tab chooser ("Open a
side panel tab"), and the user picks Properties or Artifacts. The
product's own e2e tests (`tests/e2e/artifact-tab-arrival.spec.ts`,
`artifact-uploads.spec.ts`, `disconnect-resilience.spec.ts`) and the
chat-catalog runtime cases already use the chooser.
- Inbox: desktop Coordinator inbox rows show unread state as a bold
title and have no per-row "Mark as read" button
(`doc/plans/2026-11-06-chat-contacts-pins.md`). The `r` shortcut marks
the hovered row read on the Mine view.
- Plan: the Coordinator Plan chip is named "Open Plan revision N in task
sidebar", not "Open Plan revision N".

**Steps to reproduce**
1. Run `pnpm test:e2e:runner -- --target-config <managed local config>`
with task-properties, task-edit-lifecycle, task-document-persistence and
project-task-context.
2. See 0/4 pass on master; each stops at the tab chooser.

**Expected behavior**
The journeys reach the same saved-state checks as before through the
shipped controls.

## What Changed

- New `product-journeys/task-panel.ts` helper: opens the side panel and
selects a tab (Properties or Artifacts) from the chooser, an open tab,
or the "Open a new tab" button. It waits for the page instead of a
single non-waiting visibility check, and does not close an already open
panel.
- task-properties, task-edit-lifecycle, task-dependency-resume,
project-task-context and task-document-persistence (and routine/agent
journeys that reuse `openDocumentAuthoring`) use the helper.
task-properties reopens the panel after reload before it checks "You".
- inbox-triage: when the row has no visible "Mark as read" button, open
the Mine view, blur search, hover the row and press `r` (as
`tests/e2e/coordinator-inbox-views.spec.ts` does).
- Plan journey: `planPreviewLabel()` accepts the optional " in task
sidebar" suffix and still requires the exact revision.
- No product code changes. An earlier revision of this PR changed "Show
properties" to select Properties; it is reverted because the product e2e
suite asserts the chooser is the intended design.

All saved-state assertions are unchanged: assignment, labels, status,
documents, read state and plan revision are still read back through the
API, so a broken feature still fails.

## Verification

- Real browser journeys on a managed local instance against unmodified
master UI: 4/4 pass (task-edit-lifecycle, task-properties,
task-document-persistence, project-task-context); 0/4 before.
- Inbox fallback checked by hand on a local instance: an unread task on
the Mine view became `isUnreadForMe=false` after blur + hover + `r`.
- `tests/runner-e2e` unit tests for product-journeys and plan-revision:
47 files, 1240 tests pass. The task-properties contract test now models
the chooser and asserts the opener and the Properties option are used
before assignment and after reload. New `planPreviewLabel` test covers
revision 12 vs 1 and a missing revision.
- QA Cloud rerun follows once the QA harness pin moves to a master
commit that contains this change.

## Risks

- Low risk: test code only. If the chooser changes again, the helper
fails visibly at the panel step.

## Model Used

- Claude Opus 5.5 (`claude-opus-5-5`) in Claude Code, with tool use and
code execution.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 03:08:23 +00:00

84 lines
5.8 KiB
TypeScript

import { expect } from "@playwright/test";
import { openTaskPanelTab } from "./task-panel.js";
import { taskDocumentHistoryPasses, taskDocumentMatches, type TaskDocumentExpectation, type TaskDocumentRevision, type TaskDocumentSnapshot } from "./task-document-evidence.js";
import { JourneyError, type JourneyContext, type JourneyEvidence, type TargetSession } from "./types.js";
export async function openDocumentAuthoring({ page }: JourneyContext) {
await openTaskPanelTab(page, "Artifacts", page.getByRole("button", { name: "New document", exact: true }));
}
export async function reopenTaskDocument(context: JourneyContext, issue: { title: string }) {
const { page, api, company } = context;
await page.goto(`${api.origin}/${company.issuePrefix}/issues?view=backlog&q=${encodeURIComponent(issue.title)}`);
await page.getByRole("link").filter({ hasText: issue.title }).first().click();
await page.reload();
await openDocumentAuthoring(context);
}
export async function taskDocumentPersistence(context: JourneyContext, _session: TargetSession, campaignId: string, evidence: JourneyEvidence) {
const { page, api, company, user } = context;
const issue = context.fixtures?.backlogTask;
if (!issue?.id || !issue.identifier) throw new JourneyError("blocked", "missing_prepared_backlog_task");
const route = `/api/issues/${issue.id}`;
const key = "qa-note";
const documentRoute = `${route}/documents/${key}`;
const original: TaskDocumentExpectation = { companyId: company.id, issueId: issue.id, userId: user.id, key,
title: `QA document ${campaignId}`, body: `Original task note for ${campaignId}.` };
const revised = { ...original, title: `${original.title} revised`, body: `Persisted document ${campaignId}: revised text survives a reload.` };
if ((await api.get<TaskDocumentSnapshot[]>(`${route}/documents`)).some(document => document.key === key)) {
throw new JourneyError("failed", "task_document_fixture_not_fresh");
}
await page.goto(`${api.origin}/${company.issuePrefix}/issues/${issue.identifier}`);
await openDocumentAuthoring(context);
await page.getByRole("button", { name: "New document", exact: true }).click();
const form = page.getByPlaceholder("Document key", { exact: true }).locator("..");
await page.getByPlaceholder("Document key", { exact: true }).fill(key);
await page.getByPlaceholder("Optional title", { exact: true }).fill(original.title);
const newEditor = form.locator('[contenteditable="true"], textarea').first();
await newEditor.fill(original.body);
await page.getByRole("button", { name: "Create document", exact: true }).click();
await expect.poll(async () => taskDocumentMatches((await api.get<TaskDocumentSnapshot[]>(`${route}/documents`)).find(document => document.key === key), original),
{ timeout: 30_000, intervals: [300, 600, 1000] }).toBe(true);
const initial = await api.get<TaskDocumentSnapshot>(documentRoute);
if (!taskDocumentMatches(initial, original)) throw new JourneyError("failed", "created_document_mismatch");
evidence.checks.push({ id: "browser-document-created", passed: true });
// Reopen the persisted document before editing; a locally retained draft cannot stand in for the saved body.
await page.reload();
await openDocumentAuthoring(context);
const document = page.locator(`#document-${key}`);
await expect(document.getByText(original.body, { exact: true })).toBeVisible();
await document.getByRole("button", { name: "Document actions", exact: true }).click();
await page.getByRole("menuitem", { name: "Edit document", exact: true }).click();
const editor = document.locator('[contenteditable="true"], textarea').first();
if (await editor.getAttribute("contenteditable") === "true") await expect(editor).toHaveText(original.body);
else await expect(editor).toHaveValue(original.body);
await document.getByPlaceholder("Optional title", { exact: true }).fill(revised.title);
await editor.fill(revised.body);
// Leaving the editor uses the production blur/autosave contract.
await page.getByRole("button", { name: "New document", exact: true }).focus();
await expect.poll(async () => taskDocumentMatches(await api.get<TaskDocumentSnapshot>(documentRoute), revised),
{ timeout: 30_000, intervals: [300, 600, 1000] }).toBe(true);
const current = await api.get<TaskDocumentSnapshot>(documentRoute);
const revisions = await api.get<TaskDocumentRevision[]>(`${documentRoute}/revisions`);
const originalRevision = await api.get<TaskDocumentRevision>(`${documentRoute}/revisions/${initial.latestRevisionId}`);
const currentRevision = await api.get<TaskDocumentRevision>(`${documentRoute}/revisions/${current.latestRevisionId}`);
if (!taskDocumentHistoryPasses({ initial, current, original, revised, revisions, originalRevision, currentRevision })) {
throw new JourneyError("failed", "task_document_revision_history_mismatch");
}
evidence.checks.push({ id: "document-revision-history-preserved", passed: true });
await reopenTaskDocument(context, issue);
await expect(document.getByText(revised.title, { exact: true })).toBeVisible();
await expect(document.getByText(revised.body, { exact: true })).toBeVisible();
const reopened = await api.get<TaskDocumentSnapshot>(documentRoute);
const savedIssue = await api.get<{ companyId: string; status: string }>(route);
if (!taskDocumentMatches(reopened, revised) || reopened.latestRevisionId !== current.latestRevisionId
|| reopened.latestRevisionNumber !== current.latestRevisionNumber) throw new JourneyError("failed", "task_document_reload_mismatch");
if (savedIssue.companyId !== company.id || savedIssue.status !== "backlog" || (await api.get<unknown[]>(`${route}/runs`)).length) {
throw new JourneyError("failed", "browser_only_journey_started_agent_work");
}
evidence.checks.push({ id: "document-reopened-after-reload", passed: true }, { id: "no-agent-work", passed: true });
}