From be8cfeb8c2553c63e6a8b2d79c47e4cd43950bbc Mon Sep 17 00:00:00 2001 From: Jeremias Peier Date: Mon, 27 May 2024 10:17:50 +0200 Subject: [PATCH 1/4] test: test visual regression focus without waiting --- src/components/core/testing/private/fixture.ts | 2 +- .../core/testing/private/visual-regression-snapshot.ts | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/components/core/testing/private/fixture.ts b/src/components/core/testing/private/fixture.ts index 444971dd05..32dde0b039 100644 --- a/src/components/core/testing/private/fixture.ts +++ b/src/components/core/testing/private/fixture.ts @@ -91,7 +91,7 @@ export async function visualRegressionFixture( const fix = await fixture( html`
${template}
`, diff --git a/src/components/core/testing/private/visual-regression-snapshot.ts b/src/components/core/testing/private/visual-regression-snapshot.ts index b27da02bdf..501f1bb538 100644 --- a/src/components/core/testing/private/visual-regression-snapshot.ts +++ b/src/components/core/testing/private/visual-regression-snapshot.ts @@ -2,8 +2,6 @@ import { aTimeout } from '@open-wc/testing'; import { resetMouse, sendKeys, sendMouse } from '@web/test-runner-commands'; import { visualDiff } from '@web/test-runner-visual-regression'; -import { waitForCondition } from '../wait-for-condition.js'; - export function imageName(test: Mocha.Runnable): string { return test!.fullTitle().replaceAll(', ', '-').replaceAll(' ', '_'); } @@ -30,12 +28,8 @@ export function testVisualDiff(snapshotElement: () => HTMLElement): void { export function testVisualDiffFocus(snapshotElement: () => HTMLElement): void { it('focus', async function () { - await waitForCondition(() => { - snapshotElement().focus(); - return document.activeElement === snapshotElement(); - }); + snapshotElement().focus(); await sendKeys({ press: 'Tab' }); - await aTimeout(60); await visualDiff(snapshotElement(), imageName(this.test!)); }); } From e0a0d6ead11e22f34aa4fc87b1172fc6ad0aad40 Mon Sep 17 00:00:00 2001 From: Jeremias Peier Date: Tue, 28 May 2024 19:37:29 +0200 Subject: [PATCH 2/4] fix: stabilize --- .github/workflows/continuous-integration-secure.yml | 4 ++-- src/components/lead-container/lead-container.snapshot.spec.ts | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/continuous-integration-secure.yml b/.github/workflows/continuous-integration-secure.yml index 903665120f..6a2aab05d6 100644 --- a/.github/workflows/continuous-integration-secure.yml +++ b/.github/workflows/continuous-integration-secure.yml @@ -154,7 +154,7 @@ jobs: ...(success ? { status: 'completed', conclusion: 'success' } : { status: 'in_progress' }), }); - // If we have no screenshots, we do not need to create a check or containers. + // If we have no screenshots, we do not need to create a check. if (!readdirSync('dist/screenshots').length) { await createCheck(true); return 'empty'; @@ -181,7 +181,7 @@ jobs: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Add label and create container - if: steps.screenshot-check.outputs.result == 'changed' + if: steps.screenshot-check.outputs.result == 'changed' || steps.screenshot-check.outputs.result == 'empty' run: | echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin docker build \ diff --git a/src/components/lead-container/lead-container.snapshot.spec.ts b/src/components/lead-container/lead-container.snapshot.spec.ts index b34771ad19..e4a38ea63f 100644 --- a/src/components/lead-container/lead-container.snapshot.spec.ts +++ b/src/components/lead-container/lead-container.snapshot.spec.ts @@ -110,7 +110,7 @@ describe(`sbb-lead-container`, () => { testVisualDiff(() => root); }); - describe('with img tag', () => { + describe('with img tag', async () => { beforeEach(async function () { root = await visualRegressionFixture( leadContainerTemplate( @@ -125,6 +125,8 @@ describe(`sbb-lead-container`, () => { ); }); + await waitForCondition(() => root.querySelector('img')!.complete); + testVisualDiff(() => root); }); }); From bf1964c0b39de047b5c736fea2478afe2b0c9358 Mon Sep 17 00:00:00 2001 From: Jeremias Peier Date: Wed, 29 May 2024 08:49:40 +0200 Subject: [PATCH 3/4] fix: try ignoring single letter change --- tools/web-test-runner/visual-regression-plugin-config.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/web-test-runner/visual-regression-plugin-config.js b/tools/web-test-runner/visual-regression-plugin-config.js index e127d69852..6bfb426119 100644 --- a/tools/web-test-runner/visual-regression-plugin-config.js +++ b/tools/web-test-runner/visual-regression-plugin-config.js @@ -60,4 +60,7 @@ export const visualRegressionConfig = (update) => 'utf8', ); }, + diffOptions: { + includeAA: false, + }, }); From bdfcc4eb371664e5528922764f42d34100f6b11d Mon Sep 17 00:00:00 2001 From: Jeri Peier Date: Mon, 3 Jun 2024 16:29:34 +0200 Subject: [PATCH 4/4] fix: review Co-authored-by: Lukas Spirig --- tools/web-test-runner/visual-regression-plugin-config.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/tools/web-test-runner/visual-regression-plugin-config.js b/tools/web-test-runner/visual-regression-plugin-config.js index 6bfb426119..e127d69852 100644 --- a/tools/web-test-runner/visual-regression-plugin-config.js +++ b/tools/web-test-runner/visual-regression-plugin-config.js @@ -60,7 +60,4 @@ export const visualRegressionConfig = (update) => 'utf8', ); }, - diffOptions: { - includeAA: false, - }, });