From 2ea91a8354be142b835555d4d7b6a24dd2835f5c Mon Sep 17 00:00:00 2001 From: Ilia Denisov Date: Sun, 12 Jul 2026 15:14:31 +0200 Subject: [PATCH] fix(e2e): pin Web Share off in the desktop export tests (macOS WebKit) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The three "plain desktop browser" export tests (the PNG and GCG downloads plus the legacy-Telegram clipboard copy) assumed navigator.share is absent — true for Chromium and for WebKit on the Linux CI host, but desktop WebKit on macOS exposes a working Web Share API. There shareUrlAsFile / pickGcgDelivery take the share branch, so no download event fires and the "GCG copied to the clipboard" toast never shows, and the tests failed only on macOS WebKit. Pin navigator.share/canShare off in those three tests (a withoutWebShare helper that mirrors the inverse stub the share-sheet test already uses), so the delivery path under test is deterministic and identical across engines and OSes. Test-only; no production change. Full e2e suite: 228 passed on Chromium + WebKit. --- ui/e2e/export.spec.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ui/e2e/export.spec.ts b/ui/e2e/export.spec.ts index 54eb524..01e1d68 100644 --- a/ui/e2e/export.spec.ts +++ b/ui/e2e/export.spec.ts @@ -38,7 +38,20 @@ async function openFinishedHistory(page: Page): Promise { await expect(page.getByRole('button', { name: 'Export game' })).toBeVisible(); } +// Desktop WebKit (Safari's engine) exposes a working Web Share API, unlike Chromium and WebKit on +// Linux (the CI host). The "plain desktop browser" delivery paths tested below are reached only when +// Web Share is ABSENT — shareUrlAsFile / pickGcgDelivery fall through to the anchor download or the +// clipboard copy — so pin that precondition; otherwise macOS WebKit takes the share branch and no +// download or clipboard copy occurs. Mirrors the inverse stub the share-sheet test sets up. +async function withoutWebShare(page: Page): Promise { + await page.addInitScript(() => { + Object.defineProperty(navigator, 'share', { value: undefined, configurable: true }); + Object.defineProperty(navigator, 'canShare', { value: undefined, configurable: true }); + }); +} + test('the chooser downloads the PNG through the signed URL on a plain browser', async ({ page }) => { + await withoutWebShare(page); await routeDl(page); await openFinishedHistory(page); await page.getByRole('button', { name: 'Export game' }).click(); @@ -49,6 +62,7 @@ test('the chooser downloads the PNG through the signed URL on a plain browser', }); test('the chooser downloads the GCG through the same signed-URL route', async ({ page }) => { + await withoutWebShare(page); await routeDl(page); await openFinishedHistory(page); await page.getByRole('button', { name: 'Export game' }).click(); @@ -198,6 +212,7 @@ test('Telegram on iOS keeps the app chooser and opens the OS share sheet', async }); test('a legacy Telegram client (no downloadFile) hides the image and copies the GCG', async ({ page }) => { + await withoutWebShare(page); await page.addInitScript(() => { // Headless engines deny the real clipboard; a permissive stub keeps the legacy // copy path deterministic in both browsers.