diff --git a/apps/extension/e2e/capture.spec.ts b/apps/extension/e2e/capture.spec.ts index 1899841..887a581 100644 --- a/apps/extension/e2e/capture.spec.ts +++ b/apps/extension/e2e/capture.spec.ts @@ -7,6 +7,12 @@ import { expect, test } from "./fixtures"; const BASE_URL = "http://localhost:8934"; const SHOT_QA_BIN = process.env.SHOT_QA_BIN ?? "/tmp/opencapture-target/debug/shot-qa"; +// What the download stub in the restore test records, declared so the +// assertions can read it back without casting at every call site. +declare global { + // eslint-disable-next-line no-var + var __downloads: string[]; +} // A real, small PNG already in the repo — no synthetic fixture needed. const LOGO_FIXTURE_PATH = join(dirname(fileURLToPath(import.meta.url)), "..", "public", "icons", "icon48.png"); @@ -46,6 +52,7 @@ test("popup renders its controls", async ({ context, extensionId }) => { await page.goto(`chrome-extension://${extensionId}/popup.html`); await expect(page.locator("#captureFullPage")).toBeVisible(); await expect(page.locator("#captureVisible")).toBeVisible(); + await expect(page.locator("#savePng")).toBeVisible(); await page.close(); }); @@ -2372,10 +2379,32 @@ test("popup: restores report/preview/enabled buttons after closing and reopening const previewSrc = await popup.locator("#preview").getAttribute("src"); expect(previewSrc).toMatch(/^blob:/); await expect(popup.locator("#exportPdf")).toBeEnabled(); + await expect(popup.locator("#savePng")).toBeEnabled(); await expect(popup.locator("#copyToClipboard")).toBeEnabled(); await expect(popup.locator("#openEditor")).toBeEnabled(); await expect(popup.locator("#status")).toHaveText("Opened in editor — crop, annotate, then choose PNG or PDF to save."); + // And the PNG button saves from this restored state, the same way the + // format panel's PNG answer does — counted at the download call rather + // than in a folder, like too-long.spec.ts does. + await serviceWorker.evaluate(() => { + globalThis.__downloads = []; + const real = chrome.downloads.download; + chrome.downloads.download = ((options: chrome.downloads.DownloadOptions) => { + globalThis.__downloads.push(options.filename ?? ""); + return real(options); + }) as typeof chrome.downloads.download; + }); + await popup.click("#savePng"); + await expect + .poll(async () => serviceWorker.evaluate(() => globalThis.__downloads.length), { timeout: 60_000 }) + .toBeGreaterThan(0); + expect(await serviceWorker.evaluate(() => globalThis.__downloads.every((name) => name.endsWith(".png")))).toBe(true); + await serviceWorker.evaluate(() => { + // @ts-expect-error test-only stub installed above + delete globalThis.__downloads; + }); + await popup.close(); // Reset for any other test that happens to run in this same worker diff --git a/apps/extension/e2e/too-long.spec.ts b/apps/extension/e2e/too-long.spec.ts index 75eef8a..f982774 100644 --- a/apps/extension/e2e/too-long.spec.ts +++ b/apps/extension/e2e/too-long.spec.ts @@ -139,6 +139,10 @@ test("a capture too long to finish is left to the user, not downloaded or opened console.log("TOO LONG downloads: " + JSON.stringify(saved)); expect(saved.every((name) => name.endsWith(".png"))).toBe(true); expect(saved.length).toBe(report.output_image_count); + // Both places the count now shows agree with what was written: the status + // line, and the button that names how many files its click will produce. + await expect(popup3.locator("#status")).toHaveText(`Done, captured in ${report.output_image_count} files.`); + await expect(popup3.locator("#savePngLabel")).toHaveText(`PNG (${report.output_image_count})`); await popup3.close(); // And the PDF answer, which is the recommended one, says where a PDF of a diff --git a/apps/extension/src/i18n/de.ts b/apps/extension/src/i18n/de.ts index 6563e2e..31a0442 100644 --- a/apps/extension/src/i18n/de.ts +++ b/apps/extension/src/i18n/de.ts @@ -127,6 +127,7 @@ const messages: Record = { "Copying to clipboard…": "Wird in die Zwischenablage kopiert…", "Copied to clipboard.": "In die Zwischenablage kopiert.", "Done.": "Fertig.", + "Done, captured in {count} files.": "Fertig, in {count} Dateien erfasst.", "Selection cancelled.": "Auswahl abgebrochen.", "Too large to edit on this device.": "Zu groß, um auf diesem Gerät bearbeitet zu werden.", "No captured image found — capture a page first, then click Annotate.": "Keine Aufnahme gefunden — nehmen Sie zuerst eine Seite auf und klicken Sie dann auf Kommentieren.", diff --git a/apps/extension/src/i18n/es.ts b/apps/extension/src/i18n/es.ts index 4115ca4..765a9d3 100644 --- a/apps/extension/src/i18n/es.ts +++ b/apps/extension/src/i18n/es.ts @@ -127,6 +127,7 @@ const messages: Record = { "Copying to clipboard…": "Copiando al portapapeles…", "Copied to clipboard.": "Copiado al portapapeles.", "Done.": "Listo.", + "Done, captured in {count} files.": "Listo, capturado en {count} archivos.", "Selection cancelled.": "Selección cancelada.", "Too large to edit on this device.": "Demasiado grande para editarla en este dispositivo.", "No captured image found — capture a page first, then click Annotate.": "No se encontró ninguna captura: captura una página primero y luego pulsa Anotar.", diff --git a/apps/extension/src/i18n/ja.ts b/apps/extension/src/i18n/ja.ts index be353bd..e22e35c 100644 --- a/apps/extension/src/i18n/ja.ts +++ b/apps/extension/src/i18n/ja.ts @@ -127,6 +127,7 @@ const messages: Record = { "Copying to clipboard…": "クリップボードにコピーしています…", "Copied to clipboard.": "クリップボードにコピーしました。", "Done.": "完了しました。", + "Done, captured in {count} files.": "完了しました。{count} つのファイルとしてキャプチャしました。", "Selection cancelled.": "選択をキャンセルしました。", "Too large to edit on this device.": "この端末で編集するには大きすぎます。", "No captured image found — capture a page first, then click Annotate.": "キャプチャが見つかりません。先にページをキャプチャしてから「注釈」を選んでください。", diff --git a/apps/extension/src/i18n/ko.ts b/apps/extension/src/i18n/ko.ts index dc62967..e8246a4 100644 --- a/apps/extension/src/i18n/ko.ts +++ b/apps/extension/src/i18n/ko.ts @@ -127,6 +127,7 @@ const messages: Record = { "Copying to clipboard…": "클립보드에 복사하는 중…", "Copied to clipboard.": "클립보드에 복사했습니다.", "Done.": "완료했습니다.", + "Done, captured in {count} files.": "완료했습니다. {count}개의 파일로 캡처했습니다.", "Selection cancelled.": "선택을 취소했습니다.", "Too large to edit on this device.": "이 기기에서 편집하기에는 너무 큽니다.", "No captured image found — capture a page first, then click Annotate.": "캡처한 이미지가 없습니다. 먼저 페이지를 캡처한 다음 주석을 누르세요.", diff --git a/apps/extension/src/i18n/pt.ts b/apps/extension/src/i18n/pt.ts index e137ab4..1137a58 100644 --- a/apps/extension/src/i18n/pt.ts +++ b/apps/extension/src/i18n/pt.ts @@ -127,6 +127,7 @@ const messages: Record = { "Copying to clipboard…": "Copiando para a área de transferência…", "Copied to clipboard.": "Copiado para a área de transferência.", "Done.": "Pronto.", + "Done, captured in {count} files.": "Pronto, capturado em {count} arquivos.", "Selection cancelled.": "Seleção cancelada.", "Too large to edit on this device.": "Grande demais para editar neste dispositivo.", "No captured image found — capture a page first, then click Annotate.": "Nenhuma imagem capturada — capture uma página primeiro e clique em Anotar.", diff --git a/apps/extension/src/i18n/zh-Hans.ts b/apps/extension/src/i18n/zh-Hans.ts index cd1d6eb..be11bab 100644 --- a/apps/extension/src/i18n/zh-Hans.ts +++ b/apps/extension/src/i18n/zh-Hans.ts @@ -127,6 +127,7 @@ const messages: Record = { "Copying to clipboard…": "正在复制到剪贴板…", "Copied to clipboard.": "已复制到剪贴板。", "Done.": "完成。", + "Done, captured in {count} files.": "完成,已捕获为 {count} 个文件。", "Selection cancelled.": "已取消选择。", "Too large to edit on this device.": "太大,无法在此设备上编辑。", "No captured image found — capture a page first, then click Annotate.": "未找到已捕获的图片——请先捕获网页,再点击“标注”。", diff --git a/apps/extension/src/i18n/zh-Hant.ts b/apps/extension/src/i18n/zh-Hant.ts index c30bcb1..f7bf09b 100644 --- a/apps/extension/src/i18n/zh-Hant.ts +++ b/apps/extension/src/i18n/zh-Hant.ts @@ -127,6 +127,7 @@ const messages: Record = { "Copying to clipboard…": "正在複製到剪貼簿…", "Copied to clipboard.": "已複製到剪貼簿。", "Done.": "完成。", + "Done, captured in {count} files.": "完成,已擷取為 {count} 個檔案。", "Selection cancelled.": "已取消選取。", "Too large to edit on this device.": "太大,無法在此裝置上編輯。", "No captured image found — capture a page first, then click Annotate.": "找不到已擷取的圖片——請先擷取網頁,再點選「標註」。", diff --git a/apps/extension/src/popup/popup.html b/apps/extension/src/popup/popup.html index 30eba2e..663b926 100644 --- a/apps/extension/src/popup/popup.html +++ b/apps/extension/src/popup/popup.html @@ -429,6 +429,10 @@ PDF +