test(hopper): fix fixture context and cleanup assumptions

This commit is contained in:
morluto
2026-10-14 06:23:08 +08:00
parent 22552525d5
commit cd740a6764
@@ -306,7 +306,7 @@ test.for(["handoff", "not-found"] as const)(
const token = setting("REA_TOKEN");
const runId = setting("REA_RUN_ID");
runtime = dirname(socket);
const lateBridge = async (identity: string, credential = token) => {
const lateBridge = (identity: string, credential = token) => {
const child = spawn(
process.execPath,
[
@@ -318,14 +318,14 @@ test.for(["handoff", "not-found"] as const)(
{ stdio: "ignore" },
);
children.push(child);
await vi.waitFor(() => access(socket));
return child;
};
for (const [identity, credential] of [
["different-run", token],
[runId, "different-token"],
] as const) {
const wrong = await lateBridge(identity, credential);
const wrong = lateBridge(identity, credential);
await vi.waitFor(() => access(socket));
expect(parseMcpToolError(await call("close_binary")).error.code).toBe(
"cleanup_incomplete",
);
@@ -336,7 +336,9 @@ test.for(["handoff", "not-found"] as const)(
}
const closing = call("close_binary");
await delay(150);
const owned = await lateBridge(runId);
// A verified close may remove the socket before the fixture can poll it.
// The successful close and child exit establish the owned bridge outcome.
const owned = lateBridge(runId);
expect((await closing).isError).not.toBe(true);
await vi.waitFor(() => expect(owned.exitCode).toBe(0));
await expect(access(runtime)).rejects.toMatchObject({ code: "ENOENT" });