{"draft":null,"from":100,"to":318,"files":[{"path":"client/test/issues.test.ts","added":71,"removed":17,"diff":"--- a/client/test/issues.test.ts\n+++ b/client/test/issues.test.ts\n@@ -13,7 +13,7 @@\n import { join } from \"node:path\";\n import { after, before, describe, it } from \"node:test\";\n import { readConfig, readMachineServers } from \"../src/config.ts\";\n-import { issuesServerFor, tokenGoesTo } from \"../src/core.ts\";\n+import { issuesServerFor, tokenGoesTo, tokenGoesToIssues } from \"../src/core.ts\";\n import { issuePage, searchLines } from \"../src/issues.ts\";\n import type { IssuePage } from \"../src/issues-wire.ts\";\n import { main } from \"../src/main.ts\";\n@@ -176,16 +176,42 @@\n \t\tassert.equal(r.exit, 1, r.out);\n \t\tassert.match(r.out, /sends your token only to its own servers and this machine/);\n \t\tassert.equal(seen.length, before);\n-\t\t// A server with no Issues Worker beside it, and none named.\n-\t\tconst { AVCS_ISSUES_SERVER: _, ...without } = ENV();\n-\t\tconst none = await avcs(dave, [\"waiting\"], without);\n-\t\tassert.notEqual(none.exit, 0);\n-\t\tassert.match(\n-\t\t\tnone.out,\n-\t\t\t/has no Issues Worker beside it that abso knows; ~\\/\\.abso\\/servers\\.json or ABSO_ISSUES_SERVER names one/,\n-\t\t);\n \t});\n \n+\tit(\"with no Issues Worker named, uses the server's own /issues, as the open server keeps them\", () => {\n+\t\tassert.equal(issuesServerFor(\"https://abso.example\"), \"https://abso.example/issues\");\n+\t\tassert.equal(issuesServerFor(\"https://Abso.Example/\"), \"https://abso.example/issues\");\n+\t\tassert.equal(issuesServerFor(\"http://localhost:8787\"), \"http://localhost:8787/issues\");\n+\t\tassert.equal(issuesServerFor(\"not a server\"), undefined);\n+\t\t// abso's hosted server keeps its own Issues Worker, and servers.json still comes first.\n+\t\tassert.equal(issuesServerFor(\"https://api.abso.dev\"), \"https://issues.abso.dev\");\n+\t\tconst machine = {\n+\t\t\ttrusted: [],\n+\t\t\tissues: { \"https://staging.abso.example\": \"https://issues-staging.abso.example\" },\n+\t\t};\n+\t\tassert.equal(issuesServerFor(\"https://staging.abso.example\", machine), \"https://issues-staging.abso.example\");\n+\t\t// The token goes to <server>/issues exactly where it goes to <server>.\n+\t\tassert.ok(tokenGoesToIssues(\"https://api.abso.dev/issues\"));\n+\t\tassert.ok(tokenGoesToIssues(\"http://localhost:8787/issues\"));\n+\t\tassert.ok(tokenGoesToIssues(\"https://mine.example/issues\", \"https://mine.example\"));\n+\t\tassert.equal(tokenGoesToIssues(\"https://evil.example/issues\"), false);\n+\t\tassert.equal(tokenGoesToIssues(\"https://api.abso.dev@evil.example/issues\"), false);\n+\t\tassert.equal(tokenGoesToIssues(\"https://api.abso.dev/issues?x=1\"), false);\n+\t\tassert.equal(tokenGoesToIssues(\"http://mine.example/issues\", \"http://mine.example\"), false, \"plain http only here\");\n+\t\t// The server itself still takes no path.\n+\t\tassert.equal(tokenGoesTo(\"https://api.abso.dev/issues\"), false);\n+\t});\n+\n+\tit(\"calls <issues server>/p/<project>/... when the Issues Worker is at a path\", async () => {\n+\t\tconst fay = await folder(\"fay\");\n+\t\tconst before = seen.length;\n+\t\tconst env = { ...ENV(), AVCS_ISSUES_SERVER: `${issuesUrl}/issues` };\n+\t\tconst r = await main([\"ask\", \"7\"], { cwd: fay, env, write: () => {} });\n+\t\tassert.equal(r.exit, 0, r.stdout + r.stderr);\n+\t\tconst { project } = readConfig(fay);\n+\t\tassert.deepEqual(seen.slice(before), [`GET /issues/p/${project}/ask/7`]);\n+\t});\n+\n \tit(\"finds a server's Issues Worker in this machine's servers.json, and may send it the token\", async () => {\n \t\tconst dir = mkdtempSync(join(tmpdir(), \"abso-servers-\"));\n \t\tdirs.push(dir);\n@@ -198,7 +224,7 @@\n \t\tassert.ok(seen.length > before, \"the call went to the Issues Worker servers.json names\");\n \t\tconst machine = readMachineServers({ AVCS_SERVERS_FILE: file });\n \t\tassert.equal(issuesServerFor(fake.url, machine), issuesUrl);\n-\t\tassert.equal(issuesServerFor(\"https://abso.example\", machine), undefined);\n+\t\tassert.equal(issuesServerFor(\"https://abso.example\", machine), \"https://abso.example/issues\");\n \t\t// abso's own server and its Issues Worker are built in.\n \t\tassert.ok(tokenGoesTo(\"https://api.abso.dev\"));\n \t\tassert.ok(tokenGoesTo(\"https://issues.abso.dev\"));\n@@ -246,16 +272,44 @@\n \t});\n \n \tit(\"shows a search hit as the issue, then where it matched, without the match markers\", () => {\n-\t\tconst issue = { id: 12, title: \"Pull is slow\", status: \"open\" as const, updated: 0, labels: [] };\n+\t\tconst unknownAuthorship = {\n+\t\t\tkind: \"unknown\" as const,\n+\t\t\tactor: null,\n+\t\t\tprovenance: \"unknown\" as const,\n+\t\t\tauthorField: null,\n+\t\t};\n+\t\tconst issue = {\n+\t\t\tid: 12,\n+\t\t\ttitle: \"Pull is slow\",\n+\t\t\tstatus: \"open\" as const,\n+\t\t\tupdated: 0,\n+\t\t\tlabels: [],\n+\t\t\tauthorship: { title: unknownAuthorship },\n+\t\t};\n \t\tassert.deepEqual(\n-\t\t\tsearchLines({ issue, where: \"comment\", comment: 40, snippet: \"the \\u0001network\\u0002 drops mid-sync\" }),\n+\t\t\tsearchLines({\n+\t\t\t\tissue,\n+\t\t\t\twhere: \"comment\",\n+\t\t\t\tcomment: 40,\n+\t\t\t\tsnippet: \"the \\u0001network\\u0002 drops mid-sync\",\n+\t\t\t\tmatchedAuthorship: unknownAuthorship,\n+\t\t\t}),\n \t\t\t['   12  open         \"Pull is slow\"', '       in comment 40: \"the network drops mid-sync\"'],\n \t\t);\n-\t\tassert.deepEqual(searchLines({ issue, where: \"description\", snippet: \"Pages load late.\", meaning: true }), [\n-\t\t\t'   12  open         \"Pull is slow\"',\n-\t\t\t'       by meaning: \"Pages load late.\"',\n-\t\t]);\n-\t\tassert.deepEqual(searchLines({ issue, where: \"title\", snippet: \"Pull is slow\" })[1], \"       in the title\");\n+\t\tassert.deepEqual(\n+\t\t\tsearchLines({\n+\t\t\t\tissue,\n+\t\t\t\twhere: \"description\",\n+\t\t\t\tsnippet: \"Pages load late.\",\n+\t\t\t\tmeaning: true,\n+\t\t\t\tmatchedAuthorship: unknownAuthorship,\n+\t\t\t}),\n+\t\t\t['   12  open         \"Pull is slow\"', '       by meaning: \"Pages load late.\"'],\n+\t\t);\n+\t\tassert.deepEqual(\n+\t\t\tsearchLines({ issue, where: \"title\", snippet: \"Pull is slow\", matchedAuthorship: unknownAuthorship })[1],\n+\t\t\t\"       in the title\",\n+\t\t);\n \t});\n \n \tit(\"withdraw is one POST to the asker's own withdraw/<ask> route\", async () => {"}],"unmatched":[]}