feat(events,proposals,ui): identify triggers by immutable UUID (#2126)

This commit is contained in:
sam committed 2026-11-24 05:36:52 +11:00
1 parent 67ce2901a5
commit efe7069bc1
24 files changed
+473 -299

No files matched your search

+9 -8
View File
@@ -32,25 +32,26 @@ async function main() {
await request("/api/workflows", { authenticated: false, status: 401 });
const name = `smoke-${randomUUID()}`;
const saved = await request(`/api/workflows/${name}`, {
method: "PUT",
body: { body: `repository: none\nsteps:\n - id: notify\n type: run.notify\n settings: {title: ${name}}\n` },
const saved = await request("/api/workflows", {
method: "POST",
status: 201,
body: { name, body: `repository: none\nsteps:\n - id: notify\n type: run.notify\n settings: {title: ${name}}\n` },
});
const trigger = { workflow: name, every: "1m" };
const trigger = { name, workflow_id: saved.id, every: "1m" };
const created = await request("/api/triggers", { method: "POST", body: trigger, status: 201 });
try {
await request(`/api/triggers/${name}`, { method: "PUT", body: trigger });
const deadline = Date.now() + 90_000;
let last = "no scheduled run";
while (Date.now() < deadline) {
const recent = await request("/api/runs");
const run = recent.find((row) => row.workflow === name);
const run = recent.find((row) => row.workflow_id === saved.id);
if (run) {
last = `run ${run.id}: ${run.state}`;
assert.ok(!["failed", "cancelled"].includes(run.state), `${last}: ${run.error || "no error returned"}`);
if (run.state === "succeeded") {
const trail = await request(`/api/runs/${run.id}`);
assert.equal(trail.run.workflow_version, saved.version, "Run used the wrong workflow version");
assert.equal(trail.origin?.trigger, name, "Run trail is missing the schedule trigger");
assert.equal(trail.origin?.trigger_id, created.id, "Run trail is missing the schedule trigger");
assert.ok(trail.origin?.event_id, "Run trail is missing the originating event");
assert.equal(trail.origin.type, "schedule.tick");
const messages = await request("/api/composer/messages");
@@ -64,7 +65,7 @@ async function main() {
}
throw new Error(`Timed out waiting for ${name}: ${last}`);
} finally {
await request(`/api/triggers/${name}`, { method: "PUT", body: { ...trigger, disabled: true } });
await request(`/api/triggers/${created.id}`, { method: "PUT", body: { ...trigger, disabled: true } });
}
}