import { readFile } from 'node:fs/promises'
import { resolve } from 'node:path'

const root = resolve(new URL('..', import.meta.url).pathname)
const report = JSON.parse(await readFile(resolve(root, 'config/chrome-topology-verification.json'), 'utf8'))
if (report.schemaVersion !== 1 || report.browserId !== 'chrome' || report.status !== 'pass' || report.crossOriginIsolated !== true) throw new Error('Chrome topology verification is not passing.')
if (report.capabilities?.status !== 'ready' || report.topology?.faces !== 6 || report.topology?.edges !== 12 || report.topology?.vertices !== 8 || report.topology.analyticFaces !== 6 || report.topology.analyticEdges !== 12 || report.topology.transientIndexFree !== true || report.topology.opfsTopologyRoundTrip !== true || report.topology.adjacencyKeys.length !== 5 || report.topology.adjacencyKeys.some((count) => count === 0)) throw new Error('Chrome topology analytic, adjacency, or OPFS evidence is incomplete.')
console.log(JSON.stringify({ status: 'chrome-topology-verification-pass', counts: report.topology }, null, 2))
