From da3c488506320d42c885c3cc8da4927e6104c24e Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Mon, 19 Oct 2026 02:30:39 +0100 Subject: [PATCH] web: templates gallery and template detail (P4) --- web/PARITY.md | 2 +- web/src/app.js | 210 ++++++++++++++++++++++++++++++++++- web/src/protocol.js | 5 + web/src/repository.js | 14 +++ web/src/templates.js | 93 ++++++++++++++++ web/styles.css | 53 +++++++++ web/test/repository.test.mjs | 106 ++++++++++++++++++ web/test/templates.test.mjs | 87 +++++++++++++++ web/test/ui-smoke.mjs | 18 +++ 9 files changed, 586 insertions(+), 2 deletions(-) create mode 100644 web/src/templates.js create mode 100644 web/test/repository.test.mjs create mode 100644 web/test/templates.test.mjs diff --git a/web/PARITY.md b/web/PARITY.md index 5df4f4e4..0db762e0 100644 --- a/web/PARITY.md +++ b/web/PARITY.md @@ -24,7 +24,7 @@ Status legend: `todo` · `partial` (some of it works) · `done` (working + captu | P1 | Pipeline list | `list_pipelines` | partial (list + count only) | | P2 | Filter + sort (status/name/updated) | client-side | todo | | P3 | Pipeline detail: stages, graph, versions, last run, content hash | `get_pipeline` | todo | -| P4 | Templates gallery + template detail | `list_templates` | todo | +| P4 | Templates gallery + template detail | `list_templates`, `validate` | done | | P5 | Create pipeline from a template (validate then submit) | `validate`, `submit` | todo | | P6 | Workflow graph rendering (nodes, edges, stage panes) | `get_pipeline` | todo | diff --git a/web/src/app.js b/web/src/app.js index 1af401e1..4eeda71e 100644 --- a/web/src/app.js +++ b/web/src/app.js @@ -4,6 +4,16 @@ import { PipelinesClient } from "./client.js"; import { PipelinesRepository } from "./repository.js"; import { validateServerUrl, resolveArtifactUrl } from "./serverUrl.js"; +import { + effectiveStageType, + templateCard, + templateDetailName, + templateGalleryName, + templateGraphNote, + templateStageCountLabel, + templateStageSummary, + TEMPLATE_UNPARSED_SOURCE_NOTE, +} from "./templates.js"; const STORAGE_KEY = "pipelines.web.serverUrl.v2"; @@ -43,6 +53,13 @@ const state = { runDetail: null, selectedPipelineId: null, selectedRunId: null, + templates: [], + templateLoading: false, + // key -> graph|null: the parsed definition, cached once per template key. A + // failed/absent validate stores null so the card/detail say "unavailable". + templateGraphs: new Map(), + selectedTemplateKey: null, + templateTab: "summary", loading: false, error: "", }; @@ -168,6 +185,7 @@ function renderContent() { { class: "tabs" }, tabButton("pipelines", `Pipelines (${state.pipelines.length})`), tabButton("runs", `Runs (${state.runs.length})`), + tabButton("templates", "Templates"), h("span", { class: "spacer" }), h("button", { class: "ghost", text: "Refresh", onclick: () => loadCurrentView(true) }), ), @@ -176,8 +194,10 @@ function renderContent() { const split = h("div", { class: "split" }); if (state.view === "pipelines") { split.append(renderPipelineList(), renderPipelineDetail()); - } else { + } else if (state.view === "runs") { split.append(renderRunList(), renderRunDetail()); + } else { + split.append(renderTemplateGallery(), renderTemplateDetail()); } nodes.push(split); content.replaceChildren(...nodes); @@ -193,6 +213,7 @@ function tabButton(view, label) { renderContent(); if (view === "runs" && !state.runs.length) loadCurrentView(); if (view === "pipelines" && !state.pipelines.length) loadCurrentView(); + if (view === "templates" && !state.templates.length) loadCurrentView(); }, }); } @@ -264,6 +285,140 @@ function renderPipelineDetail() { return pane; } +// --- Templates ------------------------------------------------------------- + +/** The cached parsed graph for a template key, or null when it did not parse. */ +function templateGraphFor(key) { + return state.templateGraphs.has(key) ? state.templateGraphs.get(key) : null; +} + +function renderTemplateGallery() { + const pane = h("div", { class: "list gallery" }); + pane.append( + h( + "div", + { class: "pane-head" }, + h("h2", { text: "Templates" }), + h("button", { class: "ghost", text: "Refresh templates", onclick: () => loadTemplates(true) }), + ), + ); + if (state.templateLoading && !state.templates.length) { + pane.append(h("div", { class: "muted pad", text: "Loading templates…" })); + return pane; + } + if (!state.templates.length) { + pane.append(h("div", { class: "muted pad", text: "No templates are available on this server." })); + return pane; + } + const cards = h("div", { class: "cards" }); + for (const entry of state.templates) { + const card = templateCard(entry, templateGraphFor(entry.key)); + cards.append( + h( + "button", + { + class: `card${state.selectedTemplateKey === entry.key ? " selected" : ""}`, + onclick: () => selectTemplate(entry.key), + }, + h("span", { class: "card-name", text: templateGalleryName(card.name) }), + h("span", { class: "card-desc", text: card.description }), + h("span", { class: "card-meta", text: templateStageCountLabel(card.stageCount) }), + ), + ); + } + pane.append(cards); + return pane; +} + +function renderTemplateDetail() { + const pane = h("div", { class: "detail" }); + const entry = state.templates.find((t) => t.key === state.selectedTemplateKey); + if (!entry) { + pane.append(h("div", { class: "muted pad", text: "Select a template." })); + return pane; + } + const graph = templateGraphFor(entry.key); + pane.append( + h( + "div", + { class: "tabstrip" }, + templateTabButton("summary", "Summary"), + templateTabButton("graph", "Graph"), + templateTabButton("source", "Source"), + ), + ); + if (state.templateTab === "graph") pane.append(renderTemplateGraphTab(graph)); + else if (state.templateTab === "source") pane.append(renderTemplateSourceTab(entry, graph)); + else pane.append(renderTemplateSummaryTab(entry, graph)); + return pane; +} + +function templateTabButton(tab, label) { + return h("button", { + class: `minitab${state.templateTab === tab ? " active" : ""}`, + text: label, + onclick: () => { + state.templateTab = tab; + renderContent(); + }, + }); +} + +function renderTemplateSummaryTab(entry, graph) { + const wrap = h("div", { class: "tabbody" }); + wrap.append(h("h2", { text: templateDetailName(entry) })); + if ((entry.description ?? "").trim()) { + wrap.append(h("p", { class: "body", text: entry.description })); + } + wrap.append(h("div", { class: "kv" }, kvMono("Key", entry.key))); + wrap.append( + h("div", { class: "meta-line", text: templateStageCountLabel(graph?.stages?.length ?? null) }), + ); + if (entry.scheduled) wrap.append(h("div", { class: "meta-line", text: "Includes a schedule" })); + + const summary = templateStageSummary(graph); + if (summary.note) { + wrap.append(h("div", { class: "muted pad", text: summary.note })); + return wrap; + } + wrap.append(h("h3", { text: "Stages" })); + const ul = h("ul", { class: "stages" }); + for (const stage of summary.stages) { + ul.append( + h( + "li", + {}, + h("code", { text: stage.key }), + h("span", { class: "chip", text: effectiveStageType(stage.type) }), + ), + ); + } + wrap.append(ul); + return wrap; +} + +function renderTemplateGraphTab(graph) { + const wrap = h("div", { class: "tabbody" }); + wrap.append(h("p", { class: "muted", text: templateGraphNote(graph) })); + return wrap; +} + +function renderTemplateSourceTab(entry, graph) { + const wrap = h("div", { class: "tabbody" }); + if (graph == null) { + wrap.append(h("p", { class: "muted", text: TEMPLATE_UNPARSED_SOURCE_NOTE })); + } + wrap.append( + h( + "div", + { class: "codeblock" }, + h("div", { class: "codeblock-label", text: "Definition source" }), + h("pre", { class: "codeblock-body", text: entry.source ?? "" }), + ), + ); + return wrap; +} + function renderRunList() { const list = h("div", { class: "list" }); if (state.usage) { @@ -401,6 +556,16 @@ function kv(key, value) { ); } +/** A key/value row whose value is monospace (a key, an id) rather than prose. */ +function kvMono(key, value) { + return h( + "div", + { class: "kv-row" }, + h("span", { class: "kv-key", text: key }), + h("span", { class: "kv-val" }, h("code", { text: value })), + ); +} + // --------------------------------------------------------------------------- // Actions // --------------------------------------------------------------------------- @@ -445,6 +610,10 @@ async function loadCurrentView(force = false) { renderContent(); return; } + if (state.view === "templates") { + await loadTemplates(force); + return; + } state.loading = true; state.error = ""; renderContent(); @@ -467,6 +636,45 @@ async function loadCurrentView(force = false) { } } +/** + * Loads the template catalogue, then validates each template's source once and + * caches the parsed graph (null when it did not parse) so a card's stage count + * and the detail's stage list read the same result and can never disagree. + */ +async function loadTemplates(force = false) { + state.templateLoading = true; + state.error = ""; + renderContent(); + try { + state.templates = await repo.listTemplates(); + for (const entry of state.templates) { + if (force || !state.templateGraphs.has(entry.key)) { + state.templateGraphs.set(entry.key, await validateTemplate(entry)); + } + } + state.templateLoading = false; + renderContent(); + } catch (err) { + state.templateLoading = false; + setError(err); + } +} + +/** The parsed graph for a template, or null when the server cannot parse its source. */ +async function validateTemplate(entry) { + try { + return await repo.validate(entry.source); + } catch { + return null; + } +} + +function selectTemplate(key) { + state.selectedTemplateKey = key; + state.templateTab = "summary"; + renderContent(); +} + async function selectPipeline(summary) { state.selectedPipelineId = summary.id; state.pipelineDetail = null; diff --git a/web/src/protocol.js b/web/src/protocol.js index 72ce842b..65fd52cf 100644 --- a/web/src/protocol.js +++ b/web/src/protocol.js @@ -11,6 +11,11 @@ export const Protocol = Object.freeze({ GET_PIPELINE: "get_pipeline", PIPELINE: "pipeline", + LIST_TEMPLATES: "list_templates", + TEMPLATES: "templates", + VALIDATE: "validate", + VALIDATED: "validated", + LIST_RUNS: "list_runs", RUNS: "runs", GET_RUN: "get_run", diff --git a/web/src/repository.js b/web/src/repository.js index 1ae5387c..11251765 100644 --- a/web/src/repository.js +++ b/web/src/repository.js @@ -43,6 +43,20 @@ export class PipelinesRepository { return response.detail; } + async listTemplates() { + return (await this.#client.call({ type: Protocol.LIST_TEMPLATES })).templates ?? []; + } + + async validate(source) { + const response = await this.#client.call({ type: Protocol.VALIDATE, source }); + // A server error envelope already rejects inside client.call, so a reply + // here is `validated`; a missing graph is still an unusable definition. + if (!response.graph) { + throw new ProtocolError("The server returned no graph."); + } + return response.graph; + } + async listRuns() { const response = await this.#client.call({ type: Protocol.LIST_RUNS }); return { runs: response.runs ?? [], usage: response.usage ?? null }; diff --git a/web/src/templates.js b/web/src/templates.js new file mode 100644 index 00000000..a7e01a62 --- /dev/null +++ b/web/src/templates.js @@ -0,0 +1,93 @@ +// Pure Templates derivations, mirroring the Android app's ui/Templates.kt, +// ui/Format.kt and ui/graph/StageDetailPane.kt. No DOM and no protocol here, so +// the gallery/detail wording and the stage-count mapping are unit-tested without +// a browser. Every value returned is plain text (or plain data); the caller sets +// it with textContent and never with innerHTML. + +/** A gallery card's name: a blank name is the explicit unnamed-template placeholder. */ +export function templateGalleryName(name) { + return (name ?? "").trim() ? name : "(unnamed template)"; +} + +/** A detail's heading: a blank name falls back to the template's key. */ +export function templateDetailName(entry) { + const name = (entry?.name ?? "").trim(); + return name ? entry.name : (entry?.key ?? ""); +} + +/** "1 stage" / "N stages", mirroring ui/Format.kt stageCountText. */ +export function stageCountText(count) { + return `${count} ${count === 1 ? "stage" : "stages"}`; +} + +/** + * The card's stage-count line: the count parsed from the source, or an explicit + * "unavailable" when the source could not be parsed (never "0 stages", which + * would claim a count the client does not have). + */ +export function templateStageCountLabel(stageCount) { + return stageCount == null ? "stage count unavailable" : stageCountText(stageCount); +} + +/** The effective stage type, mirroring internal/stage.EffectiveType: blank is the model stage. */ +export function effectiveStageType(type) { + return (type ?? "").trim() ? type : "model"; +} + +/** + * One gallery card's content: the template's name and description (from the + * catalogue) and its stage count (from the graph the server parsed out of the + * source; null when the source did not parse, so the card says so rather than + * claiming zero stages). + */ +export function templateCard(entry, graph = null) { + return { + key: entry?.key ?? "", + name: entry?.name ?? "", + description: entry?.description ?? "", + stageCount: graph?.stages?.length ?? null, + }; +} + +/** The unparsed-source note the Summary tab shows instead of a stage list. */ +export const TEMPLATE_UNPARSED_SUMMARY_NOTE = + "This template's source could not be parsed, so its stages are not listed. See the Source tab for the raw definition."; + +/** The note the Summary tab shows for a parsed template that declares no stages. */ +export const TEMPLATE_NO_STAGES_NOTE = "This template has no stages."; + +/** The Graph tab's note when the source did not parse. */ +export const TEMPLATE_UNPARSED_GRAPH_NOTE = + "This template's source could not be parsed, so there is no graph. The Source tab shows the raw definition."; + +/** The Graph tab's note when the source parsed; the graph is the parsed definition. */ +export const TEMPLATE_GRAPH_NOTE = + "Pinch to zoom and drag to pan. The graph is the parsed definition; nothing runs."; + +/** The Source tab's note when the source did not parse on the server. */ +export const TEMPLATE_UNPARSED_SOURCE_NOTE = + "This source could not be parsed on the server; showing the raw definition."; + +/** + * The Summary tab's stage section: an explicit [note] and no stages when the + * source did not parse or parsed to nothing, else the stage rows (key + effective + * type). One derivation, so the note and the list can never disagree. + */ +export function templateStageSummary(graph) { + if (graph == null) { + return { note: TEMPLATE_UNPARSED_SUMMARY_NOTE, stages: [] }; + } + const stages = graph.stages ?? []; + if (!stages.length) { + return { note: TEMPLATE_NO_STAGES_NOTE, stages: [] }; + } + return { + note: null, + stages: stages.map((stage) => ({ key: stage.key, type: effectiveStageType(stage.type) })), + }; +} + +/** The Graph tab's note: the unparsed note when there is no graph, else the parsed-definition note. */ +export function templateGraphNote(graph) { + return graph == null ? TEMPLATE_UNPARSED_GRAPH_NOTE : TEMPLATE_GRAPH_NOTE; +} diff --git a/web/styles.css b/web/styles.css index f753f440..0dce27da 100644 --- a/web/styles.css +++ b/web/styles.css @@ -142,3 +142,56 @@ button.ghost { background: transparent; } .banner.error { background: #2c1616; color: var(--bad); } code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: 12px; } + +/* --- Templates gallery + detail ------------------------------------------ */ + +.pane-head { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 12px 12px 0; } +.pane-head h2 { margin: 0; font-size: 16px; } + +.gallery { padding-bottom: 8px; } +.cards { display: grid; gap: 8px; padding: 10px 12px; } +.card { + display: block; + width: 100%; + text-align: left; + border: 1px solid var(--border); + border-radius: 10px; + background: var(--surface-2); + padding: 10px 12px; +} +.card:hover { border-color: var(--accent); } +.card.selected { box-shadow: inset 3px 0 0 var(--accent); border-color: var(--accent); } +.card-name { display: block; font-weight: 600; } +.card-desc { + display: -webkit-box; + -webkit-line-clamp: 2; + -webkit-box-orient: vertical; + overflow: hidden; + color: var(--muted); + font-size: 12px; + margin-top: 2px; +} +.card-desc:empty { display: none; } +.card-meta { display: block; color: var(--accent); font-size: 12px; margin-top: 4px; } + +.tabstrip { display: flex; gap: 4px; margin: -4px 0 12px; } +.minitab { border-color: transparent; background: transparent; padding: 5px 10px; } +.minitab.active { background: var(--surface-2); border-color: var(--border); color: var(--accent); } + +.tabbody h2 { margin-top: 0; } +.tabbody .body { margin: 0 0 12px; } +.meta-line { color: var(--muted); font-size: 12px; margin-top: 4px; } + +.codeblock { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; margin-top: 12px; } +.codeblock-label { padding: 6px 10px; background: var(--surface-2); border-bottom: 1px solid var(--border); color: var(--muted); font-size: 12px; } +.codeblock-body { + margin: 0; + padding: 10px; + max-height: 420px; + overflow: auto; + background: transparent; + color: var(--text); + font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; + white-space: pre-wrap; + word-break: break-word; +} diff --git a/web/test/repository.test.mjs b/web/test/repository.test.mjs new file mode 100644 index 00000000..1b560c5e --- /dev/null +++ b/web/test/repository.test.mjs @@ -0,0 +1,106 @@ +// Repository request-shape tests: the templates catalogue and the validate +// command, driven through the real transport against a fake WebSocket so the +// exact frames sent (and the error-envelope handling) are proven, not assumed. +import { test } from "node:test"; +import assert from "node:assert/strict"; + +import { PipelinesClient, ProtocolError } from "../src/client.js"; +import { PipelinesRepository } from "../src/repository.js"; +import { validateServerUrl } from "../src/serverUrl.js"; + +const VALID = validateServerUrl("ws://host:8080/connect"); + +/** The same minimal fake the client tests use (test files are not importable). */ +class FakeWebSocket { + static instances = []; + + constructor(url) { + this.url = url; + this.sent = []; + this.onopen = null; + this.onmessage = null; + this.onclose = null; + this.onerror = null; + this.reply = null; + FakeWebSocket.instances.push(this); + } + + send(data) { + const frame = JSON.parse(data); + this.sent.push(frame); + const response = this.reply?.(frame); + if (response !== undefined) { + this.onmessage?.({ data: JSON.stringify(response) }); + } + } + + close(code, reason) { + this.onclose?.({ code, reason }); + } + + open() { + this.onopen?.({}); + } +} + +function connected() { + FakeWebSocket.instances = []; + const client = new PipelinesClient({ WebSocketImpl: FakeWebSocket }); + const repo = new PipelinesRepository(client); + client.connect(VALID); + const ws = FakeWebSocket.instances.at(-1); + ws.open(); + return { repo, ws, client }; +} + +/** The last frame without the client-generated id, for an exact shape assertion. */ +function lastFrame(ws) { + const { id, ...frame } = ws.sent.at(-1); + assert.match(id, /^web-\d+$/); + return frame; +} + +test("listTemplates sends exactly {type:'list_templates'} and returns the catalogue", async () => { + const { repo, ws } = connected(); + ws.reply = (frame) => ({ + id: frame.id, + type: "templates", + templates: [{ key: "task", name: "Complete a task" }], + }); + + const templates = await repo.listTemplates(); + assert.deepEqual(lastFrame(ws), { type: "list_templates" }); + assert.equal(templates.length, 1); + assert.equal(templates[0].key, "task"); +}); + +test("listTemplates returns [] when the reply carries no templates", async () => { + const { repo, ws } = connected(); + ws.reply = (frame) => ({ id: frame.id, type: "templates" }); + assert.deepEqual(await repo.listTemplates(), []); +}); + +test("validate sends exactly {type:'validate', source} and returns response.graph", async () => { + const { repo, ws } = connected(); + const graph = { stages: [{ key: "plan" }] }; + ws.reply = (frame) => ({ id: frame.id, type: "validated", graph }); + + const result = await repo.validate("the source"); + assert.deepEqual(lastFrame(ws), { type: "validate", source: "the source" }); + assert.deepEqual(result, graph); +}); + +test("validate rejects a server error envelope with the server's text", async () => { + const { repo, ws } = connected(); + ws.reply = (frame) => ({ id: frame.id, type: "error", error: "unexpected token" }); + await assert.rejects(() => repo.validate("bad source"), { + name: "ProtocolError", + message: "unexpected token", + }); +}); + +test("validate throws when the reply has no graph", async () => { + const { repo, ws } = connected(); + ws.reply = (frame) => ({ id: frame.id, type: "validated" }); + await assert.rejects(() => repo.validate("empty"), ProtocolError); +}); diff --git a/web/test/templates.test.mjs b/web/test/templates.test.mjs new file mode 100644 index 00000000..ba98e17b --- /dev/null +++ b/web/test/templates.test.mjs @@ -0,0 +1,87 @@ +// Pure Templates helper tests: wording (singular/plural, placeholders), the +// card mapping and the stage-summary/graph-note derivations. No DOM, no server. +import { test } from "node:test"; +import assert from "node:assert/strict"; + +import { + effectiveStageType, + stageCountText, + templateCard, + templateDetailName, + templateGalleryName, + templateGraphNote, + templateStageCountLabel, + templateStageSummary, + TEMPLATE_GRAPH_NOTE, + TEMPLATE_NO_STAGES_NOTE, + TEMPLATE_UNPARSED_GRAPH_NOTE, + TEMPLATE_UNPARSED_SUMMARY_NOTE, +} from "../src/templates.js"; + +test("stageCountText spells one stage and many stages", () => { + assert.equal(stageCountText(1), "1 stage"); + assert.equal(stageCountText(2), "2 stages"); + assert.equal(stageCountText(0), "0 stages"); +}); + +test("templateStageCountLabel says unavailable for an unknown count, never zero", () => { + assert.equal(templateStageCountLabel(null), "stage count unavailable"); + assert.equal(templateStageCountLabel(undefined), "stage count unavailable"); + assert.equal(templateStageCountLabel(1), "1 stage"); + assert.equal(templateStageCountLabel(3), "3 stages"); +}); + +test("a blank gallery name becomes the unnamed placeholder", () => { + assert.equal(templateGalleryName(""), "(unnamed template)"); + assert.equal(templateGalleryName(" "), "(unnamed template)"); + assert.equal(templateGalleryName("Review a repository"), "Review a repository"); +}); + +test("a blank detail name falls back to the template key", () => { + assert.equal(templateDetailName({ key: "task", name: "" }), "task"); + assert.equal(templateDetailName({ key: "task", name: " " }), "task"); + assert.equal(templateDetailName({ key: "task", name: "Complete a task" }), "Complete a task"); +}); + +test("effectiveStageType defaults a blank type to model", () => { + assert.equal(effectiveStageType(""), "model"); + assert.equal(effectiveStageType(null), "model"); + assert.equal(effectiveStageType(" "), "model"); + assert.equal(effectiveStageType("human"), "human"); +}); + +test("templateCard takes the stage count from the parsed graph, null when absent", () => { + const entry = { key: "task", name: "Complete a task", description: "Do it." }; + assert.equal(templateCard(entry, null).stageCount, null); + assert.equal(templateCard(entry, { stages: [] }).stageCount, 0); + assert.equal(templateCard(entry, { stages: [{ key: "a" }, { key: "b" }] }).stageCount, 2); + assert.deepEqual(templateCard(entry, null), { + key: "task", + name: "Complete a task", + description: "Do it.", + stageCount: null, + }); +}); + +test("templateStageSummary distinguishes unparsed, empty and populated", () => { + assert.deepEqual(templateStageSummary(null), { + note: TEMPLATE_UNPARSED_SUMMARY_NOTE, + stages: [], + }); + assert.deepEqual(templateStageSummary({ stages: [] }), { + note: TEMPLATE_NO_STAGES_NOTE, + stages: [], + }); + + const summary = templateStageSummary({ stages: [{ key: "plan", type: "" }, { key: "review", type: "human" }] }); + assert.equal(summary.note, null); + assert.deepEqual(summary.stages, [ + { key: "plan", type: "model" }, + { key: "review", type: "human" }, + ]); +}); + +test("templateGraphNote picks the unparsed or parsed note", () => { + assert.equal(templateGraphNote(null), TEMPLATE_UNPARSED_GRAPH_NOTE); + assert.equal(templateGraphNote({ stages: [] }), TEMPLATE_GRAPH_NOTE); +}); diff --git a/web/test/ui-smoke.mjs b/web/test/ui-smoke.mjs index c39dfc6e..0ca34c8d 100644 --- a/web/test/ui-smoke.mjs +++ b/web/test/ui-smoke.mjs @@ -86,6 +86,24 @@ try { await page.waitForSelector(".detail h2", { timeout: 25000 }); shots.push(await page.screenshot(`${out}/03-run-detail.png`)); + step("opening the Templates gallery"); + await page.clickText("nav.tabs button.tab", "Templates"); + await page.waitForSelector(".cards button.card", { timeout: 25000 }); + shots.push(await page.screenshot(`${out}/04-templates-gallery.png`)); + const templateCount = await page.evaluate(`document.querySelectorAll(".cards button.card").length`); + console.log(` templates rendered: ${templateCount}`); + + step("opening a template detail (Summary)"); + await page.click(".cards button.card"); + await page.waitForSelector(".detail .tabstrip", { timeout: 25000 }); + await page.waitForText("Key", { timeout: 25000 }); + shots.push(await page.screenshot(`${out}/05-template-detail-summary.png`)); + + step("opening the template Source tab"); + await page.clickText(".detail .tabstrip button.minitab", "Source"); + await page.waitForText("Definition source", { timeout: 25000 }); + shots.push(await page.screenshot(`${out}/06-template-source.png`)); + console.log("\nUI SMOKE PASS"); for (const shot of shots) console.log(` ${shot}`); } catch (error) {