fix: bulk download partial failure, abort, and race-safe e2e

- onSuccess now reports successful envelope ids so the parent clears
  only those rows from selection instead of wiping all pages.
- Partial failures no longer auto-close the dialog; failed/unprocessed
  ids stay selected for retry.
- Cancel button turns into Stop while downloading and aborts the batch
  at the next envelope boundary.
- Replace dual waitForEvent('download') with a page.on collector +
  expect.poll so both downloads are captured reliably.
This commit is contained in:
ephraimduncan
2026-04-20 15:48:18 +00:00
parent 5b63b5deb9
commit b9b29e5a76
3 changed files with 46 additions and 37 deletions
@@ -1,3 +1,4 @@
import type { Download } from '@playwright/test';
import { expect, test } from '@playwright/test';
import { seedDraftDocument } from '@documenso/prisma/seed/documents';
@@ -133,17 +134,14 @@ test('[BULK_ACTIONS]: can bulk download multiple documents', async ({ page }) =>
await expect(dialog.getByText('Bulk Test Doc 2')).toBeVisible();
await expect(dialog.getByText('Draft').first()).toBeVisible();
const firstDownloadPromise = page.waitForEvent('download');
const secondDownloadPromise = page.waitForEvent('download');
const downloads: Download[] = [];
page.on('download', (d) => downloads.push(d));
await dialog.getByRole('button', { name: 'Download' }).click();
const [firstDownload, secondDownload] = await Promise.all([
firstDownloadPromise,
secondDownloadPromise,
]);
await expect.poll(() => downloads.length, { timeout: 10_000 }).toBe(2);
expect([firstDownload.suggestedFilename(), secondDownload.suggestedFilename()]).toEqual(
expect(downloads.map((d) => d.suggestedFilename())).toEqual(
expect.arrayContaining(['Bulk Test Doc 1.pdf', 'Bulk Test Doc 2.pdf']),
);