VALIDATION LABCSV EXPORT VALIDATION

Requests

CSV Export Validation

Pick a scope (all / active / admins), generate the CSV, and verify the header row, the comma-escaping in names, and the filename pattern on download.

Intermediate

Why this matters in QA

Exports are a security and compliance surface. The 'CSV exports unfiltered data' bug is one of the most common GDPR incidents — tests must verify both the row count AND the column header AND the file name.

Export honors the active filter set. Confirm the row count, the header row, the comma escaping (double quotes around names), and the filename pattern.

downloads: 0
// click Preview CSV to inspect the file

Filename: validation-lab-users-YYYYMMDD.csv

Live widget · interact freely

Manual test checklist

  • 1Pick 'Active only' → preview rows count matches the dropdown count
  • 2Confirm the first line is the canonical header
  • 3Confirm names with commas would be quoted (`"Akdogan, Hasan"`) — try editing the data
  • 4Click Download — file lands with the right filename pattern
  • 5Confirm the on-screen download counter increments

Expected result

Active scope produces a CSV with exactly the active rows. The first line is `id,name,email,role,status,signups`. Filename matches `validation-lab-users-YYYYMMDD.csv`.

Automation challenge

Use `const downloadPromise = page.waitForEvent('download')` BEFORE the click. Assert `download.suggestedFilename()` matches `/validation-lab-users-\d{8}\.csv/`. Then read the file via `download.path()` and assert the header line.

Stable selectors

  • Scope select[data-testid="csv-scope"]
  • Preview[data-testid="csv-preview"]
  • Download[data-testid="csv-download"]
  • Preview body[data-testid="csv-preview-body"]
  • Downloads counter[data-testid="csv-downloads"]

Reference Playwright spec

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

test('csv export filename matches contract', async ({ page }) => {
  await page.goto('https://lab.hakdogan.com/data-api/csv-export');

  const downloadPromise = page.waitForEvent('download');
  await page.getByTestId('csv-download').click();
  const download = await downloadPromise;

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