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

describe('whmcs addon module contract', () => {
  it('documents addon dashboard API and PHP module', () => {
    const controller = readFileSync(
      join(process.cwd(), 'src', 'integrations/whmcs/whmcs-integration.controller.ts'),
      'utf8',
    );
    assert.ok(controller.includes("'dashboard/stats'"));

    const addonMain = readFileSync(
      join(process.cwd(), '..', '..', 'integrations/whmcs/modules/addons/hexagamecloud/hexagamecloud.php'),
      'utf8',
    );
    assert.ok(addonMain.includes('hexagamecloud_config'));
    assert.ok(addonMain.includes('hexagamecloud_page_dashboard'));
    assert.ok(addonMain.includes('HexaGameCloudEventPoller'));
  });
});

describe('stripe fallback contract', () => {
  it('documents optional stripe webhook and billing provider', () => {
    const provider = readFileSync(
      join(process.cwd(), 'src', 'billing/billing-provider.ts'),
      'utf8',
    );
    assert.ok(provider.includes('isExternalBilling'));
    assert.ok(provider.includes("'stripe'"));

    const webhook = readFileSync(
      join(process.cwd(), 'src', 'billing/stripe/stripe-webhook.service.ts'),
      'utf8',
    );
    assert.ok(webhook.includes('isStripeBilling'));
    assert.ok(webhook.includes('ignored'));
  });
});
