import { test } from '@playwright/test';

/**
 * Skip a test that depends on persisting a Blob/File in IndexedDB when running on
 * Playwright's WebKit.
 *
 * The client upload queue (`frontend/src/lib/upload-queue.ts`) stores the file itself in
 * IndexedDB so a backgrounded or reloaded phone can resume the upload. Playwright's Linux
 * WebKit build cannot store Blobs in IndexedDB at all — `put()` fails with
 * "UnknownError: Error preparing Blob/File data to be stored in object store". Verified to
 * be the harness, not the app: a Blob constructed in-page with `new Blob([bytes])` fails
 * exactly the same way, while Chromium stores both that and a `setInputFiles` File fine.
 * Real iOS Safari supports Blobs in IndexedDB, so this is NOT evidence of a bug on the
 * platform these tests exist to protect.
 *
 * Any test that drives the composer (FAB → UploadSheet → /upload → submit) hits this,
 * because `handleSubmit` awaits `addToQueue`, which throws before it can navigate.
 *
 * This is deliberately narrow. WebKit still runs every API-driven upload test, the whole of
 * 01-auth, 03-feed and 06-export — including the keepsake download, which only WebKit can
 * meaningfully verify. If Playwright's WebKit ever gains IndexedDB Blob support, delete this
 * helper and the four call sites.
 */
export function skipIfNoIdbBlobs(browserName: string) {
  test.skip(
    browserName === 'webkit',
    "Playwright's Linux WebKit cannot store Blobs in IndexedDB (harness limitation, not an iOS one) — the client upload queue can't be exercised there"
  );
}
