import test from 'node:test';
import assert from 'node:assert';
import { safeImport } from '../_helpers/path.js';
import { AutoReporter } from '../reporters/AutoReporter.js';

const EXPECTED = {
  'LLMManager': [['callModel','invoke','run']],
  'selective-enhancement/SelectiveUtils': [['analyzeTechnicalQuality','analyze','run']],
  'ElementExtraction': [['extractElements','extract','run']],
  'ContentAssembly': [['assembleArticle','assemble','render']],
  'selective-enhancement/SelectiveCore': [['applySelectiveLayer','enhance','run']],
  'MissingKeywords': [['fillMissingKeywords','complete','run']],
  'ArticleStorage': [['workKey','makeKey','keyOf']],
  'DigitalOceanWorkflow': [['deployArticle','deploy','publish']],
  'Main': [['run','main','start']],
  'ManualTrigger': [['main','run','start']],
  'Utils': [[]],
  'trace-wrap': [[]]
};

for (const [name, variants] of Object.entries(EXPECTED)) {

// Auto-Reporter Configuration
const autoReporter = new AutoReporter();

  test(`Module ${name}: exists and has expected exports (soft)`, async () => {
    const res = await safeImport(name);
    if (!res.ok) { console.warn(`[SKIP] ${name}: ${res.reason}`); return; }
    const mod = res.mod;

    for (const group of variants) {
      if (group.length === 0) continue;
      const found = group.find(fn => typeof mod[fn] === 'function');
      if (!found) {
        console.warn(`[SKIP] ${name}: none of [${group.join(', ')}] found`);
      }
    }
  });
}
