// tests/lib/profile-flag-coverage.test.mjs
// SC #4 (docs side): every command file must document --profile + VOYAGE_PROFILE.
// /trekcontinue.md must additionally describe profile-arv (inheritance) policy.

import { test } from 'node:test';
import { strict as assert } from 'node:assert';
import { readFileSync } from 'node:fs';
import { join, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';

const __dirname = dirname(fileURLToPath(import.meta.url));
const COMMANDS_DIR = join(__dirname, '..', '..', 'commands');

const COMMAND_FILES = [
  'trekbrief.md',
  'trekresearch.md',
  'trekplan.md',
  'trekexecute.md',
  'trekreview.md',
  'trekcontinue.md',
];

for (const filename of COMMAND_FILES) {
  test(`${filename} documents --profile flag`, () => {
    const content = readFileSync(join(COMMANDS_DIR, filename), 'utf-8');
    assert.match(content, /--profile/,
      `${filename} must contain --profile flag documentation`);
  });

  test(`${filename} mentions VOYAGE_PROFILE env-var`, () => {
    const content = readFileSync(join(COMMANDS_DIR, filename), 'utf-8');
    assert.match(content, /VOYAGE_PROFILE/,
      `${filename} must mention VOYAGE_PROFILE env-var (resolution order)`);
  });
}

test('trekcontinue.md documents inheritance policy (profile arves fra plan-frontmatter)', () => {
  const content = readFileSync(join(COMMANDS_DIR, 'trekcontinue.md'), 'utf-8');
  assert.match(content, /inheritance/,
    'trekcontinue.md must describe profile-arv (inheritance) policy from plan-frontmatter');
});
