import assert from 'node:assert/strict';
import test from 'node:test';

import { assertFileExists, readText } from './helpers.ts';

test('setup resume APIs exist', () => {
  for (const route of ['current', 'start', 'steps', 'complete', 'report']) {
    assertFileExists(`src/app/api/setup/run/${route}/route.ts`);
  }

  assertFileExists('src/app/api/setup/bootstrap/run/current/route.ts');
  assertFileExists('src/features/setup/server/setup-state.service.ts');
});

test('setup wizard refreshes run state after configured-folder import', () => {
  const wizard = readText('src/features/setup/components/setup-wizard.tsx');

  assert.match(wizard, /useConfiguredBootstrapCsvPreview/);
  assert.match(wizard, /useConfiguredBootstrapCsvCommit/);
  assert.match(wizard, /setupRunQuery\.refetch/);
  assert.match(wizard, /bootstrapStatusQuery\.refetch/);
  assert.match(wizard, /Mark setup completed/);
});
