import { describe, expect, it } from 'vitest';
import { platformOperations } from '../api/platform-operations.generated';

const expected = [
  ['GET', '/api/platform/question-banks'],
  ['PUT', '/api/platform/question-banks'],
  ['POST', '/api/platform/question-banks/{bankId}/archive'],
  ['GET', '/api/platform/question-banks/{bankId}/nodes'],
  ['PUT', '/api/platform/question-banks/nodes'],
  ['POST', '/api/platform/question-banks/nodes/batch'],
  ['POST', '/api/platform/question-banks/nodes/{nodeId}/archive'],
  ['GET', '/api/platform/question-banks/questions'],
  ['PUT', '/api/platform/question-banks/questions'],
  ['POST', '/api/platform/question-banks/questions/archive'],
  ['POST', '/api/platform/question-banks/imports/preview'],
  ['POST', '/api/platform/question-banks/imports'],
  ['GET', '/api/platform/question-banks/imports/{jobId}'],
  ['POST', '/api/platform/question-banks/assets/upload-sign'],
  ['POST', '/api/platform/question-banks/assets/upload-confirm'],
] as const;

describe('公共题库页面接口契约', () => {
  it('页面使用的所有题库操作都存在于后端 OpenAPI', () => {
    const keys = new Set(platformOperations.map((operation) => `${operation.method} ${operation.path}`));
    expect(expected.filter(([method, path]) => !keys.has(`${method} ${path}`))).toEqual([]);
  });
});
