test(snapshots): use pdf as snapshot
3
.github/workflows/ci.yml
vendored
@ -14,7 +14,8 @@ jobs:
|
|||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- run: npx playwright install firefox
|
- run: npx playwright install firefox
|
||||||
- run: npm run test-prepare-pdfs
|
- run: npm run test:generate-snapshot-screenshots
|
||||||
|
- run: npm run test:generate-pdfs
|
||||||
- run: npm test
|
- run: npm test
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v3
|
||||||
if: always()
|
if: always()
|
||||||
|
6
.github/workflows/update-snapshots.yml
vendored
@ -11,13 +11,13 @@ jobs:
|
|||||||
token: ${{ secrets.GH_TOKEN }}
|
token: ${{ secrets.GH_TOKEN }}
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
- run: npx playwright install firefox
|
- run: npx playwright install firefox
|
||||||
- run: npm run test-prepare-pdfs
|
- run: npm run test:generate-pdfs
|
||||||
- run: npm test -- --update-snapshots
|
- run: rm -rf test/snapshot && mv test/output test/snapshot
|
||||||
- name: Commit
|
- name: Commit
|
||||||
run: |
|
run: |
|
||||||
git config --global user.name 'Decktape bot'
|
git config --global user.name 'Decktape bot'
|
||||||
git config --global user.email 'decktape-bot@users.noreply.github.com'
|
git config --global user.email 'decktape-bot@users.noreply.github.com'
|
||||||
git pull
|
git pull
|
||||||
git add .
|
git add .
|
||||||
git commit -m "test(screenshots): update snapshots"
|
git commit -m "test(snapshots): update snapshot pdfs"
|
||||||
git push
|
git push
|
4
.gitignore
vendored
@ -14,5 +14,9 @@
|
|||||||
!README.adoc
|
!README.adoc
|
||||||
!test/
|
!test/
|
||||||
test/output/
|
test/output/
|
||||||
|
|
||||||
|
# Snapshot screenshots are regenerated based on the snapshot pdf
|
||||||
|
test/e2e.spec.ts-snapshots
|
||||||
|
|
||||||
!playwright.config.ts
|
!playwright.config.ts
|
||||||
!.github/
|
!.github/
|
||||||
|
@ -12,7 +12,8 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node decktape.js",
|
"start": "node decktape.js",
|
||||||
"test-prepare-pdfs": "node test/run-decktape.js",
|
"test:generate-pdfs": "node test/run-decktape.js",
|
||||||
|
"test:generate-snapshot-screenshots": "SNAPSHOT=true playwright test --update-snapshots",
|
||||||
"test": "playwright test"
|
"test": "playwright test"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
|
@ -49,6 +49,7 @@ const config: PlaywrightTestConfig = {
|
|||||||
webServer: {
|
webServer: {
|
||||||
command: `node test/run-server.js ${port}`,
|
command: `node test/run-server.js ${port}`,
|
||||||
port,
|
port,
|
||||||
|
reuseExistingServer: true,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -6,7 +6,10 @@ test.describe("e2e", () => {
|
|||||||
|
|
||||||
inputDirectories.forEach((input) => {
|
inputDirectories.forEach((input) => {
|
||||||
test(`should have no visual regression for ${input}`, async ({ page }) => {
|
test(`should have no visual regression for ${input}`, async ({ page }) => {
|
||||||
await page.goto(`/show-pdf.html?file=${input}`);
|
const dir = process.env.SNAPSHOT === 'true' ? 'snapshot' : 'output';
|
||||||
|
const url = `/show-pdf.html?file=${encodeURIComponent(`${dir}/${input}.pdf`)}`;
|
||||||
|
console.log(url);
|
||||||
|
await page.goto(url);
|
||||||
await page.waitForFunction(() => typeof deck === "object");
|
await page.waitForFunction(() => typeof deck === "object");
|
||||||
const theCanvas = page.locator("#the-canvas");
|
const theCanvas = page.locator("#the-canvas");
|
||||||
const numberOfPages = await page.evaluate(async () => deck.numPages);
|
const numberOfPages = await page.evaluate(async () => deck.numPages);
|
||||||
|
Before Width: | Height: | Size: 72 KiB |
Before Width: | Height: | Size: 58 KiB |
Before Width: | Height: | Size: 31 KiB |
Before Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 55 KiB |
Before Width: | Height: | Size: 97 KiB |
Before Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 45 KiB |
Before Width: | Height: | Size: 67 KiB |
Before Width: | Height: | Size: 53 KiB |
Before Width: | Height: | Size: 70 KiB |
Before Width: | Height: | Size: 63 KiB |
Before Width: | Height: | Size: 61 KiB |
Before Width: | Height: | Size: 90 KiB |
Before Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 266 KiB |
Before Width: | Height: | Size: 74 KiB |
Before Width: | Height: | Size: 62 KiB |
Before Width: | Height: | Size: 220 KiB |
Before Width: | Height: | Size: 43 KiB |
Before Width: | Height: | Size: 51 KiB |
Before Width: | Height: | Size: 59 KiB |
Before Width: | Height: | Size: 141 KiB |
Before Width: | Height: | Size: 51 KiB |
Before Width: | Height: | Size: 50 KiB |
Before Width: | Height: | Size: 61 KiB |
Before Width: | Height: | Size: 82 KiB |
Before Width: | Height: | Size: 84 KiB |
Before Width: | Height: | Size: 74 KiB |
Before Width: | Height: | Size: 63 KiB |
Before Width: | Height: | Size: 63 KiB |
Before Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 55 KiB |
Before Width: | Height: | Size: 78 KiB |
Before Width: | Height: | Size: 100 KiB |
Before Width: | Height: | Size: 75 KiB |
Before Width: | Height: | Size: 49 KiB |
@ -11,7 +11,7 @@
|
|||||||
<script src="https://cdn.jsdelivr.net/npm/pdfjs-dist@3.1.81/build/pdf.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/pdfjs-dist@3.1.81/build/pdf.min.js"></script>
|
||||||
<script type="module">
|
<script type="module">
|
||||||
const params = new URLSearchParams(window.location.search);
|
const params = new URLSearchParams(window.location.search);
|
||||||
const pdf = await pdfjsLib.getDocument(`./output/${params.get('file')}.pdf`).promise;
|
const pdf = await pdfjsLib.getDocument(params.get('file')).promise;
|
||||||
let currentPage = 1;
|
let currentPage = 1;
|
||||||
await renderPage();
|
await renderPage();
|
||||||
|
|
||||||
|