Skip to content

Commit eca0423

Browse files
committed
✅(frontend) add pdf export regression test with embedded image fixtures
adds base64 png/jpg/svg image fixtures to stabilize pdf export snapshots Signed-off-by: Cyril <c.gromoff@gmail.com>
1 parent 6c91878 commit eca0423

File tree

6 files changed

+37
-9
lines changed

6 files changed

+37
-9
lines changed

src/frontend/apps/e2e/__tests__/app-impress/assets/content.txt

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.
231 KB
Loading
839 KB
Loading

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -596,6 +596,9 @@ test.describe('Doc Export', () => {
596596
page,
597597
browserName,
598598
}, testInfo) => {
599+
// PDF generation for a large, image-heavy document can be slow in CI.
600+
// Give this regression test a higher timeout budget than the default.
601+
testInfo.setTimeout(120000);
599602
const snapshotPath = testInfo.snapshotPath(REGRESSION_SNAPSHOT_NAME);
600603

601604
test.skip(
@@ -656,14 +659,10 @@ test.describe('Doc Export', () => {
656659
}
657660

658661
await page.reload();
659-
660-
const headingLocator = page
661-
.locator('.--docs--editor-container')
662-
.getByText('Titre h1 repliable', { exact: true })
663-
.first();
664-
665-
await headingLocator.scrollIntoViewIfNeeded();
666-
await expect(headingLocator).toBeVisible({ timeout: 15000 });
662+
// After reloading, just ensure the editor container is present before exporting.
663+
await expect(page.locator('.--docs--editor-container')).toBeVisible({
664+
timeout: 15000,
665+
});
667666

668667
await page
669668
.getByRole('button', {
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//utilitary script to print the datauris of the targeted assets
2+
3+
const fs = require('fs');
4+
const path = require('path');
5+
6+
const ASSETS_ROOT = path.resolve(__dirname, '__tests__/app-impress/assets');
7+
8+
function saveDataUrl(file, mime, outName) {
9+
const abs = path.join(ASSETS_ROOT, file);
10+
const base64 = fs.readFileSync(abs).toString('base64');
11+
const dataUrl = `data:${mime};base64,${base64}`;
12+
const outPath = path.join(ASSETS_ROOT, outName);
13+
fs.writeFileSync(outPath, dataUrl, 'utf8');
14+
console.log(`Wrote ${outName}`);
15+
}
16+
17+
// PNG
18+
saveDataUrl('panopng.png', 'image/png', 'pano-png-dataurl.txt');
19+
20+
// JPG
21+
saveDataUrl('panojpg.jpeg', 'image/jpeg', 'pano-jpg-dataurl.txt');
22+
23+
// SVG
24+
const svgPath = path.join(ASSETS_ROOT, 'test.svg');
25+
const svgText = fs.readFileSync(svgPath, 'utf8');
26+
const svgDataUrl =
27+
'data:image/svg+xml;base64,' + Buffer.from(svgText).toString('base64');
28+
fs.writeFileSync(path.join(ASSETS_ROOT, 'test-svg-dataurl.txt'), svgDataUrl, 'utf8');
29+
console.log('Wrote test-svg-dataurl.txt');

0 commit comments

Comments
 (0)