Skip to content

Commit 22ff23f

Browse files
committed
fixup! ✅(e2e) add test for accessible html export from export modal
1 parent 24f8da0 commit 22ff23f

File tree

1 file changed

+31
-5
lines changed

1 file changed

+31
-5
lines changed

src/frontend/apps/e2e/__tests__/app-impress/doc-export.spec.ts

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import path from 'path';
22

33
import { expect, test } from '@playwright/test';
44
import cs from 'convert-stream';
5+
import JSZip from 'jszip';
56
import { PDFParse } from 'pdf-parse';
67

78
import {
@@ -215,7 +216,12 @@ test.describe('Doc Export', () => {
215216
.locator('.--docs--editor-container img.bn-visual-media')
216217
.first();
217218

218-
await expect(image).toBeVisible();
219+
// Wait for the image to be attached and have a valid src (aria-hidden prevents toBeVisible on Chromium)
220+
await expect(image).toBeAttached({ timeout: 10000 });
221+
await expect(image).toHaveAttribute('src', /.*\.svg/);
222+
223+
// Give some time for the image to be fully processed
224+
await page.waitForTimeout(1000);
219225

220226
await page
221227
.getByRole('button', {
@@ -238,11 +244,31 @@ test.describe('Doc Export', () => {
238244
expect(download.suggestedFilename()).toBe(`${randomDoc}.zip`);
239245

240246
const zipBuffer = await cs.toBuffer(await download.createReadStream());
247+
// Unzip and inspect contents
248+
const zip = await JSZip.loadAsync(zipBuffer);
249+
250+
// Check that index.html exists
251+
const indexHtml = zip.file('index.html');
252+
expect(indexHtml).not.toBeNull();
253+
254+
// Read and verify HTML content
255+
const htmlContent = await indexHtml!.async('string');
256+
console.log('HTML content preview:', htmlContent.substring(0, 1000));
257+
expect(htmlContent).toContain('Hello HTML ZIP');
258+
259+
// Check for media files (they are at the root of the ZIP, not in a media/ folder)
260+
// Media files are named like "1-test.svg" or "media-1.png" by deriveMediaFilename
261+
const allFiles = Object.keys(zip.files);
262+
console.log('All files in ZIP:', allFiles);
263+
const mediaFiles = allFiles.filter(
264+
(name) => name !== 'index.html' && !name.endsWith('/'),
265+
);
266+
console.log('Media files found:', mediaFiles);
267+
expect(mediaFiles.length).toBeGreaterThan(0);
241268

242-
// ZIP files start with "PK\x03\x04"
243-
expect(zipBuffer.length).toBeGreaterThan(4);
244-
expect(zipBuffer[0]).toBe(0x50);
245-
expect(zipBuffer[1]).toBe(0x4b);
269+
// Verify the SVG image is included
270+
const svgFile = mediaFiles.find((name) => name.endsWith('.svg'));
271+
expect(svgFile).toBeDefined();
246272
});
247273

248274
/**

0 commit comments

Comments
 (0)