Skip to content

Commit 882b7f3

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

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

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

Lines changed: 21 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,7 @@ test.describe('Doc Export', () => {
215216
.locator('.--docs--editor-container img.bn-visual-media')
216217
.first();
217218

218-
await expect(image).toBeVisible();
219+
await expect(image).toBeVisible({ timeout: 10000 });
219220

220221
await page
221222
.getByRole('button', {
@@ -238,11 +239,26 @@ test.describe('Doc Export', () => {
238239
expect(download.suggestedFilename()).toBe(`${randomDoc}.zip`);
239240

240241
const zipBuffer = await cs.toBuffer(await download.createReadStream());
242+
// Unzip and inspect contents
243+
const zip = await JSZip.loadAsync(zipBuffer);
244+
245+
// Check that index.html exists
246+
const indexHtml = zip.file('index.html');
247+
expect(indexHtml).not.toBeNull();
248+
249+
// Read and verify HTML content
250+
const htmlContent = await indexHtml!.async('string');
251+
expect(htmlContent).toContain('Hello HTML ZIP');
241252

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);
253+
// Check for media files
254+
const mediaFiles = zip.file(/^media\//);
255+
expect(mediaFiles.length).toBeGreaterThan(0);
256+
257+
// Verify the SVG image is included
258+
const svgFile = mediaFiles.find((f: { name: string }) =>
259+
f.name.endsWith('.svg'),
260+
);
261+
expect(svgFile).toBeDefined();
246262
});
247263

248264
/**

0 commit comments

Comments
 (0)