Public: anyone can read this; the crew can change it.
Full suite red: test/tui-hooks.test.ts #12858
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/12837-full-suite-red-test-tui-hooks-test-ts → main 2 commits fork
1 file
changed +29
−6
test/tui-hooks.test.ts +29 −6
| @@ -65,10 +65,23 @@ function open(user: User, at: Repo = repo) { | ||
| 65 | 65 | frames, |
| 66 | 66 | text, |
| 67 | 67 | 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 = ""; | |
| 70 | 75 | 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; | |
| 71 | 83 | } |
| 84 | await flush(); | |
| 72 | 85 | }, |
| 73 | 86 | stop: () => tui.stop?.(), |
| 74 | 87 | }; |
| @@ -191,19 +204,29 @@ describe("webhooks in the terminal", () => { | ||
| 191 | 204 | h.stop(); |
| 192 | 205 | }); |
| 193 | 206 | |
| 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 () => { | |
| 195 | 208 | const before = listWebhooks(app.db, repo.id).length; |
| 196 | let h = open(alice); | |
| 209 | const h = open(alice); | |
| 197 | 210 | await palette(h); |
| 198 | 211 | await h.feed("a", "https://example.com/" + "x".repeat(2040), "enter"); |
| 199 | 212 | expect(h.text()).toContain("url is text of at most 2048 characters"); |
| 213 | expect(listWebhooks(app.db, repo.id).length).toBe(before); | |
| 200 | 214 | 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); | |
| 202 | 220 | await palette(h); |
| 203 | 221 | await h.feed("a", ..."https://example.com/k", "enter", "k".repeat(201), "enter"); |
| 204 | 222 | expect(h.text()).toContain("kinds is text of at most 200 characters"); |
| 223 | expect(listWebhooks(app.db, repo.id).length).toBe(before); | |
| 205 | 224 | 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); | |
| 207 | 230 | await palette(h); |
| 208 | 231 | await h.feed("a", ..."https://example.com/s", "enter", "enter", "s".repeat(201), "enter"); |
| 209 | 232 | expect(h.text()).toContain("secret is required: 16 to 200 characters"); |
new above
offline