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

Full suite red: test/tui-hooks.test.ts #12858

Merged opened this in answer to

Check · Review · Land · Live done — Landed and live in production.

Merged

scout/forge:scout/12837-full-suite-red-test-tui-hooks-test-ts → main 2 commits fork

  • Merged. scout/12837-full-suite-red-test-tui-hooks-test-ts was merged into main as 9740163.

Review

Sign in to review this change.
1 file changed +29 −6
test/tui-hooks.test.ts +29 −6
@@ -65,10 +65,23 @@ function open(user: User, at: Repo = repo) {
6565 frames,
6666 text,
6767 feed: async (...keys: string[]) => {
68 for (const k of keys) {
69 terminal.feed(KEYS[k] ?? k);
68 // Plain characters go in as one burst and settle once: settling per
69 // character is what made typing a 29-character secret cost a second.
70 let run = "";
71 const flush = async (): Promise<void> => {
72 if (run === "") return;
73 terminal.feed(run);
74 run = "";
7075 await settleApp(tui);
76 };
77 for (const k of keys) {
78 if (k in KEYS) {
79 await flush();
80 terminal.feed(KEYS[k]!);
81 await settleApp(tui);
82 } else run += k;
7183 }
84 await flush();
7285 },
7386 stop: () => tui.stop?.(),
7487 };
@@ -191,19 +204,29 @@ describe("webhooks in the terminal", () => {
191204 h.stop();
192205 });
193206
194 test("a url, kinds or secret over its length is refused and nothing is added", async () => {
207 test("a url over its length is refused and nothing is added", async () => {
195208 const before = listWebhooks(app.db, repo.id).length;
196 let h = open(alice);
209 const h = open(alice);
197210 await palette(h);
198211 await h.feed("a", "https://example.com/" + "x".repeat(2040), "enter");
199212 expect(h.text()).toContain("url is text of at most 2048 characters");
213 expect(listWebhooks(app.db, repo.id).length).toBe(before);
200214 h.stop();
201 h = open(alice);
215 });
216
217 test("kinds over its length is refused and nothing is added", async () => {
218 const before = listWebhooks(app.db, repo.id).length;
219 const h = open(alice);
202220 await palette(h);
203221 await h.feed("a", ..."https://example.com/k", "enter", "k".repeat(201), "enter");
204222 expect(h.text()).toContain("kinds is text of at most 200 characters");
223 expect(listWebhooks(app.db, repo.id).length).toBe(before);
205224 h.stop();
206 h = open(alice);
225 });
226
227 test("a secret over its length is refused and never echoed", async () => {
228 const before = listWebhooks(app.db, repo.id).length;
229 const h = open(alice);
207230 await palette(h);
208231 await h.feed("a", ..."https://example.com/s", "enter", "enter", "s".repeat(201), "enter");
209232 expect(h.text()).toContain("secret is required: 16 to 200 characters");

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs