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

opened this

Merged 15h 18m ago, live in production

fix/tui-mirror-set-cpu → main 0 commits

  • Merged. fix/tui-mirror-set-cpu was merged into main as 14e705d.

Review

Sign in to review this change.
1 file changed +35 −6
test/tui-mirror-set.test.ts +35 −6
@@ -5,6 +5,7 @@ import { tmpdir } from "node:os";
55 import { join } from "node:path";
66 import { createApp, type App as Forge } from "../src/app.ts";
77 import { createUser, getUserByName } from "../src/core/users.ts";
8 import { forgetMirror, saveMirror } from "../src/actions/mirror.ts";
89 import { mirrorSealedSet } from "../src/snapshot/mirror.ts";
910 import { startSnapshots, type SnapshotsHandle } from "../src/snapshot/service.ts";
1011 import { dirStore } from "../src/blob/store.ts";
@@ -86,6 +87,13 @@ describe("mirror in the terminal", () => {
8687 });
8788 if (!made.ok) throw new Error(made.error);
8889 }
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;
8997 });
9098 afterAll(async () => {
9199 await svc.stop();
@@ -93,7 +101,19 @@ describe("mirror in the terminal", () => {
93101 await rm(dataDir, { recursive: true, force: true });
94102 });
95103
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;
97117 const h = boot("alice");
98118 await open(h);
99119 expect(h.text()).toContain("Mirror: none.");
@@ -110,6 +130,19 @@ describe("mirror in the terminal", () => {
110130 expect(h.text()).toContain("Mirror sealed");
111131 expect(h.text()).toContain("mirror"); // the place: the local directory
112132 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.");
113146
114147 // Blank everywhere but the bucket: the sealed keys stay.
115148 await h.press("m");
@@ -139,11 +172,7 @@ describe("mirror in the terminal", () => {
139172 expect(mirrorSealedSet(forge.db)).toEqual([]);
140173 expect(h.text()).toContain("Mirror: none.");
141174 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);
147176 });
148177
149178 test("an admin who is not a person opens Resilience but is offered no M or F", async () => {

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

Keyboard shortcuts

Docs