test: fix CI flakes and registry test API

This commit is contained in:
Peter Steinberger
2026-03-31 19:20:07 +01:00
parent b7013ec207
commit 0abd143d37
3 changed files with 36 additions and 33 deletions

View File

@@ -58,7 +58,7 @@ function resolveTemplateModelId(modelId: string) {
}
function createTemplateModelRegistry(modelId: string): ModelRegistry {
const registry = new ModelRegistry(AuthStorage.inMemory());
const registry = ModelRegistry.inMemory(AuthStorage.inMemory());
const template = getModel("openai", resolveTemplateModelId(modelId));
registry.registerProvider("openai", {
apiKey: "test",

View File

@@ -41,7 +41,7 @@ describeLive("openrouter plugin live", () => {
const resolved = provider.resolveDynamicModel?.({
provider: "openrouter",
modelId: LIVE_MODEL_ID,
modelRegistry: new ModelRegistry(AuthStorage.inMemory()),
modelRegistry: ModelRegistry.inMemory(AuthStorage.inMemory()),
});
if (!resolved) {
throw new Error(`openrouter provider did not resolve ${LIVE_MODEL_ID}`);

View File

@@ -17,7 +17,7 @@ afterEach(() => {
describe("test planner executor", () => {
it("falls back to child exit when close never arrives", async () => {
vi.useRealTimers();
vi.useFakeTimers();
const stdout = new PassThrough();
const stderr = new PassThrough();
const fakeChild = Object.assign(new EventEmitter(), {
@@ -47,6 +47,7 @@ describe("test planner executor", () => {
},
);
await vi.runAllTimersAsync();
await expect(executePromise).resolves.toMatchObject({
exitCode: 0,
summary: {
@@ -59,7 +60,7 @@ describe("test planner executor", () => {
});
it("collects failures across planned units when failure policy is collect-all", async () => {
vi.useRealTimers();
vi.useFakeTimers();
const children = [1, 2].map((pid, index) => {
const stdout = new PassThrough();
const stderr = new PassThrough();
@@ -87,7 +88,7 @@ describe("test planner executor", () => {
return child;
});
const artifacts = createExecutionArtifacts({});
const report = await executePlan(
const reportPromise = executePlan(
{
failurePolicy: "collect-all",
passthroughMetadataOnly: false,
@@ -114,6 +115,8 @@ describe("test planner executor", () => {
spawn: spawnMock,
},
);
await vi.runAllTimersAsync();
const report = await reportPromise;
expect(spawnMock).toHaveBeenCalledTimes(2);
expect(report.exitCode).toBe(1);
@@ -128,7 +131,7 @@ describe("test planner executor", () => {
});
it("injects a valid localstorage file path into child NODE_OPTIONS", async () => {
vi.useRealTimers();
vi.useFakeTimers();
const stdout = new PassThrough();
const stderr = new PassThrough();
const fakeChild = Object.assign(new EventEmitter(), {
@@ -149,34 +152,34 @@ describe("test planner executor", () => {
const artifacts = createExecutionArtifacts({
NODE_OPTIONS: "--max_old_space_size=4096 --localstorage-file",
});
await expect(
executePlan(
{
failurePolicy: "fail-fast",
passthroughMetadataOnly: false,
passthroughOptionArgs: [],
targetedUnits: [],
parallelUnits: [{ id: "unit-a", args: ["vitest", "run", "src/alpha.test.ts"] }],
serialUnits: [],
serialPrefixUnits: [],
shardCount: 1,
shardIndexOverride: null,
topLevelSingleShardAssignments: new Map(),
runtimeCapabilities: { isWindowsCi: false, isCI: false, isWindows: false },
topLevelParallelEnabled: false,
topLevelParallelLimit: 1,
deferredRunConcurrency: 1,
passthroughRequiresSingleRun: false,
const executePromise = executePlan(
{
failurePolicy: "fail-fast",
passthroughMetadataOnly: false,
passthroughOptionArgs: [],
targetedUnits: [],
parallelUnits: [{ id: "unit-a", args: ["vitest", "run", "src/alpha.test.ts"] }],
serialUnits: [],
serialPrefixUnits: [],
shardCount: 1,
shardIndexOverride: null,
topLevelSingleShardAssignments: new Map(),
runtimeCapabilities: { isWindowsCi: false, isCI: false, isWindows: false },
topLevelParallelEnabled: false,
topLevelParallelLimit: 1,
deferredRunConcurrency: 1,
passthroughRequiresSingleRun: false,
},
{
env: {
NODE_OPTIONS: "--max_old_space_size=4096 --localstorage-file",
},
{
env: {
NODE_OPTIONS: "--max_old_space_size=4096 --localstorage-file",
},
artifacts,
spawn: spawnMock,
},
),
).resolves.toMatchObject({
artifacts,
spawn: spawnMock,
},
);
await vi.runAllTimersAsync();
await expect(executePromise).resolves.toMatchObject({
exitCode: 0,
});