diff --git a/.eslintrc.js b/.eslintrc.js index cba7a60d..777134fe 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -71,7 +71,8 @@ module.exports = { { files: ['test/**/*.ts'], rules: { - 'import/no-import-module-exports': 'off' + 'import/no-import-module-exports': 'off', + 'no-restricted-syntax': 'off' } } ], diff --git a/test/functional/cypress-image-diff-screenshots/baseline/visual.cy.ts-avatar-zoom-0.5-side-[-1].png b/test/functional/cypress-image-diff-screenshots/baseline/visual.cy.ts-avatar-zoom-0.5-side-[-1].png new file mode 100755 index 00000000..4c898d6b Binary files /dev/null and b/test/functional/cypress-image-diff-screenshots/baseline/visual.cy.ts-avatar-zoom-0.5-side-[-1].png differ diff --git a/test/functional/cypress-image-diff-screenshots/baseline/visual.cy.ts-avatar-zoom-0.5-side-[1].png b/test/functional/cypress-image-diff-screenshots/baseline/visual.cy.ts-avatar-zoom-0.5-side-[1].png new file mode 100755 index 00000000..a1eb9ef6 Binary files /dev/null and b/test/functional/cypress-image-diff-screenshots/baseline/visual.cy.ts-avatar-zoom-0.5-side-[1].png differ diff --git a/test/functional/cypress-image-diff-screenshots/baseline/visual.cy.ts-avatar-zoom-3-side-[-1].png b/test/functional/cypress-image-diff-screenshots/baseline/visual.cy.ts-avatar-zoom-3-side-[-1].png new file mode 100755 index 00000000..30601cf1 Binary files /dev/null and b/test/functional/cypress-image-diff-screenshots/baseline/visual.cy.ts-avatar-zoom-3-side-[-1].png differ diff --git a/test/functional/cypress-image-diff-screenshots/baseline/visual.cy.ts-avatar-zoom-3-side-[1].png b/test/functional/cypress-image-diff-screenshots/baseline/visual.cy.ts-avatar-zoom-3-side-[1].png new file mode 100755 index 00000000..744d27e1 Binary files /dev/null and b/test/functional/cypress-image-diff-screenshots/baseline/visual.cy.ts-avatar-zoom-3-side-[1].png differ diff --git a/test/functional/cypress/e2e/visual.cy.ts b/test/functional/cypress/e2e/visual.cy.ts index 080d3204..29c05dca 100644 --- a/test/functional/cypress/e2e/visual.cy.ts +++ b/test/functional/cypress/e2e/visual.cy.ts @@ -3,27 +3,43 @@ const VISUAL_TEST_CONFIG = Object.freeze({ head: 0.5, body: 3.0 }, + side: { + front: 1, + back: -1 + }, testUrl: 'http://localhost:3000/test', - modelUrl: 'https://api.readyplayer.dev/v3/avatars/65f82db95462c113fe5c5bb6.glb' + modelUrl: 'https://api.readyplayer.dev/v3/avatars/65f82db95462c113fe5c5bb6.glb', + testThreshold: 0.05 }); -function compareSnapshot(zoomLevel: number) { +function compareSnapshot(zoomLevel: number, side: number) { + // use zoom level to rotate camera by 180 degrees cy.visit( - `${VISUAL_TEST_CONFIG.testUrl}/?modelUrl=${encodeURIComponent(VISUAL_TEST_CONFIG.modelUrl)}&zoomLevel=${zoomLevel}` + `${VISUAL_TEST_CONFIG.testUrl}/?modelUrl=${encodeURIComponent(VISUAL_TEST_CONFIG.modelUrl)}&zoomLevel=${ + zoomLevel * side + }` ); cy.intercept(VISUAL_TEST_CONFIG.modelUrl).as('modelDownloading'); cy.wait('@modelDownloading'); cy.wait(2000); - cy.compareSnapshot(`avatar-zoom-${zoomLevel}`); + + const name = `avatar-zoom-${zoomLevel}-side-[${side}]`; + cy.compareSnapshot({ name, testThreshold: VISUAL_TEST_CONFIG.testThreshold }); } describe('visual', () => { - it('compares avatar body snapshot', () => { - compareSnapshot(VISUAL_TEST_CONFIG.zoomLevel.body); + it('compares avatar body snapshot front', () => { + compareSnapshot(VISUAL_TEST_CONFIG.zoomLevel.body, VISUAL_TEST_CONFIG.side.front); + }); + it('compares avatar body snapshot back', () => { + compareSnapshot(VISUAL_TEST_CONFIG.zoomLevel.body, VISUAL_TEST_CONFIG.side.back); + }); + it('compares avatar head snapshot front', () => { + compareSnapshot(VISUAL_TEST_CONFIG.zoomLevel.head, VISUAL_TEST_CONFIG.side.front); }); - it('compares avatar head snapshot', () => { - compareSnapshot(VISUAL_TEST_CONFIG.zoomLevel.head); + it('compares avatar head snapshot back', () => { + compareSnapshot(VISUAL_TEST_CONFIG.zoomLevel.head, VISUAL_TEST_CONFIG.side.back); }); });