60 lines
2.4 KiB
TypeScript
60 lines
2.4 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import transcriptArtifact from '../fixtures/ecosystem/phase1/transcript-artifact.json' with { type: 'json' };
|
|
import noteArtifact from '../fixtures/ecosystem/phase1/note-artifact.json' with { type: 'json' };
|
|
import memoryArtifact from '../fixtures/ecosystem/phase1/memory-artifact.json' with { type: 'json' };
|
|
import captureTranscriptCreatedEvent from '../fixtures/ecosystem/phase1/capture-transcript-created.event.json' with { type: 'json' };
|
|
import artifactCreatedEvent from '../fixtures/ecosystem/phase1/artifact-created.event.json' with { type: 'json' };
|
|
import artifactLinkedEvent from '../fixtures/ecosystem/phase1/artifact-linked.event.json' with { type: 'json' };
|
|
import memoryEntryCreatedEvent from '../fixtures/ecosystem/phase1/memory-entry-created.event.json' with { type: 'json' };
|
|
import {
|
|
Phase1ArtifactEnvelopeSchema,
|
|
Phase1EcosystemEventSchema,
|
|
Phase1EcosystemEventSchemas,
|
|
} from './ecosystem.js';
|
|
|
|
describe('phase1 ecosystem contracts', () => {
|
|
it('validates canonical transcript, note, and memory artifacts', () => {
|
|
const transcript = Phase1ArtifactEnvelopeSchema.parse(transcriptArtifact);
|
|
const note = Phase1ArtifactEnvelopeSchema.parse(noteArtifact);
|
|
const memory = Phase1ArtifactEnvelopeSchema.parse(memoryArtifact);
|
|
|
|
expect(transcript.artifactType).toBe('transcript');
|
|
expect(note.links).toContainEqual({
|
|
relation: 'summarizes',
|
|
targetArtifactId: transcript.id,
|
|
});
|
|
expect(memory.links).toEqual(
|
|
expect.arrayContaining([
|
|
{
|
|
relation: 'generated-memory',
|
|
targetArtifactId: note.id,
|
|
},
|
|
])
|
|
);
|
|
});
|
|
|
|
it('validates canonical phase1 events', () => {
|
|
const events = [
|
|
captureTranscriptCreatedEvent,
|
|
artifactCreatedEvent,
|
|
artifactLinkedEvent,
|
|
memoryEntryCreatedEvent,
|
|
].map(event => Phase1EcosystemEventSchema.parse(event));
|
|
|
|
expect(events.map(event => event.eventName)).toEqual([
|
|
'capture.transcript.created',
|
|
'artifact.created',
|
|
'artifact.linked',
|
|
'memory.entry.created',
|
|
]);
|
|
});
|
|
|
|
it('exposes event-specific schemas keyed by canonical event name', () => {
|
|
const created = Phase1EcosystemEventSchemas['artifact.created'].parse(artifactCreatedEvent);
|
|
const linked = Phase1EcosystemEventSchemas['artifact.linked'].parse(artifactLinkedEvent);
|
|
|
|
expect(created.payload.artifactType).toBe('note');
|
|
expect(linked.payload.relation).toBe('summarizes');
|
|
});
|
|
});
|