Files
thedotmack--claude-mem/tests/server/agent-event-platform-source.test.ts
wehub-resource-sync f9447f8e5f
CI / typecheck · build · test · bundle-size (push) Failing after 1s
CI / clean-room dependency closure smoke (push) Failing after 1s
CI / server-runtime e2e (docker · pg + valkey) (push) Failing after 2s
Deploy Install Scripts / deploy (push) Failing after 2s
Windows / build (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:07:03 +08:00

43 lines
1.3 KiB
TypeScript

// SPDX-License-Identifier: Apache-2.0
//
// #2560 — platform_source threading + idempotent Postgres migration.
import { describe, expect, it } from 'bun:test';
import { CreateAgentEventSchema, AgentEventSchema } from '../../src/core/schemas/agent-event.js';
describe('agent-event platformSource threading (#2560)', () => {
it('CreateAgentEventSchema preserves platformSource when provided', () => {
const parsed = CreateAgentEventSchema.parse({
projectId: 'proj-1',
sourceType: 'api',
eventType: 'tool_use',
platformSource: 'opencode',
occurredAtEpoch: 1,
});
expect(parsed.platformSource).toBe('opencode');
});
it('defaults platformSource to null when omitted (back-compat)', () => {
const parsed = CreateAgentEventSchema.parse({
projectId: 'proj-1',
sourceType: 'hook',
eventType: 'tool_use',
occurredAtEpoch: 1,
});
expect(parsed.platformSource).toBeNull();
});
it('full AgentEventSchema round-trips platformSource', () => {
const parsed = AgentEventSchema.parse({
id: 'evt-1',
projectId: 'proj-1',
sourceType: 'server',
eventType: 'tool_use',
platformSource: 'claude-code',
occurredAtEpoch: 1,
createdAtEpoch: 2,
});
expect(parsed.platformSource).toBe('claude-code');
});
});