import { describe, expect, it } from 'vitest';
import { adminTaskAdvancedFilterCount, adminTaskPagination } from './AdminTasksPanel';

describe('admin task pagination', () => {
  it('keeps empty results on the first page', () => {
    expect(adminTaskPagination(0, 8, 20)).toEqual({
      totalPages: 1,
      currentPage: 1,
      pageStart: 0,
      pageEnd: 0,
    });
  });

  it('clamps an out-of-range page to the final partial page', () => {
    expect(adminTaskPagination(41, 99, 20)).toEqual({
      totalPages: 3,
      currentPage: 3,
      pageStart: 41,
      pageEnd: 41,
    });
  });
});

describe('admin task advanced filters', () => {
  it('counts only filters moved into the advanced dialog', () => {
    expect(adminTaskAdvancedFilterCount({
      tenantId: 'tenant-id',
      status: 'failed',
      model: '',
      apiKey: 'ops-key',
    })).toBe(3);
  });
});
