From 24978ec1ba2e7c7aac394c50af6ac170d4106aa8 Mon Sep 17 00:00:00 2001 From: Caryl Wyatt Date: Mon, 17 Nov 2025 16:51:02 -0500 Subject: [PATCH 1/2] change buildAction reactivity statement to run function when any argument changes --- .../firebird/src/js/components/DownloadPanel/index.svelte | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pt/web/firebird/src/js/components/DownloadPanel/index.svelte b/pt/web/firebird/src/js/components/DownloadPanel/index.svelte index 60f157c6d..ee26adfa4 100644 --- a/pt/web/firebird/src/js/components/DownloadPanel/index.svelte +++ b/pt/web/firebird/src/js/components/DownloadPanel/index.svelte @@ -280,16 +280,16 @@ } } - function buildAction(format) { + function buildAction(format, range, targetPPI) { let action = '/cgi/imgsrv/'; if (format.startsWith('image-') && range.startsWith('current-page')) { action += 'image'; sizeAttr = 'size'; sizeValue = targetPPI == '0' ? 'full' : `ppi:${targetPPI}`; } else { + action += 'download/' + format.split('-')[0]; sizeAttr = 'target_ppi'; sizeValue = targetPPI; - action += 'download/' + format.split('-')[0]; } return action; } @@ -342,8 +342,7 @@ let flattenedSelection = []; - $: action = buildAction(format, range); - $: iframeName = `download-module-xxx`; // ${tunnelFormAttempt}`; + $: action = buildAction(format, range, targetPPI); $: if ((format == 'plaintext-zip' || format == 'epub') && range != 'volume') { range = 'volume'; } From 860c23b4d82192df73055b3a48145a8154e6d119 Mon Sep 17 00:00:00 2001 From: Caryl Wyatt Date: Tue, 18 Nov 2025 09:40:43 -0500 Subject: [PATCH 2/2] add playwright test for full resoltuion TIFF --- pt/web/firebird/tests/imgsrv_download.spec.js | 4 +- pt/web/firebird/tests/sidebar.spec.js | 41 +++++++++++++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/pt/web/firebird/tests/imgsrv_download.spec.js b/pt/web/firebird/tests/imgsrv_download.spec.js index c4f22b87d..e803457da 100644 --- a/pt/web/firebird/tests/imgsrv_download.spec.js +++ b/pt/web/firebird/tests/imgsrv_download.spec.js @@ -103,11 +103,11 @@ test.describe('imgsrv download', () => { expect(downloadBody.length).toBeGreaterThan(0); }); - test('download single tiff, full resolution', async ({ request, page }) => { + test('download single tiff current page, full resolution', async ({ request, page }) => { // no callback tunnel on single tiff const downloadResponse = await request.get( - 'http://apache-test:8080/cgi/imgsrv/image?id=test.pd_open&attachment=1&tracker=D1&format=image/tiff&size=ppi:300&seq=1' + 'http://apache-test:8080/cgi/imgsrv/image?id=test.pd_open&attachment=1&tracker=D1&format=image/tiff&size=full&seq=1' ); const downloadHeaders = downloadResponse.headers(); const downloadBody = await downloadResponse.text(); diff --git a/pt/web/firebird/tests/sidebar.spec.js b/pt/web/firebird/tests/sidebar.spec.js index 647a8eac0..f2c91f310 100644 --- a/pt/web/firebird/tests/sidebar.spec.js +++ b/pt/web/firebird/tests/sidebar.spec.js @@ -122,6 +122,47 @@ test.describe('sidebar actions', () => { const download = await downloadPromise; const downloadPath = await download.path(); + //expect download to be zip + expect(download.suggestedFilename()).toContain('zip'); + //expect file to exist before playwright deletes it + expect(fs.existsSync(downloadPath)).toBeTruthy(); + }); + test('download selected scan as full resolution tiff', async ({ page }) => { + const downloadPromise = page.waitForEvent('download'); + const downloadButton = page + .getByRole('form', { name: 'Download options' }) + .getByRole('button', { name: 'Download' }); + + await expect(page.getByText('Note: TIFF downloads are limited')).toBeVisible({ visible: false }); + await page.getByLabel('Image (TIFF)').check(); + await expect(page.getByText('Note: TIFF downloads are limited')).toBeVisible(); + await page.getByLabel('Selected page scans').check(); + + await downloadButton.click(); + await expect( + page.getByRole('form', { name: 'Download options' }).getByText("You haven't selected any") + ).toBeVisible(); + + await page.getByRole('button', { name: 'View' }).click(); + await page.getByRole('button', { name: 'Thumbnails' }).click(); + await expect(page).toHaveURL('/cgi/pt?id=test.pd_open&seq=1&view=thumb'); + + const selectScan = page.locator('button[aria-label="Select scan #2"]'); + await expect(selectScan).toHaveAttribute('aria-pressed', 'false'); + await selectScan.click(); + + const fullResolution = page.getByRole('radio', { name: 'Full / 600 dpi' }); + await fullResolution.click(); + await expect(fullResolution).toBeChecked(); + + // check hidden download form for the correct input value for 'selected scan' full resolution image + const hiddenTagetPpiInput = page.locator('input[name="target_ppi"]'); + await expect(hiddenTagetPpiInput).toHaveAttribute('value', '0'); + + await downloadButton.click(); + const download = await downloadPromise; + const downloadPath = await download.path(); + //expect download to be zip expect(download.suggestedFilename()).toContain('zip'); //expect file to exist before playwright deletes it