Open History to see the last commit
1import { afterAll, describe, expect } from 'vitest'
2import { composePersistence, memoryPersistence } from '../src'
3import { runPersistenceConformance } from '../src/testkit/conformance'
4import type { RunnerTask, RunnerTestCase } from 'vitest'
5
6// A store that is absent and declared in `skip` must report its cases as
7// skipped. A case that returns early without `ctx.skip` reports a pass that
8// asserted nothing.
9const OMITTED_STORES = ['activities', 'generationRuns', 'artifacts', 'blobs']
10
11function collectCases(task: RunnerTask): Array<RunnerTestCase> {
12 if (task.type === 'test') return [task]
13 return task.tasks.flatMap(collectCases)
14}
15
16describe('conformance reporting for omitted stores', () => {
17 runPersistenceConformance(
18 'chat-only',
19 () =>
20 composePersistence(memoryPersistence(), {
21 overrides: {
22 activities: false,
23 generationRuns: false,
24 artifacts: false,
25 blobs: false,
26 },
27 }),
28 { skip: ['activities', 'generationRuns', 'artifacts', 'blobs'] },
29 )
30
31 // vitest requires a destructuring pattern as the first hook argument.
32 // eslint-disable-next-line no-empty-pattern
33 afterAll(({}, suite) => {
34 const omittedCases = suite.tasks
35 .flatMap(collectCases)
36 .filter((testCase) => OMITTED_STORES.includes(testCase.suite?.name ?? ''))
37
38 expect(omittedCases.length).toBeGreaterThan(0)
39 for (const testCase of omittedCases) {
40 expect(testCase.result?.state, testCase.name).toBe('skip')
41 }
42 })
43})