Files
learnharness/tests/completion.test.ts
T
amosblomqvist 4f4b5643d4 test: await completed ChatGPT sign-in and consent saves
Replace arbitrary event-loop budgets in two release-gate tests with fresh per-attempt sign-in notifications and the actual consent control reply, bounded by a clear watchdog. Retain all final-state assertions and explicitly verify successful connected/error-free completion.

Controlled token/save gates demonstrate both old 100-turn waits return before completion; the corrected waits remain pending and retain the final persistence/UI assertions after release. Add small watchdog result/error/timeout tests. No production, workflow or dependency changes.

Isolated checks: focused 87/87, full suite once 2517/2517, full ESLint and typecheck. The full run preceded three runtime-erased non-null array-index annotations; focused tests/typecheck/full ESLint passed again on final source.
2026-10-27 23:44:48 +02:00

17 lines
747 B
TypeScript

import assert from "node:assert/strict";
import { test } from "node:test";
import { completedWithin } from "./completion.ts";
test("fixture completion wait returns its result and preserves its actual error", async () => {
assert.equal(await completedWithin(Promise.resolve("saved"), "fixture save"), "saved");
const failure = new Error("fixture persistence failed");
await assert.rejects(completedWithin(Promise.reject(failure), "fixture save"), (error) => error === failure);
});
test("fixture completion wait fails clearly if completion never arrives", async () => {
await assert.rejects(
completedWithin(new Promise<never>(() => {}), "verified fixture sign-in", 0),
/Timed out after 0ms waiting for verified fixture sign-in/,
);
});