import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import test from 'node:test';

test('V2.5 admin pages are routed, guarded, and visible through permissions', () => {
  const auditPage = readFileSync('app/admin/audit/page.tsx', 'utf8');
  const consistencyPage = readFileSync('app/admin/consistency/page.tsx', 'utf8');
  const sidebar = readFileSync('components/layout/Sidebar.tsx', 'utf8');
  const permissions = readFileSync('lib/permissions.ts', 'utf8');

  assert.match(auditPage, /RouteGuard permission="audit:view"/);
  assert.match(consistencyPage, /RouteGuard permission="consistency:view"/);
  assert.ok(sidebar.includes("path: '/admin/audit'"));
  assert.ok(sidebar.includes("path: '/admin/consistency'"));
  assert.match(permissions, /permission: 'audit:view'/);
  assert.match(permissions, /permission: 'consistency:view'/);
});
