import { test, expect } from '@playwright/test';
import { RoleAuthHelper } from '../../helpers/helpers';

test.describe('Excel Export Verification', () => {

  test('complaint Excel export downloads valid file', async ({ page }) => {
    const auth = new RoleAuthHelper(page);
    await auth.login('hospital_admin');

    const apiCtx = await page.context().request;
    const resp = await apiCtx.get('http://localhost:8000/complaints/export/excel/');
    expect(resp.status()).toBe(200);
    expect(resp.headers()['content-type']).toContain('spreadsheet');

    const body = await resp.body();
    expect(body.length).toBeGreaterThan(0);
    expect(body[0]).toBe(0x50);
  });
});
