a1f46646ee
Task 9.4: certifyProvider runs the P9 conformance checklist a provider must pass before backing a channel — declares explicit capabilities, returns providerRef + recognized outcome (never throws), repeatable/idempotent, tolerates empty payload. 2 tests: SandboxProvider passes; a throwing/no-capability provider fails with the specific failing checks listed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
28 lines
1.2 KiB
TypeScript
28 lines
1.2 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import type { CapabilityProvider, CapabilityRequest, ProviderResult } from '@insignia/iios-contracts';
|
|
import { certifyProvider } from './capability.certification';
|
|
import { SandboxProvider } from './sandbox.provider';
|
|
|
|
describe('adapter certification checklist (P9)', () => {
|
|
it('SandboxProvider passes certification', async () => {
|
|
const report = await certifyProvider(new SandboxProvider(['WEBHOOK']));
|
|
expect(report.passed).toBe(true);
|
|
expect(report.checks.every((c) => c.ok)).toBe(true);
|
|
});
|
|
|
|
it('a broken provider fails with the specific failing checks', async () => {
|
|
const broken: CapabilityProvider = {
|
|
name: 'broken',
|
|
channelTypes: [], // no declared channels
|
|
capabilities: { canSend: false },
|
|
async send(_req: CapabilityRequest): Promise<ProviderResult> {
|
|
throw new Error('kaboom'); // throws instead of returning FAILED
|
|
},
|
|
};
|
|
const report = await certifyProvider(broken);
|
|
expect(report.passed).toBe(false);
|
|
expect(report.checks.find((c) => c.name === 'declares-capabilities')?.ok).toBe(false);
|
|
expect(report.checks.find((c) => c.name === 'returns-providerRef-and-outcome')?.ok).toBe(false);
|
|
});
|
|
});
|