Public: anyone can read this; the crew can change it.

A key whose control is in a closed disclosure opens it first: an issue's a reaches Assign to #17224

opened this

Merged 45h 4m ago, live in production

issue-assign → main 0 commits

  • Merged. issue-assign was merged into main as 4315785.

Review

Sign in to review this change.
2 files changed +87 −1
src/web/client.ts +5 −1
@@ -1689,7 +1689,11 @@ const shellCore = /* js */ `
16891689 // a g, whose letter is a jump).
16901690 var target = doc.querySelector('[data-shortcut="' + esc(joined) + '"]') || (seq.length === 2 && seq[0] !== 'g' ? doc.querySelector('[data-shortcut="' + esc(e.key) + '"]') : null);
16911691 if (target) {
1692 seq.length = 0; e.preventDefault(); target.click();
1692 seq.length = 0; e.preventDefault();
1693 // A key whose control sits in a closed disclosure (an issue's Details: a assigns) opens it
1694 // first, or the click would focus nothing.
1695 for (var shut = target.closest('details:not([open])'); shut; shut = shut.parentElement && shut.parentElement.closest('details:not([open])')) shut.open = true;
1696 target.click();
16931697 // A chord that picks a radio leaves the caret in that form's box: the
16941698 // verdict is chosen, the words come next.
16951699 var after = target.type === 'radio' && target.form ? target.form.querySelector('textarea') : null;
test/issue-assign-key.test.ts added +82
@@ -0,0 +1,82 @@
1 /**
2 * A key whose control sits in a closed disclosure opens it before the click (client.ts): on an
3 * issue page, `a` (Assign) reaches the assignee field inside the closed Details, as production
4 * showed it did not (v0.7.690: the caret stayed on the page).
5 */
6 import { afterAll, beforeAll, expect, test } from "bun:test";
7 import { mkdtemp, rm } from "node:fs/promises";
8 import { tmpdir } from "node:os";
9 import { join } from "node:path";
10 import { openIssue } from "../src/actions/issues.ts";
11 import { createRepo } from "../src/actions/repos.ts";
12 import { createApp, type App } from "../src/app.ts";
13 import { createSession } from "../src/core/sessions.ts";
14 import { createUser, type User } from "../src/core/users.ts";
15 import { serve, type Servers } from "../src/http/server.ts";
16 import { findChromium } from "../src/looks/capture.ts";
17 import { chromiumRuns, evaluateLoaded } from "./helpers/chrome.ts";
18 import { quietLogs } from "./helpers/globals.ts";
19
20 quietLogs();
21 const found = findChromium();
22 const chromium = found !== undefined && chromiumRuns(found) ? found : undefined;
23 const skip = chromium === undefined && (process.env["FORGE_CHECK"] ?? "") === "";
24 if (skip) console.log("SKIPPING: no chromium that starts on this machine, so the issue page's a is not pressed");
25
26 let dir: string;
27 let app: App;
28 let servers: Servers;
29 let alice: User;
30 let number = 0;
31 beforeAll(async () => {
32 dir = await mkdtemp(join(tmpdir(), "forge-issue-assign-key-"));
33 app = createApp({ dataDir: dir, port: 0 });
34 servers = await serve(app);
35 const made = await createUser(app.db, {
36 origin: "seed",
37 trusted: true,
38 username: "alice",
39 email: "[email protected]",
40 password: "a-good-passphrase",
41 adminIfFirst: true,
42 });
43 if (!made.ok) throw new Error(made.error);
44 alice = made.value;
45 const repo = await createRepo(app, alice, { name: "harbor", visibility: "public" });
46 if (!repo.ok) throw new Error("repo");
47 const issue = openIssue(app, alice, repo.value, { title: "Pick someone" });
48 if (!issue.ok) throw new Error(issue.error);
49 number = issue.value.number;
50 }, 30_000);
51 afterAll(async () => {
52 servers.stop();
53 app.close();
54 await rm(dir, { recursive: true, force: true });
55 });
56
57 test.skipIf(skip)(
58 "a on an issue page opens Details and puts the caret on Assign to",
59 async () => {
60 if (chromium === undefined)
61 throw new Error("no Chromium starts in this check, so the key is not pressed: the check's image must carry one (FORGE_CHROMIUM)");
62 const out = JSON.parse(
63 await evaluateLoaded(
64 chromium,
65 `${servers.url}/alice/harbor/issues/${String(number)}`,
66 { width: 1280, height: 900 },
67 [{ name: "forge_session", value: createSession(app.db, alice.id).token }],
68 `(async () => {
69 const label = document.querySelector('[data-shortcut="a"]');
70 const before = label?.closest("details")?.open ?? null;
71 document.dispatchEvent(new KeyboardEvent("keydown", { key: "a", bubbles: true, cancelable: true }));
72 await new Promise((r) => requestAnimationFrame(() => requestAnimationFrame(r)));
73 return JSON.stringify({ before, open: label?.closest("details")?.open ?? null, active: document.activeElement?.id ?? "" });
74 })()`,
75 ),
76 ) as { before: boolean | null; open: boolean | null; active: string };
77 expect(out.before).toBe(false);
78 expect(out.open).toBe(true);
79 expect(out.active).toBe("f-assignee");
80 },
81 30_000,
82 );

Search
↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs