import { describe, it } from 'node:test';
import assert from 'node:assert/strict';
import { readFileSync } from 'node:fs';
import { join } from 'node:path';

describe('phase 8 api contract', () => {
  it('documents internal edge routes and join fields', () => {
    const edgeSource = readFileSync(
      join(process.cwd(), 'src', 'edge/edge.controller.ts'),
      'utf8',
    );
    assert.ok(edgeSource.includes("'resolve/:slug'"));
    assert.ok(edgeSource.includes("'start/:slug'"));
    assert.ok(edgeSource.includes('EdgeInternalGuard'));

    const edgeServiceSource = readFileSync(
      join(process.cwd(), 'src', 'edge/edge.service.ts'),
      'utf8',
    );
    assert.ok(edgeServiceSource.includes('requestJoinStart'));
    assert.ok(edgeServiceSource.includes('checkStartRateLimit'));

    const serversSource = readFileSync(
      join(process.cwd(), 'src', 'servers/servers.service.ts'),
      'utf8',
    );
    assert.ok(serversSource.includes('startServerInternal'));
    assert.ok(serversSource.includes('joinHostname'));
  });
});
