import test from 'node:test';
import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';

const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
test('production package contains protected product and landing page', () => {
  assert.ok(fs.statSync(path.join(ROOT, 'private', 'First-Time-Marloth-Kruger-International-Visitors-Companion-V1.0.pdf')).size > 1_000_000);
  assert.ok(fs.existsSync(path.join(ROOT, 'public', 'index.html')));
  assert.ok(fs.existsSync(path.join(ROOT, 'public', 'assets', 'hero-giraffes.webp')));
});
test('companion price and sku are fixed server-side', async () => {
  process.env.NODE_ENV = 'test'; process.env.PAYPAL_ENV = 'mock'; process.env.ALLOW_MOCK_PAYPAL = 'true';
  const { config } = await import('../src/config.js');
  assert.equal(config.product.price, '14.99');
  assert.equal(config.product.currency, 'USD');
  assert.equal(config.product.sku, 'MPC-COMPANION-V1');
});
