import assert from 'node:assert/strict';
import test from 'node:test';

import { summarizeConsistencyResult, type ConsistencyResult } from './consistency-api';

test('summarizeConsistencyResult counts ok warn and error checks', () => {
  const result: ConsistencyResult = {
    generatedAt: '2026-07-08T08:00:00.000Z',
    status: 'fail',
    counts: { products: 1 },
    checks: {
      partitionKeys: [{ id: 'p', label: 'p', severity: 'ok', count: 0, message: 'ok' }],
      orphanReferences: [{ id: 'o', label: 'o', severity: 'error', count: 2, message: 'bad' }],
      auditCoverage: [{ id: 'a', label: 'a', severity: 'warn', count: 0, message: 'missing' }],
    },
    summary: { errors: 1, warnings: 1, human: 'summary' },
  };

  assert.deepEqual(summarizeConsistencyResult(result), {
    ok: 1,
    warn: 1,
    error: 1,
    total: 3,
  });
});
