test(e2e): cover prompt-history recall end to end
A14 (API) and B15 (browser) make the feature verifiable against a real daemon,
a real headless nvim and a real `pi`.
- A14: the prompt A4 sent through `prompt.send` is in the plugin's archive
exactly once — the console → daemon → plugin → daemon → console round trip, and
the guard for "a web send is recorded at all"; `?limit=1` answers the newest
entry; a freshly added workspace with no instance answers
`{live:false, supported:false, entries:[]}` and its `/workspaces` row still
reports `instance: null`, which is the no-spawn rule a keystroke depends on
- B15: wipes the browser mirror, reloads, checks the console fetched
`/prompt-history`, walks ↑ back to the prompt B6 sent, walks ↓ out to the empty
draft, recalls with Ctrl+P from a mid-line caret, and asserts that browsing
never sends anything
- `docs/e2e.md` documents both (A0–A14, B1–B15)
Attribution done while landing this: with the plugin change stashed, A14 fails
(the capability is absent) while A5 reproduces identically and B1/B2/B3/B9/B13
fail the same way — pre-existing, not this feature. A5 is the coalesced
`text_delta` after `agent_settled` the suite already lists as a suspected
product bug; A11 is model-dependent and passed on the rerun.
This commit is contained in:
1 parent
b8f1fca5bd
commit
ce87799b61
3 files changed
+220
-7
No files matched your search
+96
-1
@@ -663,6 +663,9 @@ async function waitEnabled(page, selector, timeout = 30000) {
|
||||
|
||||
const COMPOSER_INPUT = '[data-testid="composer-input"]';
|
||||
|
||||
/** The short prompt B6 sends; B15 recalls it out of the plugin's archive. */
|
||||
const PONG_PROMPT = "Reply with exactly the word PONG and nothing else.";
|
||||
|
||||
/** `article.msg[data-entry-id]` projections (id/role come from the product test ids). */
|
||||
async function streamArticles(page) {
|
||||
return page.evaluate(() =>
|
||||
@@ -1606,7 +1609,7 @@ scenario("B6", "Prompt + streaming: PONG turn, one user entry, no .streaming aft
|
||||
await textarea.fill("");
|
||||
|
||||
// --- Enter sends, the assistant streams and settles ------------------
|
||||
const prompt = "Reply with exactly the word PONG and nothing else.";
|
||||
const prompt = PONG_PROMPT;
|
||||
await textarea.fill(prompt);
|
||||
await page.keyboard.press("Enter");
|
||||
const sent = await waitFor(async () => ctx.cmdRequests.find((request) => request.method === "prompt.send") ?? null, 15000);
|
||||
@@ -2657,6 +2660,98 @@ scenario("B14", "i18n + theme: language menu switches html[lang]/copy, theme seg
|
||||
await ctx.shot(page, "b14-theme-i18n");
|
||||
});
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* B15 — composer ↑/↓ recall from the plugin archive */
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
scenario("B15", "Composer recall: ↑ restores the prompt B6 sent, over the relay (mirror wiped)", async (ctx) => {
|
||||
const pong = state.pongSession;
|
||||
if (!pong) ctx.skip("B6 did not produce a session to reuse");
|
||||
const { page } = await ctx.openPage("paired");
|
||||
|
||||
ctx.check("chat page becomes usable", await openChat(page, pong.sessionId, pong.workspaceId), {
|
||||
expected: "textarea[aria-label='Message input'] enabled",
|
||||
observed: { composer: await composerState(page) },
|
||||
});
|
||||
|
||||
// Delete this browser's fallback mirror and reload, so recall can only work
|
||||
// from the relayed archive (docs/prompt-history.md: the plugin owns the text,
|
||||
// the mirror is only a fallback). A regression that dropped the relay would
|
||||
// leave nothing to recall here.
|
||||
await page.evaluate(() => localStorage.removeItem("pi2-prompt-history"));
|
||||
await page.reload({ waitUntil: "domcontentloaded" });
|
||||
ctx.check("chat page reloads usable", await openChat(page, pong.sessionId, pong.workspaceId), {
|
||||
expected: "composer enabled after reload",
|
||||
observed: { composer: await composerState(page) },
|
||||
});
|
||||
|
||||
const relayed = await waitFor(
|
||||
async () => ctx.apiCalls.find((call) => call.path.includes("/prompt-history") && call.status === 200) ?? null,
|
||||
20000,
|
||||
);
|
||||
ctx.check("the console reads GET /workspaces/:id/prompt-history", Boolean(relayed), {
|
||||
expected: "200 on /prompt-history",
|
||||
observed: ctx.apiCalls.map((call) => `${call.method} ${call.path} ${call.status}`).slice(-10),
|
||||
});
|
||||
|
||||
const textarea = page.locator(COMPOSER_INPUT);
|
||||
await textarea.click();
|
||||
await textarea.fill("");
|
||||
|
||||
// The archive is workspace-scoped, and later scenarios (B7's abort, B10's
|
||||
// attention turn) send into the *same* workspace — so the newest entry is not
|
||||
// necessarily B6's. Recall the newest first, then walk back until B6's prompt
|
||||
// shows up; both directions are part of the contract, so this asserts more
|
||||
// than a single-step recall would.
|
||||
await page.keyboard.press("ArrowUp");
|
||||
const newest = await waitFor(async () => (await textarea.inputValue()).trim() || null, 15000);
|
||||
ctx.check("↑ recalls the newest archived prompt", Boolean(newest), {
|
||||
expected: "a non-empty prompt",
|
||||
observed: newest,
|
||||
});
|
||||
|
||||
let reachedPong = newest === PONG_PROMPT;
|
||||
for (let step = 0; step < 30 && !reachedPong; step += 1) {
|
||||
// `↑` only recalls from the first line (nvim's rule), so park the caret
|
||||
// there before each step.
|
||||
await page.keyboard.press("Control+Home");
|
||||
await page.keyboard.press("ArrowUp");
|
||||
await sleep(120);
|
||||
reachedPong = (await textarea.inputValue()) === PONG_PROMPT;
|
||||
}
|
||||
ctx.check("↑ walks back to the prompt B6 sent (archive round trip)", reachedPong, {
|
||||
expected: PONG_PROMPT,
|
||||
observed: await textarea.inputValue(),
|
||||
});
|
||||
|
||||
// ↓ all the way back out: the stashed (empty) draft returns.
|
||||
let draftBack = false;
|
||||
for (let step = 0; step < 40 && !draftBack; step += 1) {
|
||||
await page.keyboard.press("ArrowDown");
|
||||
await sleep(120);
|
||||
draftBack = (await textarea.inputValue()) === "";
|
||||
}
|
||||
ctx.check("↓ walks back out to the empty draft", draftBack, {
|
||||
expected: "",
|
||||
observed: await textarea.inputValue(),
|
||||
});
|
||||
|
||||
// Ctrl+P is the readline alias: it recalls without moving the caret first.
|
||||
await textarea.fill("half typed");
|
||||
await page.keyboard.press("Control+p");
|
||||
const viaCtrlP = await waitFor(async () => (await textarea.inputValue()) || null, 10000);
|
||||
ctx.check("Ctrl+P recalls the newest entry from a mid-line caret", viaCtrlP === newest, {
|
||||
expected: newest,
|
||||
observed: viaCtrlP,
|
||||
});
|
||||
|
||||
ctx.check("recall never sent anything",
|
||||
!ctx.cmdRequests.some((request) => request.method === "prompt.send"),
|
||||
{ observed: ctx.cmdRequests.map((request) => request.method) },
|
||||
);
|
||||
await ctx.shot(page, "b15-composer-recall");
|
||||
});
|
||||
|
||||
/* ------------------------------------------------------------------ */
|
||||
/* C1 — responsive overflow */
|
||||
/* ------------------------------------------------------------------ */
|
||||
|
||||
Reference in new issue
Block a user