Merge branch 'main' into web-search
# Conflicts: # web/src/app.js # web/src/protocol.js # web/src/repository.js # web/styles.css # web/test/repository.test.mjs # web/test/ui-smoke.mjs
This commit is contained in:
@@ -144,3 +144,90 @@ test("search surfaces an explicit server error with the server's own text", asyn
|
||||
message: "unknown command: search",
|
||||
});
|
||||
});
|
||||
/** The run detail a run.action reply carries in these tests. */
|
||||
const RUN_DETAIL = { id: 440, status: "failed" };
|
||||
|
||||
test("decideRun sends exactly {type:'decide_run',run_id,option,feedback} and returns the run detail", async () => {
|
||||
const { repo, ws } = connected();
|
||||
ws.reply = (frame) => ({ id: frame.id, type: "run", run_detail: RUN_DETAIL });
|
||||
|
||||
const detail = await repo.decideRun(440, { stage: "review", option: "approve", feedback: " yes " });
|
||||
assert.deepEqual(lastFrame(ws), {
|
||||
type: "decide_run",
|
||||
run_id: 440,
|
||||
stage: "review",
|
||||
option: "approve",
|
||||
feedback: "yes",
|
||||
});
|
||||
assert.deepEqual(detail, RUN_DETAIL);
|
||||
});
|
||||
|
||||
test("decideRun omits a blank stage and blank feedback", async () => {
|
||||
const { repo, ws } = connected();
|
||||
ws.reply = (frame) => ({ id: frame.id, type: "run", run_detail: RUN_DETAIL });
|
||||
|
||||
await repo.decideRun(12, { stage: " ", option: "publish", feedback: " " });
|
||||
assert.deepEqual(lastFrame(ws), { type: "decide_run", run_id: 12, option: "publish" });
|
||||
});
|
||||
|
||||
test("cancelRun sends exactly {type:'cancel_run',run_id} and returns the run detail", async () => {
|
||||
const { repo, ws } = connected();
|
||||
ws.reply = (frame) => ({ id: frame.id, type: "run", run_detail: RUN_DETAIL });
|
||||
|
||||
const detail = await repo.cancelRun(440);
|
||||
assert.deepEqual(lastFrame(ws), { type: "cancel_run", run_id: 440 });
|
||||
assert.deepEqual(detail, RUN_DETAIL);
|
||||
});
|
||||
|
||||
test("retryRun always sends request_key and omits retry_mode for the default resume", async () => {
|
||||
const { repo, ws } = connected();
|
||||
ws.reply = (frame) => ({ id: frame.id, type: "run_started", run_detail: RUN_DETAIL });
|
||||
|
||||
await repo.retryRun(440, { requestKey: "key-1" });
|
||||
assert.deepEqual(lastFrame(ws), { type: "retry_run", run_id: 440, request_key: "key-1" });
|
||||
});
|
||||
|
||||
test("retryRun sends retry_mode only for an explicit restart", async () => {
|
||||
const { repo, ws } = connected();
|
||||
ws.reply = (frame) => ({ id: frame.id, type: "run_started", run_detail: RUN_DETAIL });
|
||||
|
||||
await repo.retryRun(440, { mode: "restart", requestKey: "key-2" });
|
||||
assert.deepEqual(lastFrame(ws), {
|
||||
type: "retry_run",
|
||||
run_id: 440,
|
||||
request_key: "key-2",
|
||||
retry_mode: "restart",
|
||||
});
|
||||
});
|
||||
|
||||
test("setRunTitle sends exactly {type:'set_run_title',run_id,title} and returns the run detail", async () => {
|
||||
const { repo, ws } = connected();
|
||||
ws.reply = (frame) => ({ id: frame.id, type: "run", run_detail: RUN_DETAIL });
|
||||
|
||||
const detail = await repo.setRunTitle(440, "New title");
|
||||
assert.deepEqual(lastFrame(ws), { type: "set_run_title", run_id: 440, title: "New title" });
|
||||
assert.deepEqual(detail, RUN_DETAIL);
|
||||
});
|
||||
|
||||
test("each run action rejects a server error envelope instead of returning a detail", async () => {
|
||||
const calls = [
|
||||
(repo) => () => repo.decideRun(440, { option: "approve" }),
|
||||
(repo) => () => repo.cancelRun(440),
|
||||
(repo) => () => repo.retryRun(440, { requestKey: "key-3" }),
|
||||
(repo) => () => repo.setRunTitle(440, ""),
|
||||
];
|
||||
for (const makeCall of calls) {
|
||||
const { repo, ws } = connected();
|
||||
ws.reply = (frame) => ({ id: frame.id, type: "error", error: "a title with usable text is required" });
|
||||
await assert.rejects(makeCall(repo), {
|
||||
name: "ProtocolError",
|
||||
message: "a title with usable text is required",
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
test("a run action throws when the reply has no run detail", async () => {
|
||||
const { repo, ws } = connected();
|
||||
ws.reply = (frame) => ({ id: frame.id, type: "run" });
|
||||
await assert.rejects(() => repo.cancelRun(7), ProtocolError);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user