Skip to content

Commit d8af6ee

Browse files
authored
Merge branch 'dev-2.0' into manual-tests-2
2 parents a11d3bc + aa73cea commit d8af6ee

File tree

10 files changed

+471
-10
lines changed

10 files changed

+471
-10
lines changed

.github/workflows/ci-test.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,23 @@ jobs:
2424
env:
2525
CI: true
2626
- name: build and test
27+
id: test
2728
run: npm test
29+
continue-on-error: true
2830
env:
2931
CI: true
32+
- name: Generate Visual Test Report
33+
if: always()
34+
run: node visual-report.js
35+
env:
36+
CI: true
37+
- name: Upload Visual Test Report
38+
if: always()
39+
uses: actions/upload-artifact@v4
40+
with:
41+
name: visual-test-report
42+
path: test/unit/visual/visual-report.html
43+
retention-days: 14
3044
- name: generate TypeScript types
3145
run: npm run generate-types
3246
env:
@@ -36,6 +50,10 @@ jobs:
3650
env:
3751
CI: true
3852
- name: report test coverage
53+
if: steps.test.outcome == 'success'
3954
run: bash <(curl -s https://codecov.io/bash) -f coverage/coverage-final.json
4055
env:
4156
CI: true
57+
- name: fail job if tests failed
58+
if: steps.test.outcome != 'success'
59+
run: exit 1

.gitignore

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,17 @@ __screenshots__/
2424
*.d.ts
2525
p5.zip
2626
yarn.lock
27+
28+
docs/data.json
29+
analyzer/
30+
preview/
31+
__screenshots__/
32+
actual-screenshots/
33+
visual-report.html
34+
2735
todo.md
2836

2937
*.DS_Store
3038
.idea
31-
.project
39+
.project
40+

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
"./core": {
8383
"default": "./dist/core/main.js"
8484
},
85+
"./color": "./dist/color/index.js",
8586
"./shape": "./dist/shape/index.js",
8687
"./accessibility": "./dist/accessibility/index.js",
8788
"./friendlyErrors": "./dist/core/friendlyErrors/index.js",

src/core/p5.Renderer2D.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,18 @@ class Renderer2D extends Renderer {
7070
}
7171
this.scale(this._pixelDensity, this._pixelDensity);
7272

73-
if(!this.filterRenderer){
74-
this.filterRenderer = new FilterRenderer2D(this);
75-
}
7673
// Set and return p5.Element
7774
this.wrappedElt = new Element(this.elt, this._pInst);
7875
this.clipPath = null;
7976
}
8077

78+
get filterRenderer() {
79+
if (!this._filterRenderer) {
80+
this._filterRenderer = new FilterRenderer2D(this);
81+
}
82+
return this._filterRenderer;
83+
}
84+
8185
remove(){
8286
this.wrappedElt.remove();
8387
this.wrappedElt = null;
Binary file not shown.

test/unit/visual/screenshots/Shape drawing/2D mode/Drawing triangles/metadata.json

Lines changed: 0 additions & 3 deletions
This file was deleted.
Binary file not shown.

test/unit/visual/screenshots/Shape drawing/WebGL mode/Drawing triangles/metadata.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

test/unit/visual/visualTest.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,9 +463,15 @@ export function visualTest(
463463
: [];
464464

465465
for (let i = 0; i < actual.length; i++) {
466+
const flatName = name.replace(/\//g, '-');
467+
const actualFilename = `../actual-screenshots/${flatName}-${i.toString().padStart(3, '0')}.png`;
466468
if (expected[i]) {
467469
const result = await checkMatch(actual[i], expected[i], myp5);
470+
// Always save the actual image before potentially throwing an error
471+
writeImageFile(actualFilename, toBase64(actual[i]));
468472
if (!result.ok) {
473+
const diffFilename = `../actual-screenshots/${flatName}-${i.toString().padStart(3, '0')}-diff.png`;
474+
writeImageFile(diffFilename, toBase64(result.diff));
469475
throw new Error(
470476
`Screenshots do not match! Expected:\n${toBase64(expected[i])}\n\nReceived:\n${toBase64(actual[i])}\n\nDiff:\n${toBase64(result.diff)}\n\n` +
471477
'If this is unexpected, paste these URLs into your browser to inspect them.\n\n' +
@@ -474,6 +480,7 @@ export function visualTest(
474480
}
475481
} else {
476482
writeImageFile(expectedFilenames[i], toBase64(actual[i]));
483+
writeImageFile(actualFilename, toBase64(actual[i]));
477484
}
478485
}
479486
});

0 commit comments

Comments
 (0)