MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / run

Function run

e2e/desktop/reset-state.test.ts:36–123  ·  view source on GitHub ↗
(runDir: string)

Source from the content-addressed store, hash-verified

34);
35
36const run = async (runDir: string) => {
37 const home = mkdtempSync(join(tmpdir(), "executor-desktop-e2e-reset-"));
38 const videoTmp = join(runDir, ".video-tmp");
39 let stepIndex = 0;
40
41 const app = await _electron.launch({
42 executablePath: electronBinary,
43 args: [appDir],
44 cwd: appDir,
45 env: { ...process.env, HOME: home, EXECUTOR_TEST_AUTO_CONFIRM_RESET: "1" },
46 recordVideo: { dir: videoTmp, size: { width: 1280, height: 800 } },
47 timeout: 120_000,
48 });
49
50 try {
51 const page = await app.firstWindow({ timeout: 120_000 });
52 const step = async (label: string, body: () => Promise<void>) => {
53 await body();
54 stepIndex += 1;
55 const slug = label.toLowerCase().replace(/[^a-z0-9]+/g, "-");
56 await page.screenshot({
57 path: join(runDir, `${String(stepIndex).padStart(2, "0")}-${slug}.png`),
58 });
59 };
60
61 await step("app boots into the web console", async () => {
62 await page.getByText("Settings").first().waitFor({ timeout: 120_000 });
63 });
64
65 await step("the database is corrupted and the server killed", async () => {
66 const manifest = JSON.parse(
67 readFileSync(join(home, ".executor/server-control/server.json"), "utf8"),
68 ) as { pid: number };
69 // Corrupt first so the sidecar can never come back on its own, then
70 // kill it to bring up the crash screen.
71 writeFileSync(join(home, ".executor/data.db"), CORRUPT_MARKER);
72 rmSync(join(home, ".executor/data.db-wal"), { force: true });
73 rmSync(join(home, ".executor/data.db-shm"), { force: true });
74 process.kill(manifest.pid, "SIGKILL");
75 await page.getByText("stopped unexpectedly").waitFor({ timeout: 30_000 });
76 });
77
78 await step("restart alone cannot heal a damaged database", async () => {
79 await page.locator("#restart").click();
80 await page.getByText("Restart failed").waitFor({ timeout: 60_000 });
81 });
82
83 await step("reset data backs the state up and heals the app", async () => {
84 await page.locator("#reset").click();
85 await page.getByText("Settings").first().waitFor({ timeout: 120_000 });
86 });
87
88 // Backup-then-move, never delete: the corrupted bytes must live on in
89 // ~/.executor/backups/<stamp>/data.db, and the live db must be fresh.
90 const backupsDir = join(home, ".executor/backups");
91 const stamps = readdirSync(backupsDir);
92 expect(stamps.length, "exactly one backup created").toBe(1);
93 const backedUp = readFileSync(join(backupsDir, stamps[0] ?? "", "data.db"), "utf8");

Callers 1

Calls 4

toStringMethod · 0.80
videoMethod · 0.80
stepFunction · 0.70
closeMethod · 0.65

Tested by

no test coverage detected