justintsus-experiment Public
import { pathToFileURL } from "node:url";// Set WORKTREE_A and WORKTREE_B to checkouts of the two builds (Rebasely at 40d9e6fd and a69ca436).process.env.SEARCH_WORKTREE ??= process.env.WORKTREE_A;const H = await import(new URL("../../hidden-tests/helpers.mjs", import.meta.url).href);const a = await import(pathToFileURL(process.env.SEARCH_WORKTREE + "/apps/web/src/search/api.ts").href);const db = H.fixture();const show = (q, t = "issues", ctx = H.CTX) => { const r = a.parseQuery(q, t); if (!r.ok) return console.log(JSON.stringify(q), t, "ERR", r.errors.map((e) => `${e.code}@${e.start}-${e.end} "${e.message}"`).join(" | ")); const s = a.toSql(r.query, ctx); const rows = db.prepare(`SELECT number FROM ${H.tableOf(t)} WHERE ${s.where} ORDER BY ${s.orderBy}`).all(...s.params).map((x) => x.number); console.log(JSON.stringify(q), t, ctx === H.ANON ? "anon" : ctx.orgId, "->", JSON.stringify(a.serializeQuery(r.query)), "rows", rows.join(","));};const O = { ...H.CTX, orgId: "org-2" };for (const [q, t, c] of [["author:fixer","issues"],["author:fixer","pulls"],["-author:fixer","pulls"],["author:fixer","issues",O],["-author:@me","pulls"],["-author:@me","pulls",H.ANON],["author:@me","pulls",H.ANON],["-author:"+H.BOB,"pulls"],["-review-requested:@me","pulls"],["-review-requested:@me","pulls",H.ANON],["review-requested:fixer","pulls"],["100%"],["a_c"],["a_b","pulls"],["%"],["_"],["\\"],["a\\b"],["ü"],["Ü"],["ÜNÏCODE"],["🐛"],["🐛:x"],["foo:🐛 bar"],["\"🐛"],["a 🐛\" b"],["\uD83D"],[" is:open label:bug "],["is:open"],["is:open"],["\u0085is:open"],["is:openlabel:bug"],["\"abc"],["-\"abc"],["x\"y z"],["\"a\"b c"],["label:\"a\"b"],["label:\"\""],["\"\""],["-\"\""],["-"],["- -"],["--x"],["-#5"],["#0"],["#1234567890"],["sort:created-asc sort:CREATED-ASC"],["sort:x sort:y"],["-is:open is:open"],["created:2026-10-05..2026-10-01"],["created:*..*"],["created:<0007D"],["created:<0d"],["created:<10000d"],["created:7d"],["created:=2026-10-01"],["created:9999-12-31"],["created:1969-12-31"],["created:<٧d"],["created:2026-04-31"],["created:2026-10-01..*..*"],["CREATED:<1W"],["created:>2026-10-01..2026-10-02"],["label:\" Needs Review \""],["label:\"needs\treview\""],["label:a"+"b".repeat(32)],["no:labels"],["-no:label"],["author:@you"],["author:"+H.ME.toUpperCase()],["foo:"],["-label:"],["-sort:"],["-sort:x"],["review-requested:","issues"],["Review-Requested:@me","pulls"],["http://x"],["12:30"],["a-:x"],["\"label:bug\""],["label:bug:x"],["x".repeat(1025)],[Array.from({length:33},(_, i)=>`w${i}`).join(" ")],[Array.from({length:32},(_, i)=>`w${i}`).join(" ")+" \"unterm"]]) show(q, t ?? "issues", c ?? H.CTX);