Skip to content

Commit 2c1dd39

Browse files
committed
test(runtime): the replayer test's fake loader returns the contract's results array
SeedLoaderResultSchema requires results (one entry per dataset, empty when nothing loaded) and the real loader returns it on every path. The fake answered without it, a shape the producer never produces, so the replayer's hand-off of result.results to the seed-settlement tracker threw on it. Claude-Session: https://claude.ai/code/session_01LFqdRsuM5nkqoJdHd5ztVk Co-authored-by: Claude <noreply@anthropic.com>
1 parent 70a9ae6 commit 2c1dd39

1 file changed

Lines changed: 16 additions & 3 deletions

File tree

‎packages/runtime/src/seed-datasets.test.ts‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,20 @@ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
2525

2626
// ── Part B plumbing: capture what the replayer feeds the seed loader ──────────
2727
let loadCalls: any[] = [];
28-
let seedResult: any = { summary: { totalInserted: 0, totalUpdated: 0, totalSkipped: 0 }, errors: [] };
28+
/**
29+
* What the real `SeedLoaderService.load()` resolves, reduced to the keys AppPlugin
30+
* reads: `summary`, `errors` and `results`. `results` is REQUIRED by the contract
31+
* (`SeedLoaderResultSchema`: one entry per dataset, `[]` when nothing loaded; the real
32+
* loader returns it on every path, the empty one included), and the replayer hands it
33+
* to the seed-settlement tracker (#23354) — a fake without it answers a shape the
34+
* producer never does.
35+
*/
36+
const loaderResult = (summary: { totalInserted: number; totalUpdated: number; totalSkipped: number }) => ({
37+
summary,
38+
errors: [] as unknown[],
39+
results: [] as unknown[],
40+
});
41+
let seedResult: any = loaderResult({ totalInserted: 0, totalUpdated: 0, totalSkipped: 0 });
2942

3043
vi.mock('./seed-loader.js', () => ({
3144
SeedLoaderService: class {
@@ -143,7 +156,7 @@ describe('AppPlugin per-org replayer replays the live union (#3453 seam)', () =>
143156

144157
beforeEach(() => {
145158
loadCalls = [];
146-
seedResult = { summary: { totalInserted: 0, totalUpdated: 0, totalSkipped: 0 }, errors: [] };
159+
seedResult = loaderResult({ totalInserted: 0, totalUpdated: 0, totalSkipped: 0 });
147160
process.env.OS_MULTI_ORG_ENABLED = 'true'; // per-org replay path; skip inline seed
148161
});
149162
afterEach(() => {
@@ -193,7 +206,7 @@ describe('AppPlugin per-org replayer replays the live union (#3453 seam)', () =>
193206
expect(typeof replayer).toBe('function');
194207

195208
// A brand-new org is created → the middleware invokes the replayer.
196-
seedResult = { summary: { totalInserted: 3, totalUpdated: 0, totalSkipped: 0 }, errors: [] };
209+
seedResult = loaderResult({ totalInserted: 3, totalUpdated: 0, totalSkipped: 0 });
197210
const result = await replayer('org_fresh');
198211

199212
// The replayer fed the loader the FULL union in source order — the crux of

0 commit comments

Comments
 (0)