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

import {
  BugStatus,
  DevTaskStatus,
  RequirementStatus,
  TestCaseStatus,
  VersionPlanStatus,
  VersionStatus,
} from '@ftb/shared';

import type { BugStatus as WebBugStatus } from './bug';
import type { DevTaskStatus as WebDevTaskStatus } from './dev-task';
import type { RequirementStatus as WebRequirementStatus } from './requirement';
import type { TestCaseStatus as WebTestCaseStatus } from './test-case';
import type { PlanTaskStatus } from './version-plan';
import type { VersionStatus as WebVersionStatus } from './version-status';

test('shared requirement statuses match the current requirement workflow', () => {
  const shared = Object.values(RequirementStatus);
  const expected: WebRequirementStatus[] = [
    'pending_review',
    'adopted',
    'rejected',
    'planned',
    'developing',
    'testing',
    'released',
    'closed',
  ];

  assert.deepEqual(shared, expected);
});

test('shared execution entity statuses match frontend domain workflows', () => {
  const planStatuses: PlanTaskStatus[] = ['pending', 'in_progress', 'completed'];
  const devTaskStatuses: WebDevTaskStatus[] = ['todo', 'in_progress', 'testing', 'submitted'];
  const testCaseStatuses: WebTestCaseStatus[] = ['pending', 'running', 'passed', 'failed', 'blocked'];
  const bugStatuses: WebBugStatus[] = ['open', 'fixing', 'fixed', 'verifying', 'closed', 'rejected'];
  const versionStatuses: WebVersionStatus[] = ['developing', 'planned', 'released', 'paused', 'closed'];

  assert.deepEqual(Object.values(VersionPlanStatus), planStatuses);
  assert.deepEqual(Object.values(DevTaskStatus), devTaskStatuses);
  assert.deepEqual(Object.values(TestCaseStatus), testCaseStatuses);
  assert.deepEqual(Object.values(BugStatus), bugStatuses);
  assert.deepEqual(Object.values(VersionStatus), versionStatuses);
});
