Public: anyone can read this; the crew can change it.
The terminal mirror test pays its first boot in the hook and runs as two tests, each under the 2 s CPU budget #17571
Merged 15h 18m ago, live in production
fix/tui-mirror-set-cpu → main 0 commits
1 file
changed +35
−6
test/tui-mirror-set.test.ts +35 −6
| @@ -5,6 +5,7 @@ import { tmpdir } from "node:os"; | ||
| 5 | 5 | import { join } from "node:path"; |
| 6 | 6 | import { createApp, type App as Forge } from "../src/app.ts"; |
| 7 | 7 | import { createUser, getUserByName } from "../src/core/users.ts"; |
| 8 | import { forgetMirror, saveMirror } from "../src/actions/mirror.ts"; | |
| 8 | 9 | import { mirrorSealedSet } from "../src/snapshot/mirror.ts"; |
| 9 | 10 | import { startSnapshots, type SnapshotsHandle } from "../src/snapshot/service.ts"; |
| 10 | 11 | import { dirStore } from "../src/blob/store.ts"; |
| @@ -86,6 +87,13 @@ describe("mirror in the terminal", () => { | ||
| 86 | 87 | }); |
| 87 | 88 | if (!made.ok) throw new Error(made.error); |
| 88 | 89 | } |
| 90 | // The terminal's first boot in a process loads its root, palette and screens (#17496): the | |
| 91 | // file's cost, paid here, not by the first test to boot (each test is held to 2 s of CPU; a | |
| 92 | // check runner measured 3.9 s for the first, 2026-12-02). Nothing is sealed or changed. | |
| 93 | const warm = boot("alice"); | |
| 94 | await open(warm); | |
| 95 | warm.stop(); | |
| 96 | frames.length = 0; | |
| 89 | 97 | }); |
| 90 | 98 | afterAll(async () => { |
| 91 | 99 | await svc.stop(); |
| @@ -93,7 +101,19 @@ describe("mirror in the terminal", () => { | ||
| 93 | 101 | await rm(dataDir, { recursive: true, force: true }); |
| 94 | 102 | }); |
| 95 | 103 | |
| 96 | test("seal, read back without a key, keep a sealed key on a blank field, forget", async () => { | |
| 104 | /** Nothing the terminal drew since `from` shows the secret or the access key. */ | |
| 105 | const noKeyDrawn = (from: number): void => { | |
| 106 | for (const frame of frames.slice(from)) { | |
| 107 | expect(frame).not.toContain(SECRET); | |
| 108 | expect(frame).not.toContain(ACCESS); | |
| 109 | } | |
| 110 | }; | |
| 111 | ||
| 112 | // Two tests, each from its own state (2 s of CPU each; the one test they were took 3.9 s on a | |
| 113 | // check runner, 2026-12-02): sealing through the terminal, then what a sealed mirror does there. | |
| 114 | test("seal through the terminal, read back without a key", async () => { | |
| 115 | forgetMirror(forge, getUserByName(forge.db, "alice")); | |
| 116 | const from = frames.length; | |
| 97 | 117 | const h = boot("alice"); |
| 98 | 118 | await open(h); |
| 99 | 119 | expect(h.text()).toContain("Mirror: none."); |
| @@ -110,6 +130,19 @@ describe("mirror in the terminal", () => { | ||
| 110 | 130 | expect(h.text()).toContain("Mirror sealed"); |
| 111 | 131 | expect(h.text()).toContain("mirror"); // the place: the local directory |
| 112 | 132 | expect(h.text()).not.toContain("Mirror: none."); |
| 133 | h.stop(); | |
| 134 | noKeyDrawn(from); | |
| 135 | }); | |
| 136 | ||
| 137 | test("a sealed mirror keeps its keys on blank fields, names a refused field, and forgets on the second choice", async () => { | |
| 138 | const alice = getUserByName(forge.db, "alice"); | |
| 139 | const sealed = saveMirror(forge, alice, { endpoint: "http://s3.example.test", bucket: "offbox-copy", region: "", accessKey: ACCESS, secretKey: SECRET }); | |
| 140 | expect(sealed.ok).toBe(true); | |
| 141 | expect(mirrorSealedSet(forge.db).length).toBe(4); | |
| 142 | const from = frames.length; | |
| 143 | const h = boot("alice"); | |
| 144 | await open(h); | |
| 145 | expect(h.text()).not.toContain("Mirror: none."); | |
| 113 | 146 | |
| 114 | 147 | // Blank everywhere but the bucket: the sealed keys stay. |
| 115 | 148 | await h.press("m"); |
| @@ -139,11 +172,7 @@ describe("mirror in the terminal", () => { | ||
| 139 | 172 | expect(mirrorSealedSet(forge.db)).toEqual([]); |
| 140 | 173 | expect(h.text()).toContain("Mirror: none."); |
| 141 | 174 | h.stop(); |
| 142 | ||
| 143 | for (const frame of frames) { | |
| 144 | expect(frame).not.toContain(SECRET); | |
| 145 | expect(frame).not.toContain(ACCESS); | |
| 146 | } | |
| 175 | noKeyDrawn(from); | |
| 147 | 176 | }); |
| 148 | 177 | |
| 149 | 178 | test("an admin who is not a person opens Resilience but is offered no M or F", async () => { |
new above
offline