From 48ea4c0533869a4fbc280353e650ff838e9ef286 Mon Sep 17 00:00:00 2001 From: Nathan Vasse Date: Tue, 14 Apr 2026 15:11:26 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=85(frontend)=20add=20unsupported=20file?= =?UTF-8?q?=20preview=20e2e=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cover the fallback viewer that kicks in for file types the app cannot render inline. A minimal .bin fixture exercises the redesign so the filename, the "Unsupported format." disclaimer and the secondary download button are all checked end to end. --- .../app-drive/assets/test-unsupported.bin | 1 + .../unsupported-file-preview.spec.ts | 64 +++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 src/frontend/apps/e2e/__tests__/app-drive/assets/test-unsupported.bin create mode 100644 src/frontend/apps/e2e/__tests__/app-drive/file-preview/unsupported-file-preview.spec.ts diff --git a/src/frontend/apps/e2e/__tests__/app-drive/assets/test-unsupported.bin b/src/frontend/apps/e2e/__tests__/app-drive/assets/test-unsupported.bin new file mode 100644 index 00000000..647ad810 --- /dev/null +++ b/src/frontend/apps/e2e/__tests__/app-drive/assets/test-unsupported.bin @@ -0,0 +1 @@ +This is an unsupported binary fixture file. diff --git a/src/frontend/apps/e2e/__tests__/app-drive/file-preview/unsupported-file-preview.spec.ts b/src/frontend/apps/e2e/__tests__/app-drive/file-preview/unsupported-file-preview.spec.ts new file mode 100644 index 00000000..85e36f10 --- /dev/null +++ b/src/frontend/apps/e2e/__tests__/app-drive/file-preview/unsupported-file-preview.spec.ts @@ -0,0 +1,64 @@ +import path from "path"; + +import test, { expect } from "@playwright/test"; + +import { clearDb, login } from "../utils-common"; +import { clickToMyFiles } from "../utils-navigate"; +import { uploadFile } from "../utils/upload-utils"; + +const UNSUPPORTED_FILE_PATH = path.join( + __dirname, + "../assets/test-unsupported.bin", +); + +test.describe("Unsupported File Preview", () => { + test.beforeEach(async ({ page }) => { + await clearDb(); + await login(page, "drive@example.com"); + await page.goto("/"); + await clickToMyFiles(page); + + await uploadFile(page, UNSUPPORTED_FILE_PATH); + await expect( + page.getByRole("cell", { name: "test-unsupported.bin", exact: true }), + ).toBeVisible({ timeout: 10000 }); + + await page + .getByRole("cell", { name: "test-unsupported.bin", exact: true }) + .dblclick(); + await expect(page.getByTestId("file-preview")).toBeVisible({ + timeout: 10000, + }); + }); + + test("Renders the NotSupportedPreview for an unknown binary file", async ({ + page, + }) => { + const unsupported = page.locator(".file-preview-unsupported"); + await expect(unsupported).toBeVisible(); + + await expect( + unsupported.locator(".file-preview-unsupported__title"), + ).toHaveText("test-unsupported.bin"); + }); + + test("Download button in the unsupported view triggers a download", async ({ + page, + }) => { + const downloadButton = page.locator( + ".file-preview-unsupported__download-button", + ); + await expect(downloadButton).toBeVisible(); + + const downloadPromise = page.waitForEvent("download"); + await downloadButton.click(); + const download = await downloadPromise; + + expect(download.suggestedFilename()).toContain("test-unsupported"); + }); + + test("Hides the actions menu for unsupported files", async ({ page }) => { + const filePreview = page.getByTestId("file-preview"); + await expect(filePreview.getByText("more_vert")).not.toBeVisible(); + }); +});