@@ -2,6 +2,7 @@ import path from 'path';
22
33import { expect , test } from '@playwright/test' ;
44import cs from 'convert-stream' ;
5+ import JSZip from 'jszip' ;
56import { PDFParse } from 'pdf-parse' ;
67
78import {
@@ -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 ( / ^ m e d i a \/ / ) ;
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