Chat keeps the work item Ask's page and proposals name
- G1T-Session:
- ses_01m566357hejh9yeqjbetx23f3
2 files+12−100/2 viewed
| 88 | 88 | { type: "sources", sources: [] }, | |
| 89 | 89 | ]; | |
| 90 | 90 | const rows = [ | |
| 91 | − | row("m1", ana, "Open issues in acme/rocket?"), | |
| 91 | + | row("m1", ana, "Open work items in acme/rocket?"), | |
| 92 | 92 | row("m2", G1T_KEY, "There is no acme/rocket.", { answer: { state: "done", steps } }), | |
| 93 | 93 | row("m3", ana, "Did you check?"), | |
| 94 | 94 | ]; | |
| ⋯ | |||
| 151 | 151 | }); | |
| 152 | 152 | ||
| 153 | 153 | test("the page an answer is told is the newest question's, as sent from the top bar", () => { | |
| 154 | − | const page = { path: "/acme/web/issues/12", repo: { namespace: "acme", name: "web" }, issue: 12, pull: null }; | |
| 154 | + | const page = { path: "/acme/-/work/12", repo: null, workspace: "acme", item: 12, pull: null }; | |
| 155 | 155 | assert.deepEqual(latestPage([row("m1", ana, "Q", { page }), row("m2", G1T_KEY, "A", done)]), page); | |
| 156 | 156 | assert.equal(latestPage([row("m1", ana, "Q", { page }), row("m2", ana, "From chat")]), null); | |
| 157 | − | assert.deepEqual(pageFrom({ path: "/acme/web", repo: { namespace: "acme", name: "web" }, issue: -1, extra: true }), { | |
| 157 | + | assert.deepEqual(pageFrom({ path: "/acme/web", repo: { namespace: "acme", name: "web" }, item: -1, extra: true }), { | |
| 158 | 158 | path: "/acme/web", | |
| 159 | 159 | repo: { namespace: "acme", name: "web" }, | |
| 160 | − | issue: null, | |
| 160 | + | workspace: null, | |
| 161 | + | item: null, | |
| 161 | 162 | pull: null, | |
| 162 | 163 | time_zone: null, | |
| 163 | 164 | }); | |
| 164 | 165 | // The browser's time zone is kept when it is one; anything else is dropped. | |
| 165 | 166 | assert.equal(pageFrom({ path: "/acme", time_zone: "America/Denver" })?.time_zone, "America/Denver"); | |
| 166 | 167 | assert.equal(pageFrom({ path: "/acme", time_zone: "<script>" })?.time_zone, null); | |
| 167 | − | assert.deepEqual(pageFrom({ time_zone: "Asia/Kolkata" }), { path: null, repo: null, issue: null, pull: null, time_zone: "Asia/Kolkata" }); | |
| 168 | + | assert.deepEqual(pageFrom({ time_zone: "Asia/Kolkata" }), { path: null, repo: null, workspace: null, item: null, pull: null, time_zone: "Asia/Kolkata" }); | |
| 168 | 169 | assert.equal(pageFrom({ path: "https://elsewhere" }), null); | |
| 169 | 170 | assert.equal(pageFrom("nope"), null); | |
| 170 | 171 | assert.equal(metaColumn({}), null); | |
| ⋯ | |||
| 260 | 261 | assert.deepEqual(made.state, { id: "proposal_1_0", starting_at: 5, repo_url: "/acme/hello", production_url: "https://hello-acme.g1t.page" }); | |
| 261 | 262 | assert.equal(made.answer.steps!.length, 2); | |
| 262 | 263 | // A later step merges into the same one; unknown fields are dropped. | |
| 263 | − | const started = withProposalState(made.answer, { id: "proposal_1_0", issue: 1, started: true, session_url: "/s", evil: "x" } as never)!; | |
| 264 | + | const started = withProposalState(made.answer, { id: "proposal_1_0", item: 1, started: true, session_url: "/s", evil: "x" } as never)!; | |
| 264 | 265 | assert.equal(started.answer.steps!.length, 2); | |
| 265 | 266 | assert.deepEqual(started.answer.steps![1], { | |
| 266 | 267 | type: "proposal_state", | |
| ⋯ | |||
| 268 | 269 | starting_at: 5, | |
| 269 | 270 | repo_url: "/acme/hello", | |
| 270 | 271 | production_url: "https://hello-acme.g1t.page", | |
| 271 | − | issue: 1, | |
| 272 | + | item: 1, | |
| 272 | 273 | started: true, | |
| 273 | 274 | session_url: "/s", | |
| 274 | 275 | }); | |
| 69 | 69 | } | |
| 70 | 70 | if (typeof change.repo_url === "string") state.repo_url = change.repo_url.slice(0, 500); | |
| 71 | 71 | if (typeof change.default_branch === "string") state.default_branch = change.default_branch.slice(0, 200); | |
| 72 | − | if (Number.isInteger(change.issue) && change.issue! > 0) state.issue = change.issue; | |
| 72 | + | if (Number.isInteger(change.item) && change.item! > 0) state.item = change.item; | |
| 73 | 73 | if (typeof change.starting_at === "number") state.starting_at = change.starting_at; | |
| 74 | 74 | if (change.started === true) state.started = true; | |
| 75 | 75 | const step = { type: "proposal_state", ...state } as Record<string, unknown>; | |
| ⋯ | |||
| 225 | 225 | repo && typeof repo.namespace === "string" && typeof repo.name === "string" && repo.namespace && repo.name | |
| 226 | 226 | ? { namespace: repo.namespace.slice(0, 100), name: repo.name.slice(0, 100) } | |
| 227 | 227 | : null, | |
| 228 | − | issue: number(sent.issue), | |
| 228 | + | workspace: typeof sent.workspace === "string" && /^[A-Za-z0-9][A-Za-z0-9._-]{0,99}$/.test(sent.workspace) ? sent.workspace : null, | |
| 229 | + | item: number(sent.item), | |
| 229 | 230 | pull: number(sent.pull), | |
| 230 | 231 | time_zone: typeof sent.time_zone === "string" && /^[A-Za-z][A-Za-z0-9_+\-]*(\/[A-Za-z0-9_+\-]+){0,2}$/.test(sent.time_zone) && sent.time_zone.length <= 64 ? sent.time_zone : null, | |
| 231 | 232 | }; | |
| 232 | − | return page.path || page.repo || page.time_zone ? page : null; | |
| 233 | + | return page.path || page.repo || page.workspace || page.time_zone ? page : null; | |
| 233 | 234 | } | |
| 234 | 235 | ||
| 235 | 236 | /** What g1t says when nobody chose an AI provider for Ask yet: once, and where to choose one. */ | |
Comments
Sign in to comment.