Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions pt/web/firebird/src/js/components/DownloadPanel/index.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -342,8 +342,7 @@
let flattenedSelection = [];
$: action = buildAction(format, range);
$: iframeName = `download-module-xxx`; // ${tunnelFormAttempt}`;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this because the variable iframeName was not in use anywhere. It must've been leftover from some refactor a while back.

$: action = buildAction(format, range, targetPPI);
$: if ((format == 'plaintext-zip' || format == 'epub') && range != 'volume') {
range = 'volume';
}
Expand Down
4 changes: 2 additions & 2 deletions pt/web/firebird/tests/imgsrv_download.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
41 changes: 41 additions & 0 deletions pt/web/firebird/tests/sidebar.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down