search: browse bounded recent items with kind-only queries

This commit is contained in:
2026-10-20 17:54:00 +01:00
parent cce7ea903a
commit 9cdfd9d9ab
12 changed files with 477 additions and 94 deletions
+30 -10
View File
@@ -8,7 +8,7 @@ import { fileURLToPath } from "node:url";
import { launchChrome, eventually } from "./browser.mjs";
const root = fileURLToPath(new URL("../", import.meta.url));
const out = resolve(process.argv[2] || "captures/search-types");
const out = resolve(process.argv[2] || "captures/search-types-recent");
await mkdir(out, { recursive: true });
const server = createServer(async (req, res) => {
try {
@@ -39,7 +39,14 @@ try {
window.framesSent = [];
const repo = new PipelinesRepository({ call: async (frame) => {
framesSent.push(frame);
return { search_results: { results: [] } };
const fixtures = {
pipeline: [{ kind: 'pipeline', target: 'pipeline:12', pipeline: { id: 12, name: 'Recent fixture pipeline', version: 1, stages: 2 } }],
artifact: [{ kind: 'artifact', target: '/artifacts/12/1/report.txt', artifact: { run_id: 12, sequence: 1, name: 'Recent fixture report.txt', url: '/artifacts/12/1/report.txt', content_type: 'text/plain', size_bytes: 20 } }],
};
return { search_results: {
results: frame.search.query === '' ? fixtures[frame.search.kind] || [] : [],
truncated: frame.search.query === '' && ['field', 'pipeline'].includes(frame.search.kind),
} };
}});
const state = { searchQuery: '', searchKind: '', searchSort: 'relevance',
searchResults: [], searchSequencer: new SearchSequencer(), searchActiveIndex: 0 };
@@ -69,17 +76,30 @@ try {
assert.equal((await last()).search.query, '"t:run" t:unknown');
await page.screenshot(`${out}/04-literal-tokens.png`);
const before = await page.evaluate("framesSent.length");
await page.fill("#searchInput", "t:pipeline");
await eventually(() => page.evaluate("document.querySelector('#searchResults').textContent.includes('Add search text')"));
await new Promise((done) => setTimeout(done, 400));
assert.equal(await page.evaluate("framesSent.length"), before);
await page.screenshot(`${out}/05-type-only-help.png`);
await search("t:pipeline");
assert.deepEqual((await last()), { type: "search", search: { query: "", kind: "pipeline", limit: 0 } });
await eventually(() => page.evaluate("document.querySelector('#searchResults').textContent.includes('Recent fixture pipeline')"));
await page.screenshot(`${out}/05-type-only-pipelines.png`);
await search("type:ARTIFACT");
assert.deepEqual((await last()).search, { query: "", kind: "artifact", limit: 0 });
await eventually(() => page.evaluate("document.querySelector('#searchResults').textContent.includes('Recent fixture report.txt')"));
await page.screenshot(`${out}/06-type-only-artifacts.png`);
await page.evaluate("document.querySelector('#searchKind').value = 'step'; document.querySelector('#searchKind').dispatchEvent(new Event('change'))");
await eventually(() => page.evaluate("document.querySelector('#searchResults').textContent === 'No steps yet.'"));
assert.deepEqual((await last()).search, { query: "", kind: "step", limit: 0 });
await page.screenshot(`${out}/07-empty-kind.png`);
await page.evaluate("document.querySelector('#searchKind').value = 'field'; document.querySelector('#searchKind').dispatchEvent(new Event('change'))");
await eventually(() => page.evaluate("document.querySelector('#searchResults').textContent.includes(\"No fields found within the server's scan limit.\")"));
await page.screenshot(`${out}/08-scan-bound-empty.png`);
const beforeClear = await page.evaluate("framesSent.length");
await page.click("#searchClearFilter");
assert.equal(await page.evaluate("document.querySelector('#searchInput').value"), "");
assert.equal(await page.evaluate("document.querySelector('#searchKind').value"), "");
await page.screenshot(`${out}/06-cleared-filter.png`);
console.log(`PASS: type tokens, wire kind/query, precedence, selector replacement, literals, type-only help and clear. Captures: ${out}`);
assert.equal(await page.evaluate("document.querySelector('#searchResults').textContent"), "");
assert.equal(await page.evaluate("framesSent.length"), beforeClear);
await page.screenshot(`${out}/09-cleared-filter.png`);
console.log(`PASS: type tokens, wire kind/query, precedence, selector replacement, literals, kind-only results/empty state and clear. Captures: ${out}`);
} finally {
await browser?.close();
await new Promise((done) => server.close(done));