web: create a pipeline from a template — validate then submit (P5)
A template detail now offers "Create pipeline from this template". Its
dialog ("Create from {name}", one required field "New pipeline name
(required)", the note that it creates a draft and does not run, Create /
Cancel with Cancel reading Close after a success) validates the
template's source first and, only when it parses, submits it create-only
with the trimmed name. Create is disabled while the name is blank or
while sending; the field locks while sending and after a success. A
refusal shows the server's own error in the still-open dialog; a success
shows `Created "{name}". It is in the Pipelines list.` and refreshes
list_pipelines so the new row is visible.
Pure helpers + both request shapes are unit-tested; the flow is captured
against a scratch server with its own throwaway database. The live
server's pipeline list is never touched: the default ui-smoke run sends
no submit and create runs only under its --scratch flag. Wording matches
android/.../TemplateDetailScreen.kt and PipelinesRepository.kt.
This commit is contained in:
@@ -105,6 +105,67 @@ test("validate throws when the reply has no graph", async () => {
|
||||
await assert.rejects(() => repo.validate("empty"), ProtocolError);
|
||||
});
|
||||
|
||||
/** The new pipeline detail a `submitted` reply carries in these tests. */
|
||||
const SUBMITTED_DETAIL = { id: 91, name: "Release helper", version: 1 };
|
||||
|
||||
test("submit sends exactly {type:'submit',name,source,create_only:true} and returns the detail", async () => {
|
||||
const { repo, ws } = connected();
|
||||
ws.reply = (frame) => ({ id: frame.id, type: "submitted", detail: SUBMITTED_DETAIL });
|
||||
|
||||
const detail = await repo.submit("Release helper", "the source");
|
||||
assert.deepEqual(lastFrame(ws), {
|
||||
type: "submit",
|
||||
name: "Release helper",
|
||||
source: "the source",
|
||||
create_only: true,
|
||||
});
|
||||
assert.deepEqual(detail, SUBMITTED_DETAIL);
|
||||
});
|
||||
|
||||
test("submit trims the name before sending it", async () => {
|
||||
const { repo, ws } = connected();
|
||||
ws.reply = (frame) => ({ id: frame.id, type: "submitted", detail: SUBMITTED_DETAIL });
|
||||
|
||||
await repo.submit(" Release helper ", "the source");
|
||||
assert.deepEqual(lastFrame(ws), {
|
||||
type: "submit",
|
||||
name: "Release helper",
|
||||
source: "the source",
|
||||
create_only: true,
|
||||
});
|
||||
});
|
||||
|
||||
test("submit refuses a blank name without sending anything", async () => {
|
||||
const { repo, ws } = connected();
|
||||
ws.reply = () => ({ id: "unused", type: "submitted", detail: SUBMITTED_DETAIL });
|
||||
|
||||
await assert.rejects(() => repo.submit(" ", "the source"), {
|
||||
name: "ProtocolError",
|
||||
message: "Enter a pipeline name.",
|
||||
});
|
||||
assert.equal(ws.sent.length, 0);
|
||||
});
|
||||
|
||||
test("submit rejects a server error envelope with the server's own text", async () => {
|
||||
const { repo, ws } = connected();
|
||||
ws.reply = (frame) => ({ id: frame.id, type: "error", error: 'a pipeline named "Release helper" already exists' });
|
||||
|
||||
await assert.rejects(() => repo.submit("Release helper", "the source"), {
|
||||
name: "ProtocolError",
|
||||
message: 'a pipeline named "Release helper" already exists',
|
||||
});
|
||||
});
|
||||
|
||||
test("submit throws when the reply has no pipeline detail", async () => {
|
||||
const { repo, ws } = connected();
|
||||
ws.reply = (frame) => ({ id: frame.id, type: "submitted", name: "Release helper" });
|
||||
|
||||
await assert.rejects(() => repo.submit("Release helper", "the source"), {
|
||||
name: "ProtocolError",
|
||||
message: "The server returned no pipeline detail.",
|
||||
});
|
||||
});
|
||||
|
||||
test("search sends exactly {type:'search',search:{query,kind:'',limit:0}} and returns search_results", async () => {
|
||||
const { repo, ws } = connected();
|
||||
const payload = { query: "release", results: [{ kind: "run" }], cap: 50, scanned_steps: 3 };
|
||||
|
||||
Reference in New Issue
Block a user