Admin Panel

Export CSV

CSV export streams the active filter set, not the entire table, and uses a stable filename.

User story

As an admin, I want to export only the filtered rows as a CSV so I can share clean data with stakeholders.

Acceptance criteria

  • CSV reflects the active filter set
  • Filename matches /^validation-lab-users-\d{8}.csv$/
  • Header row is fixed
  • Special characters are escaped (commas, quotes)

Manual test steps

  1. 1.Open /users
  2. 2.Filter role=Admin
  3. 3.Click Export CSV
  4. 4.Open file and confirm header + row count

Expected result

Download starts and the file contains only Admin rows.

Possible bug risks

  • CSV exports unfiltered data ('all rows' bug)
  • Quotes inside email field break the parser
  • Filename collides on rapid re-export

Reference Playwright spec

export-csv.spec.ts
ts
1
2
3
4
5
6
7
8
9
10
11
12
import { test, expect } from '@playwright/test';

test('CSV export honors filter @regression', async ({ page }) => {
  await page.goto('https://lab.hakdogan.com/users');
  await page.getByLabel(/role/i).selectOption('admin');

  const downloadPromise = page.waitForEvent('download');
  await page.getByRole('button', { name: /export csv/i }).click();
  const download = await downloadPromise;

  expect(download.suggestedFilename()).toMatch(/validation-lab-users-\d{8}.csv/);
});