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

const expected = [
  ['GET', '/api/platform-admin/question-banks'],
  ['PUT', '/api/platform-admin/question-banks'],
  ['POST', '/api/platform-admin/question-banks/{bankId}/archive'],
  ['GET', '/api/platform-admin/question-banks/{bankId}/nodes'],
  ['PUT', '/api/platform-admin/question-banks/nodes'],
  ['POST', '/api/platform-admin/question-banks/nodes/batch'],
  ['POST', '/api/platform-admin/question-banks/nodes/{nodeId}/archive'],
  ['GET', '/api/platform-admin/question-banks/questions'],
  ['PUT', '/api/platform-admin/question-banks/questions'],
  ['POST', '/api/platform-admin/question-banks/questions/archive'],
  ['POST', '/api/platform-admin/question-banks/imports/preview'],
  ['POST', '/api/platform-admin/question-banks/imports'],
  ['GET', '/api/platform-admin/question-banks/imports/{jobId}'],
  ['POST', '/api/platform-admin/question-banks/assets/upload-sign'],
  ['POST', '/api/platform-admin/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([]);
  });
});
