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

describe('phase 9 api contract', () => {
  it('documents WHMCS integration routes and billing suspension', () => {
    const whmcsSource = readFileSync(
      join(process.cwd(), 'src', 'integrations/whmcs/whmcs-integration.controller.ts'),
      'utf8',
    );
    assert.ok(whmcsSource.includes("'integrations/whmcs'"));
    assert.ok(whmcsSource.includes("'services/:externalServiceId/suspend'"));
    assert.ok(whmcsSource.includes('WhmcsIntegrationGuard'));

    const billingSource = readFileSync(
      join(process.cwd(), 'src', 'billing/billing.service.ts'),
      'utf8',
    );
    assert.ok(billingSource.includes('isWhmcsBilling'));

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