Files
DottaandPaperclip 823e90d8b2 fix(e2e): follow current routine form and schedule controls (#22821)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - The scheduled-routine journey checks creation, timed execution,
saved output and pause.
> - The routine page redesign changed its form and schedule controls.
> - The journey still used the old title placeholder, Responsible picker
and trigger editor.
> - It stopped before it could measure scheduling, even after the New
routine button fix.
> - This pull request follows the current controls and adds a
production-component browser regression.
> - The benefit is a usable schedule test with the same independent
behavior checks.

## Linked Issues or Issue Description

Refs #22182 and #22205. Related open #22340 changes other routine page
details; it does not update this journey.

**What happened?**
The scheduled-routine journey opens New routine, then times out on the
removed Routine title placeholder. The current form labels that field
Title. It has a Default agent picker and a separate Project picker. The
old journey also expects the removed Schedule trigger region and Enable
trigger control.

**Expected behavior**
The journey must use the current form, resume its owned schedule,
observe one attributed scheduled run, pause it, and check the next full
schedule boundary.

**Steps to reproduce**
Run the new credential-free browser control against the previous UI
actions. It renders the production RoutineEditDialog and fails waiting
for the old Routine title placeholder. The same control passes with this
repair.

**Paperclip version or commit**
Reproduced from master at d128e2db6f.
Published on current master after checking that all four existing
changed files were unchanged.

**Deployment mode**
Local Chromium production-component control, with no app server, model
or testing credentials. The observed staging failure supplied the
original report. This PR has no fresh full-stack staging pass.

## What Changed

- Extract the routine browser actions into a small journey-owned module.
- Fill Title and Instructions by accessible name. Open the agent and
project pickers explicitly.
- Use the schedule popover's Resume and Pause controls. Wait for each
exact trigger PATCH.
- Read created-task history on the base routine page. Keep configuration
version history separate.
- Add a Chromium control using the actual form, entity selectors and
routine page. It checks exact owner/project selection, missing-choice
refusal and the two owned trigger mutations. Unrelated display/editor
boundaries are stubbed.
- Keep the scheduler, native run, output, reload, duplicate-run,
deadline and cleanup oracles intact.
- Document the control and its limited acceptance scope.

## Verification

- Red: the production-component browser control timed out on
`getByPlaceholder("Routine title")` with the original actions.
- Green: `BROWSER_EXECUTABLE_PATH=/usr/bin/chromium node --import
/tmp/pap5819-tools/node_modules/tsx/dist/loader.mjs
tests/runner-e2e/product-journeys/routine-schedule-ui.browser.mjs`
passes.
- Focused Vitest: all 17 tests in routine-schedule-entry,
routine-schedule-evidence and routine-schedule-flow pass. The temporary
config selects only those suites.
- Local tools: Node 25.9.0, Vitest 5.0.3, Playwright 1.62.1 and system
Chromium. Dependencies were installed outside the checkout; no lockfile
changed.
- `pnpm verify` could not select tests: the managed Git storage guard
rejects `git ls-files`. This attempt has no verification verdict. The
first head passed selected CI. Those results do not qualify the revised
head; fresh CI and review remain pending.
- No new paid run, protected test-harness pin change or staging
deployment was made. Full scheduled acceptance remains separate.

- Review regression: the production route resolver rejects the old
/history task read; all 17 focused tests pass after the correction.
- Isolated dependency layout: the previous browser check cannot resolve
React without root React/React DOM. The revised check resolves UI-owned
peers and passes in that layout.

## Risks

- These actions target the current redesigned routine UI. An old UI
paired with this harness would not match the controls.
- The browser regression stubs unrelated display/editor boundaries. It
proves the real control actions, not a complete scheduler or
native-provider run.
- The fixture owns one schedule. Multiple matching schedule controls
cause an error rather than selecting an arbitrary trigger.

> For core feature work, check [`ROADMAP.md`](ROADMAP.md) first and
discuss it in `#dev` before opening the PR. Feature PRs that overlap
with planned core work may need to be redirected — check the roadmap
first. See `CONTRIBUTING.md`.

## Model Used

OpenAI GPT-6 in Codex, with tool use for source edits, Chromium, local
tests and GitHub API operations.

## 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

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-11-24 15:19:57 -06:00

71 lines
4.2 KiB
TypeScript

import { enableRoutineScheduleTrigger } from "./routine-schedule-ui.js";
import { mkdtemp, readFile, rm } from "node:fs/promises";
import os from "node:os";
import path from "node:path";
import { describe, expect, it, vi } from "vitest";
import { routineUiStep, withRoutineTriggerCleanup } from "./routine-schedule-flow.js";
import { JourneyError } from "./types.js";
describe("routine trigger cleanup failure reporting", () => {
it.each([false, true])("retains the original grade with a secondary disable failure (primary=%s)", async primary => {
const directory = await mkdtemp(path.join(os.tmpdir(), "routine-cleanup-"));
const original = new JourneyError("failed", "routine_result_attributed");
const patch = vi.fn().mockRejectedValue(new Error("private URL and form data"));
try {
const result = withRoutineTriggerCleanup({ api: { patch }, triggerRoute: "/api/routine-triggers/owned", directory,
run: async () => { if (primary) throw original; return "completed"; } });
if (primary) await expect(result).rejects.toBe(original);
else await expect(result).rejects.toMatchObject({ outcome: "failed", code: "routine_trigger_disable_failed" });
const receipt = JSON.parse(await readFile(path.join(directory, "scheduled-routine-cleanup-failure.json"), "utf8"));
expect(receipt).toMatchObject({ code: "routine_trigger_disable_failed", primaryFailurePreserved: primary });
expect(JSON.stringify(receipt)).not.toMatch(/private|form data/);
expect(patch).toHaveBeenCalledExactlyOnceWith("/api/routine-triggers/owned", { enabled: false });
} finally { await rm(directory, { recursive: true, force: true }); }
});
it("keeps the successful outcome when disabling the exact trigger succeeds", async () => {
const patch = vi.fn().mockResolvedValue({ enabled: false });
expect(await withRoutineTriggerCleanup({ api: { patch }, triggerRoute: "/api/routine-triggers/owned", directory: "/unused",
run: async () => "completed" })).toBe("completed");
expect(patch).toHaveBeenCalledExactlyOnceWith("/api/routine-triggers/owned", { enabled: false });
});
});
describe("routine UI failure evidence", () => {
it("retains a closed step code without browser messages or form values", async () => {
const error = await routineUiStep("fill_form", async () => {
throw new Error("Timeout at https://private.example/?token=secret with form value private-project");
}).catch(value => value);
expect(error).toBeInstanceOf(JourneyError);
expect(error).toMatchObject({ outcome: "failed", code: "routine_fill_form_failed", message: "routine_fill_form_failed" });
expect(JSON.stringify(error)).not.toMatch(/private|token|secret/);
});
it("keeps a semantic journey failure instead of replacing its evidence code", async () => {
const original = new JourneyError("failed", "routine_schedule_enable_failed");
await expect(routineUiStep("enable_trigger", async () => { throw original; })).rejects.toBe(original);
});
it("returns the original successful browser response without replaying the action", async () => {
let count = 0;
const response = { status: 201 };
expect(await routineUiStep("submit", async () => { count += 1; return response; })).toBe(response);
expect(count).toBe(1);
});
});
describe("schedule trigger controls", () => {
it("opens the schedule popover before one attributed resume action", async () => {
let expanded = false, clicks = 0, resolveResponse!: (value: any) => void;
const response = { status: () => 200 };
const pending = new Promise<any>(resolve => { resolveResponse = resolve; });
const page = { getByRole: (_role: string, options: { name: string | RegExp }) => ({ click: async () => {
if (options.name instanceof RegExp && options.name.test("Change schedule: Every minute")) { expanded = true; return; }
if (options.name !== "Resume" || !expanded) throw new Error("schedule control is not rendered");
clicks += 1;
resolveResponse(response);
} }), waitForResponse: () => pending } as unknown as Parameters<typeof enableRoutineScheduleTrigger>[0];
expect(await enableRoutineScheduleTrigger(page, "/api/routine-triggers/owned-trigger")).toBe(response);
expect(expanded).toBe(true);
expect(clicks).toBe(1);
});
});