import assert from 'node:assert/strict';
import test from 'node:test';
import { readFile, access } from 'node:fs/promises';
import { join, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
const root=fileURLToPath(new URL('../dist/client/',import.meta.url));
test('VPS static export contains the product and working controls',async()=>{
  const html=await readFile(join(root,'index.html'),'utf8');
  for(const marker of ["Backplane", "LIVE CONTROL-PLANE SANDBOX", "The model stays frozen", "Seven diligence gates"])assert.ok(html.toLowerCase().includes(marker.toLowerCase()),marker);
  assert.match(html,/application\/ld\+json/);
  assert.match(html,/justin@cyberelf\.link/);
  assert.doesNotMatch(html,/Your site is taking shape|codex-preview/);
});
test('every emitted local script and stylesheet exists in the deployment root',async()=>{
  const html=await readFile(join(root,'index.html'),'utf8');
  for(const match of html.matchAll(/(?:src|href)="(\/[^"?#]+\.(?:js|css))[^" ]*"/g)){
    const target=resolve(root,'.'+match[1]);
    assert.ok(target.startsWith(resolve(root)));await access(target);
  }
});
