Skip to content

Commit d2fbccd

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 d2fbccd

File tree

5 files changed

+30
-1
lines changed

5 files changed

+30
-1
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
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)