fix: cancel download fetch when progress toast is closed (#27152)

* fix: cancel download fetch when progress toast is closed

- Create new progress-toast utility using @coss/ui toastManager
- Add ToastProvider to app providers
- Update download components to use AbortController for cancellation
- When cancel button is clicked, abort signal stops the fetch loop

Co-Authored-By: [email protected] <[email protected]>

* fix: track active toasts with Set instead of accessing toastManager.toasts

Co-Authored-By: [email protected] <[email protected]>

* feat: add AnchoredToastProvider to app providers

Co-Authored-By: [email protected] <[email protected]>

* refactor: extract common CSV download logic into useCsvDownload hook

Co-Authored-By: [email protected] <[email protected]>

* refactor: improve progress toast with i18n support and Progress component

Co-Authored-By: [email protected] <[email protected]>

* refactor: replace useCsvDownload hook with DownloadButton component

Co-Authored-By: [email protected] <[email protected]>

* refactor: rename DownloadButton to CsvDownloadButton

Co-Authored-By: [email protected] <[email protected]>

* clean up i18n

* fix: properly throw AbortError when download is cancelled

Co-Authored-By: [email protected] <[email protected]>

* Revert "fix: properly throw AbortError when download is cancelled"

This reverts commit 3c64b848140271e4dcd2e45dba5302eef9ca562c.

* fix abort controller

* fix layout shift

* better handle error

* fix: address Cubic AI review feedback

- Fix typo 'copmlete' -> 'complete' in download_progress i18n string
- Treat null batch as failure during CSV download to prevent partial exports

Co-Authored-By: unknown <>

* remove redundant try - catch

---------

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2026-01-27 16:46:37 +00:00
1 parent 7ce1ee5cea
commit fd476bf7f7
7 files changed
+256 -268

No files matched your search

+6 -12
View File
@@ -1,11 +1,9 @@
import { expect } from "@playwright/test";
import { FeaturesRepository } from "@calcom/features/flags/features.repository";
import { PermissionCheckService } from "@calcom/features/pbac/services/permission-check.service";
import { randomString } from "@calcom/lib/random";
import { prisma } from "@calcom/prisma";
import { clearFilters, applySelectFilter } from "./filter-helpers";
import { expect } from "@playwright/test";
import { applySelectFilter, clearFilters } from "./filter-helpers";
import { test } from "./lib/fixtures";
import { createAllPermissionsArray, enablePBACForTeam } from "./lib/test-helpers/pbac";
@@ -224,17 +222,13 @@ test.describe("Insights", async () => {
const downloadPromise = page.waitForEvent("download");
const downloadButton = page.getByRole("button", { name: "Download" });
// Expect download button to be visible
await expect(page.locator("text=Download")).toBeVisible();
// Click on Download button
await page.getByText("Download").click();
// Expect as csv option to be visible
await expect(page.locator("text=as CSV")).toBeVisible();
await expect(downloadButton).toBeVisible();
// Start waiting for download before clicking. Note no await.
await page.getByText("as CSV").click();
await downloadButton.click();
const download = await downloadPromise;
// Wait for the download process to complete and save the downloaded file somewhere.