Skip to content

Commit 98ffee7

Browse files
committed
✅(e2e) add test for accessible html export from export modal
checks generated zip contains html and embedded media files Signed-off-by: Cyril <[email protected]>
1 parent 1c176f4 commit 98ffee7

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

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

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,64 @@ test.describe('Doc Export', () => {
187187
expect(download.suggestedFilename()).toBe(`${randomDoc}.odt`);
188188
});
189189

190+
test('it exports the doc to html zip', async ({ page, browserName }) => {
191+
const [randomDoc] = await createDoc(
192+
page,
193+
'doc-editor-html-zip',
194+
browserName,
195+
1,
196+
);
197+
198+
await verifyDocName(page, randomDoc);
199+
200+
// Add some content and at least one image so that the ZIP contains media files.
201+
await page.locator('.ProseMirror.bn-editor').click();
202+
await page.locator('.ProseMirror.bn-editor').fill('Hello HTML ZIP');
203+
204+
await page.keyboard.press('Enter');
205+
await page.locator('.bn-block-outer').last().fill('/');
206+
await page.getByText('Resizable image with caption').click();
207+
208+
const fileChooserPromise = page.waitForEvent('filechooser');
209+
await page.getByText('Upload image').click();
210+
211+
const fileChooser = await fileChooserPromise;
212+
await fileChooser.setFiles(path.join(__dirname, 'assets/test.svg'));
213+
214+
const image = page
215+
.locator('.--docs--editor-container img.bn-visual-media')
216+
.first();
217+
218+
await expect(image).toBeVisible();
219+
220+
await page
221+
.getByRole('button', {
222+
name: 'Export the document',
223+
})
224+
.click();
225+
226+
await page.getByRole('combobox', { name: 'Format' }).click();
227+
await page.getByRole('option', { name: 'HTML' }).click();
228+
229+
await expect(page.getByTestId('doc-export-download-button')).toBeVisible();
230+
231+
const downloadPromise = page.waitForEvent('download', (download) => {
232+
return download.suggestedFilename().includes(`${randomDoc}.zip`);
233+
});
234+
235+
void page.getByTestId('doc-export-download-button').click();
236+
237+
const download = await downloadPromise;
238+
expect(download.suggestedFilename()).toBe(`${randomDoc}.zip`);
239+
240+
const zipBuffer = await cs.toBuffer(await download.createReadStream());
241+
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);
246+
});
247+
190248
/**
191249
* This test tell us that the export to pdf is working with images
192250
* but it does not tell us if the images are being displayed correctly

0 commit comments

Comments
 (0)