Files
PaperClipAI/tests/runner-e2e/product-journeys/task-dependency-resume.test.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

287 lines
21 KiB
TypeScript

import { mkdir, mkdtemp, readFile, rm } from "node:fs/promises";
import os from "node:os";
import path from "node:path";
import { afterEach, describe, expect, it, vi } from "vitest";
import { JourneyError, type JourneyContext, type JourneyEvidence, type TargetSession } from "./types.js";
import { dependencyEvidenceFixture } from "./task-dependency-resume-fixture.js";
import * as observedReader from "./observation-read.js";
const controls = vi.hoisted(() => ({ create: vi.fn() }));
vi.mock("../user-actions.js", () => ({ createTaskThroughUi: (...args: unknown[]) => controls.create(...args) }));
vi.mock("./task-document-flow.js", () => ({ openDocumentAuthoring: vi.fn(async () => {}) }));
vi.mock("@playwright/test", () => ({ expect: Object.assign((locator: any) => ({
async toBeVisible() { expect(await locator.isVisible()).toBe(true); },
async toBeInViewport() { expect(await locator.isVisible()).toBe(true); },
async toContainText(text: string) { expect(await locator.textContent()).toContain(text); },
}), { poll: (read: () => Promise<unknown>) => ({
async toBe(value: unknown) { expect(await read()).toBe(value); },
async toEqual(value: unknown) { expect(await read()).toEqual(value); },
}) }) }));
import { taskDependencyResume } from "./task-dependency-resume.js";
interface FixtureOptions { priorRuns?: number; unrelatedActivity?: number; ownedActivity?: number; agentActivity?: number; missingActivity?: boolean; activePrior?: boolean;
closedPanel?: "properties" | "toggle"; missingProperty?: boolean; missingStatusChoice?: boolean }
async function fixture(premature = false, options: FixtureOptions = {}) {
const directory = await mkdtemp(path.join(os.tmpdir(), "dependency-flow-"));
const f = dependencyEvidenceFixture(), s = f.scope;
const blocker = { ...f.created.blocker }, dependent = { ...f.created.dependent };
const actions: string[] = [], owned: any[] = [], writes: unknown[] = [], reads: string[] = [];
let completed = false, assigned = false, panelOpen = !options.closedPanel;
const reference = () => /review reference is ([a-f0-9]{32})/.exec(blocker.description)?.[1];
const output = () => JSON.stringify({ reference: reference(), blockerIdentifier: s.blockerIdentifier });
const runs = () => assigned && (completed || premature) ? [structuredClone(f.finished.dependentRuns[0]!)] : [];
const priorRuns = Array.from({ length: options.priorRuns ?? 0 }, (_, i) => ({ ...structuredClone(f.finished.agentRuns[0]!),
id: `prior-${i}`, nativeIssueId: `prior-task-${i}`, contextSnapshot: { issueId: `prior-task-${i}` },
startedAt: "2019-12-31T23:00:00Z", status: options.activePrior ? "running" : i % 2 ? "failed" : "succeeded" }));
const activity = (count: number, entityId: string, agentId?: string) => Array.from({ length: count }, (_, i) => ({
id: `${entityId}-activity-${i}`, companyId: s.companyId, entityType: "issue", entityId, agentId,
actorType: agentId ? "agent" : "user", actorId: agentId ?? s.userId, action: "issue.observed" }));
const taskDocument = () => ({ ...f.finished.document, body: output() });
const revision = () => ({ ...f.finished.revision, body: output() });
controls.create.mockImplementation(async (input: any) => {
await input.beforeDispatch?.();
const row = input.title.includes(" blocker ") ? blocker : dependent;
Object.assign(row, { title: input.title, description: input.prompt });
actions.push(`create:${row.id}`);
return { issueId: row.id, submittedAtMs: Date.now() };
});
const locator = (key: string): any => ({
key,
filter(value: any) {
if (key === '[data-slot="popover-content"]' && value?.has) {
return locator(options.missingStatusChoice ? "missing-status-choice" : value.has.key);
}
return this;
}, first() { return this; }, last() { return this; },
locator() { return this; },
getByRole(_role: string, options?: any) { return locator(options?.name ? String(options.name) : key); },
async isVisible() {
if (key.includes("data-property-row")) return panelOpen && !options.missingProperty;
if (key === "Toggle side panel") return !panelOpen && options.closedPanel === "toggle";
if (key.includes("Show properties")) return !panelOpen && options.closedPanel === "properties";
if (key === "Open a new tab" || key === "/^Properties/") return false;
return true;
},
async scrollIntoViewIfNeeded() { actions.push(`scroll:${key}`); },
async fill(value: string) { actions.push(`fill:${key}:${value}`); },
async click() {
actions.push(`click:${key}`);
if (key === "Toggle side panel" || key.includes("Show properties")) panelOpen = true;
if (key === "missing-status-choice") throw new Error("missing_status_choice");
if (key === "blocker-choice") dependent.blockedByIssueIds = [blocker.id];
if (key === "Blocked") dependent.status = "blocked";
if (key === "agent-choice") { assigned = true; dependent.assigneeAgentId = s.agentId; dependent.assigneeUserId = null; }
if (key === "Done") {
completed = true; blocker.status = "done"; blocker.completedAt = "2020-01-01T00:00:20.000Z";
dependent.status = "done";
}
},
async textContent() { return output(); },
});
const page: any = {
locator(selector: string) { return locator(selector); },
getByRole(_role: string, options?: any) {
if (_role === "button" && options?.exact && ["Blocked", "Done"].includes(options.name)) return locator("missing-status-choice");
const l = locator(options?.name ? String(options.name) : "buttons");
l.filter = (options: any) => options?.hasText === blocker.title ? locator("blocker-choice")
: options?.hasText === "Fixture agent" ? locator("agent-choice") : l;
return l;
},
getByPlaceholder(name: string) { return locator(name); },
getByTestId(name: string) { return locator(name); },
async goto(url: string) { actions.push(`goto:${url}`); }, async reload() { actions.push("reload"); },
};
const api: any = { origin: "https://qa.example.test", async get(route: string) {
reads.push(route);
if (route === `/api/issues/${s.blockerId}`) return structuredClone(blocker);
if (route === `/api/issues/${s.dependentId}`) return structuredClone(dependent);
if (route === `/api/issues/${s.blockerId}/runs`) return [];
if (route === `/api/issues/${s.dependentId}/runs`) return runs().map(r => ({ runId: r.id }));
if (route.includes("/heartbeat-runs?")) return [...runs(), ...structuredClone(priorRuns)];
if (route === "/api/heartbeat-runs/run") return runs()[0];
if (route === `/api/issues/${s.blockerId}/activity`) return completed ? structuredClone(f.reopened.activity) : [];
if (route === `/api/issues/${s.dependentId}/activity`) return activity(options.ownedActivity ?? 0, s.dependentId);
if (route === `/api/companies/${s.companyId}/activity?agentId=${s.agentId}&limit=500`) {
return options.missingActivity ? undefined : activity(options.agentActivity ?? 0, "prior-task", s.agentId);
}
if (route === `/api/companies/${s.companyId}/activity?limit=500`) return activity(options.unrelatedActivity ?? 0, "unrelated-task").slice(0, 500);
if (route === `/api/issues/${s.dependentId}/documents`) return completed ? [taskDocument()] : [];
if (route.endsWith("/documents/dependency-proof")) return taskDocument();
if (route.endsWith("/revisions/revision")) return revision();
throw new Error(`unexpected_read:${route}`);
}, async post(...args: unknown[]) { writes.push(args); throw new Error("unexpected_mutation"); },
async patch(...args: unknown[]) { writes.push(args); throw new Error("unexpected_mutation"); } };
const context = { page, api, company: { id: s.companyId, issuePrefix: "QA" }, user: { id: s.userId }, environmentId: s.environmentId,
capabilities: ["company", "board-user", "task-write", "agent"], agent: { id: s.agentId, name: "Fixture agent", provider: s.provider, model: s.model, runtimeMode: "native" } } as JourneyContext;
const session = { own: vi.fn(async resource => { owned.push(resource); }) } as unknown as TargetSession;
const evidence = { checks: [] } as unknown as JourneyEvidence;
return { directory, context, session, evidence, actions, owned, writes, reads };
}
afterEach(() => { vi.useRealTimers(); controls.create.mockReset(); });
describe("dependency browser flow orchestration", () => {
const evidenceFiles = ["task-dependency-observations.json", "observation-read-failures.json"] as const;
const writerFaults = ["observations", "reads", "both"] as const;
const obstructWriters = async (directory: string, fault: typeof writerFaults[number]) => {
const names = fault === "both" ? [...evidenceFiles] : [evidenceFiles[fault === "observations" ? 0 : 1]];
await Promise.all(names.map(name => mkdir(path.join(directory, name))));
return names;
};
it.each(writerFaults.flatMap(fault => (["unsupported", "failed"] as const).map(outcome => [fault, outcome] as const)))(
"preserves the original %s writer failure outcome %s and attempts both evidence files", async (fault, outcome) => {
const f = await fixture(), blocked = await obstructWriters(f.directory, fault);
const logging = vi.spyOn(console, "error").mockImplementation(() => {});
const original = Object.freeze(new JourneyError("failed", "dependency_observation_control_failed"));
if (outcome === "unsupported") f.context.agent!.provider = "";
else vi.spyOn(f.context.api, "get").mockRejectedValue(original);
try {
const operation = taskDependencyResume(f.context, f.session, "journey-123-abcdef01", f.evidence,
{ deadlineAt: Date.now() + 60_000, directory: f.directory });
if (outcome === "unsupported") await expect(operation).rejects.toMatchObject({ outcome, code: "dependency_execution_identity_unavailable" });
else await expect(operation).rejects.toBe(original);
for (const name of evidenceFiles.filter(name => !blocked.includes(name))) {
expect(JSON.parse(await readFile(path.join(f.directory, name), "utf8"))).toBeTypeOf("object");
}
expect(logging).toHaveBeenCalledWith("dependency_evidence_preservation_failed", blocked);
expect(JSON.stringify(logging.mock.calls)).not.toContain(f.directory);
expect(f.actions).toEqual([]); expect(f.owned).toEqual([]); expect(f.writes).toEqual([]);
} finally { logging.mockRestore(); await rm(f.directory, { recursive: true, force: true }); }
});
it.each(["unsupported", "failed"] as const)("awaits the other evidence file when the read writer throws synchronously after %s", async outcome => {
const f = await fixture(), createReader = observedReader.createObservedReader;
const original = Object.freeze(new JourneyError("failed", "dependency_observation_control_failed"));
const failingWrite = vi.fn(() => { throw new Error("private writer diagnostic"); });
const reader = vi.spyOn(observedReader, "createObservedReader").mockImplementation((...args) => ({
...createReader(...args), preserve: failingWrite,
}));
const logging = vi.spyOn(console, "error").mockImplementation(() => {});
if (outcome === "unsupported") f.context.agent!.model = "";
else vi.spyOn(f.context.api, "get").mockRejectedValue(original);
try {
const operation = taskDependencyResume(f.context, f.session, "journey-123-abcdef01", f.evidence,
{ deadlineAt: Date.now() + 60_000, directory: f.directory });
if (outcome === "unsupported") await expect(operation).rejects.toMatchObject({ outcome, code: "dependency_execution_identity_unavailable" });
else await expect(operation).rejects.toBe(original);
expect(failingWrite).toHaveBeenCalledOnce();
expect(JSON.parse(await readFile(path.join(f.directory, "task-dependency-observations.json"), "utf8"))).toHaveProperty("stage",
outcome === "unsupported" ? "prerequisites" : "observe_starting_runs");
expect(logging).toHaveBeenCalledWith("dependency_evidence_preservation_failed", ["observation-read-failures.json"]);
expect(JSON.stringify(logging.mock.calls)).not.toContain("private writer diagnostic");
} finally { logging.mockRestore(); reader.mockRestore(); await rm(f.directory, { recursive: true, force: true }); }
});
it.each(writerFaults)("fails a successful journey when its %s evidence writer fails", async fault => {
const f = await fixture(), blocked = await obstructWriters(f.directory, fault);
const logging = vi.spyOn(console, "error").mockImplementation(() => {});
vi.useFakeTimers(); vi.setSystemTime(new Date("2020-01-01T00:00:00Z"));
try {
const rejection = expect(taskDependencyResume(f.context, f.session, "journey-123-abcdef01", f.evidence,
{ deadlineAt: Date.now() + 60_000, directory: f.directory })).rejects.toMatchObject({
outcome: "failed", code: "dependency_evidence_preservation_failed",
});
await vi.advanceTimersByTimeAsync(11_000); await rejection;
expect(f.evidence.checks).toHaveLength(8); expect(f.evidence.checks.every(check => check.passed)).toBe(true);
expect(logging).toHaveBeenCalledWith("dependency_evidence_preservation_failed", blocked);
for (const name of evidenceFiles.filter(name => !blocked.includes(name))) {
expect(JSON.parse(await readFile(path.join(f.directory, name), "utf8"))).toBeTypeOf("object");
}
expect(f.writes).toEqual([]);
} finally { logging.mockRestore(); await rm(f.directory, { recursive: true, force: true }); }
});
it.each((["provider", "model"] as const).flatMap(field => [
[field, "missing", undefined], [field, "null", null], [field, "empty", ""], [field, "blank", " \t "],
] as const))("rejects a %s identity that is %s before observation or task work", async (field, _kind, value) => {
const f = await fixture();
Object.assign(f.context.agent!, { [field]: value });
const get = vi.spyOn(f.context.api, "get").mockRejectedValue(new Error("preflight_read_attempted"));
try {
await expect(taskDependencyResume(f.context, f.session, "journey-123-abcdef01", f.evidence,
{ deadlineAt: Date.now() + 60_000, directory: f.directory })).rejects.toMatchObject({
outcome: "unsupported", code: "dependency_execution_identity_unavailable",
});
expect(get).not.toHaveBeenCalled(); expect(controls.create).not.toHaveBeenCalled();
expect(f.actions).toEqual([]); expect(f.owned).toEqual([]); expect(f.writes).toEqual([]);
expect(f.evidence.checks).toEqual([]);
expect(JSON.parse(await readFile(path.join(f.directory, "task-dependency-observations.json"), "utf8"))).toHaveProperty("stage", "prerequisites");
expect(JSON.parse(await readFile(path.join(f.directory, "observation-read-failures.json"), "utf8"))).toEqual({ failures: [] });
} finally { await rm(f.directory, { recursive: true, force: true }); }
});
it.each([
["empty history", {}],
["completed earlier campaign runs", { priorRuns: 3 }],
["more than 100 earlier campaign runs", { priorRuns: 150 }],
["more than 500 unrelated company events", { unrelatedActivity: 800 }],
["more than 500 owned task events", { ownedActivity: 600 }],
["prior agent events", { priorRuns: 2, agentActivity: 300 }],
] as const)("uses browser actions with %s and never writes output through API observations", async (_name, options) => {
const f = await fixture(false, options); vi.useFakeTimers(); vi.setSystemTime(new Date("2020-01-01T00:00:00Z"));
try {
const operation = taskDependencyResume(f.context, f.session, "journey-123-abcdef01", f.evidence,
{ deadlineAt: Date.now() + 60_000, directory: f.directory });
await vi.advanceTimersByTimeAsync(11_000); await operation;
expect(f.evidence.checks).toHaveLength(8); expect(f.evidence.checks.every(check => check.passed)).toBe(true);
expect(f.writes).toEqual([]);
expect(f.actions.indexOf("click:Blocked")).toBeLessThan(f.actions.indexOf("click:agent-choice"));
expect(f.actions.indexOf("click:agent-choice")).toBeLessThan(f.actions.indexOf("click:Done"));
expect(f.owned).toEqual(expect.arrayContaining([
expect.objectContaining({ kind: "issue", id: "blocker", journeyId: "task-dependency-resume" }),
expect.objectContaining({ kind: "issue", id: "dependent", journeyId: "task-dependency-resume" }),
]));
const saved = JSON.parse(await readFile(path.join(f.directory, "task-dependency-observations.json"), "utf8"));
expect(saved.stage).toBe("complete"); expect(saved.scope.prompt).not.toContain(saved.scope.reference);
expect(saved.waiting.at(-1).observedAt - saved.waiting[0].observedAt).toBeGreaterThanOrEqual(10_000);
expect(saved.startingAgentRuns).toHaveLength("priorRuns" in options ? options.priorRuns : 0);
expect(saved.reopened.agentRuns).toHaveLength(saved.startingAgentRuns.length + 1);
expect(f.reads.some(route => route.startsWith("/api/heartbeat-runs/prior-"))).toBe(false);
expect(f.reads).toContain("/api/issues/blocker/activity"); expect(f.reads).toContain("/api/issues/dependent/activity");
expect(f.reads).not.toContain("/api/companies/company/activity?limit=500");
} finally { await rm(f.directory, { recursive: true, force: true }); }
});
it.each(["properties", "toggle"] as const)("opens a closed properties pane through its %s control before linking", async closedPanel => {
const f = await fixture(false, { closedPanel }); vi.useFakeTimers(); vi.setSystemTime(new Date("2020-01-01T00:00:00Z"));
try {
const operation = taskDependencyResume(f.context, f.session, "journey-123-abcdef01", f.evidence,
{ deadlineAt: Date.now() + 60_000, directory: f.directory });
await vi.advanceTimersByTimeAsync(11_000); await operation;
expect(f.evidence.checks).toHaveLength(8); expect(f.evidence.checks.every(check => check.passed)).toBe(true);
const opener = f.actions.findIndex(action => action.startsWith("click:") && (action.includes("Show properties") || action === "click:Toggle side panel"));
expect(opener).toBeGreaterThanOrEqual(0); expect(opener).toBeLessThan(f.actions.indexOf("click:blocker-choice"));
expect(f.actions.some(action => action.startsWith("scroll:[data-property-row]:not([inert] *):not([aria-hidden=\"true\"] *)"))).toBe(true);
expect(f.writes).toEqual([]);
} finally { await rm(f.directory, { recursive: true, force: true }); }
});
it.each([
["missing property", { missingProperty: true }, "link_blocker"],
["missing matching status glyph", { missingStatusChoice: true }, "set_dependent_blocked"],
] as const)("fails closed on %s before agent assignment or blocker completion", async (_name, options, stage) => {
const f = await fixture(false, options);
try {
await expect(taskDependencyResume(f.context, f.session, "journey-123-abcdef01", f.evidence,
{ deadlineAt: Date.now() + 60_000, directory: f.directory })).rejects.toThrow();
expect(f.actions).not.toContain("click:agent-choice"); expect(f.actions).not.toContain("click:Done"); expect(f.writes).toEqual([]);
expect(JSON.parse(await readFile(path.join(f.directory, "task-dependency-observations.json"), "utf8"))).toHaveProperty("stage", stage);
} finally { await rm(f.directory, { recursive: true, force: true }); }
});
it.each([
["truncated agent activity", { agentActivity: 500 }, "dependency_activity_coverage_unavailable"],
["missing agent activity", { missingActivity: true }, "dependency_activity_coverage_unavailable"],
["active earlier work", { priorRuns: 1, activePrior: true }, "dependency_starting_agent_not_idle"],
["saturated run history", { priorRuns: 1000 }, "dependency_run_coverage_unavailable"],
] as const)("rejects %s before completing the blocker", async (_name, options, code) => {
const f = await fixture(false, options);
try {
await expect(taskDependencyResume(f.context, f.session, "journey-123-abcdef01", f.evidence,
{ deadlineAt: Date.now() + 60_000, directory: f.directory })).rejects.toThrow(code);
expect(f.actions).not.toContain("click:Done"); expect(f.writes).toEqual([]);
} finally { await rm(f.directory, { recursive: true, force: true }); }
});
it("premature work fails before the browser completes the blocker and preserves its observations", async () => {
const f = await fixture(true);
try {
await expect(taskDependencyResume(f.context, f.session, "journey-123-abcdef01", f.evidence,
{ deadlineAt: Date.now() + 60_000, directory: f.directory })).rejects.toThrow("dependency_ran_before_blocker_completed");
expect(f.actions).not.toContain("click:Done"); expect(f.writes).toEqual([]);
expect(JSON.parse(await readFile(path.join(f.directory, "task-dependency-observations.json"), "utf8"))).toHaveProperty("stage", "observe_blocked_wait");
expect(JSON.parse(await readFile(path.join(f.directory, "observation-read-failures.json"), "utf8"))).toEqual({ failures: [] });
} finally { await rm(f.directory, { recursive: true, force: true }); }
});
});