import { V22QueryController } from './v22-query.controller';

describe('V22QueryController', () => {
  it('forwards V2.2 hot-path requests to the query service', async () => {
    const service = {
      getVersionDetailData: jest.fn().mockResolvedValue({ version: { id: 'version-1' } }),
      listRequirements: jest.fn().mockResolvedValue({ items: [], nextCursor: undefined }),
      getWorkspaceData: jest.fn().mockResolvedValue({ devTasks: [] }),
      getXiaobaoWarnings: jest.fn().mockResolvedValue([]),
    };
    const controller = new V22QueryController(service as any);

    await controller.getVersionDetailData('version-1');
    await controller.listRequirements(
      'product-1',
      'project-1',
      undefined,
      'adopted',
      'P1',
      'feature',
      'login',
      'created_at_asc',
      'req-2',
      '50',
    );
    await controller.getWorkspaceData('member-1');
    await controller.getXiaobaoWarnings('member-1', 'false');

    expect(service.getVersionDetailData).toHaveBeenCalledWith('version-1');
    expect(service.listRequirements).toHaveBeenCalledWith({
      productId: 'product-1',
      projectId: 'project-1',
      versionId: undefined,
      status: 'adopted',
      priority: 'P1',
      type: 'feature',
      q: 'login',
      sort: 'created_at_asc',
      cursor: 'req-2',
      limit: '50',
    });
    expect(service.getWorkspaceData).toHaveBeenCalledWith('member-1');
    expect(service.getXiaobaoWarnings).toHaveBeenCalledWith({ userId: 'member-1', manager: 'false' });
  });
});
