splitting tests
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import { expect, test } from '@playwright/test';
|
||||
import { unzipSync } from 'fflate';
|
||||
import { readFile } from 'node:fs/promises';
|
||||
import { createEncryptedPdf, dropFiles, pdfDropzone, trackPageErrors } from './helpers';
|
||||
|
||||
test('decrypt batch unlocks every file and bundles results in one ZIP', async ({ page }) => {
|
||||
const pageErrors = trackPageErrors(page);
|
||||
await page.goto('/tools/decrypt');
|
||||
await dropFiles(page, pdfDropzone(page), [
|
||||
{
|
||||
name: 'eins_geschuetzt.pdf',
|
||||
mimeType: 'application/pdf',
|
||||
buffer: await createEncryptedPdf(1, 'Eins', 'test-passwort')
|
||||
},
|
||||
{
|
||||
name: 'zwei_geschuetzt.pdf',
|
||||
mimeType: 'application/pdf',
|
||||
buffer: await createEncryptedPdf(2, 'Zwei', 'test-passwort')
|
||||
},
|
||||
{
|
||||
name: 'kaputt.pdf',
|
||||
mimeType: 'application/pdf',
|
||||
buffer: Buffer.from('kein gueltiges PDF')
|
||||
}
|
||||
]);
|
||||
|
||||
await expect(page.getByText('Dateien (3)')).toBeVisible();
|
||||
await page.locator('#decrypt-password').fill('test-passwort');
|
||||
await page.getByRole('button', { name: 'Passwort entfernen', exact: true }).click();
|
||||
await expect(page.getByText('Fertig ✓')).toHaveCount(2, { timeout: 20_000 });
|
||||
await expect(page.getByText(/Fehler beim Entsperren/)).toBeVisible();
|
||||
|
||||
const downloadPromise = page.waitForEvent('download');
|
||||
await page.getByRole('button', { name: 'Alle herunterladen' }).click();
|
||||
const download = await downloadPromise;
|
||||
expect(download.suggestedFilename()).toMatch(/^entsperrt_\d{4}-\d{2}-\d{2}\.zip$/);
|
||||
const zipPath = await download.path();
|
||||
expect(zipPath).not.toBeNull();
|
||||
const entries = Object.keys(unzipSync(new Uint8Array(await readFile(zipPath!))));
|
||||
expect(entries.sort()).toEqual([
|
||||
'eins_geschuetzt_entsperrt.pdf',
|
||||
'zwei_geschuetzt_entsperrt.pdf'
|
||||
]);
|
||||
expect(pageErrors).toEqual([]);
|
||||
});
|
||||
Reference in New Issue
Block a user