From 3074644c67ddde906cb69253fabc6ef0488247bf Mon Sep 17 00:00:00 2001 From: Jeri Peier Date: Wed, 3 Jul 2024 14:06:33 +0200 Subject: [PATCH] build: add global diff switch for visual regression app (#2884) --- .../test-case/image-diff/image-diff.ts | 12 +++--- .../src/components/test-case/test-case.scss | 17 +++++++++ .../src/components/test-case/test-case.ts | 37 ++++++++++++++++--- 3 files changed, 54 insertions(+), 12 deletions(-) diff --git a/src/visual-regression-app/src/components/test-case/image-diff/image-diff.ts b/src/visual-regression-app/src/components/test-case/image-diff/image-diff.ts index 1e3ea8c4c1..c44bf913d1 100644 --- a/src/visual-regression-app/src/components/test-case/image-diff/image-diff.ts +++ b/src/visual-regression-app/src/components/test-case/image-diff/image-diff.ts @@ -1,4 +1,4 @@ -import { LitElement, html, type TemplateResult, type CSSResultGroup, nothing } from 'lit'; +import { type CSSResultGroup, html, LitElement, nothing, type TemplateResult } from 'lit'; import { customElement, property, state } from 'lit/decorators.js'; // eslint-disable-next-line import-x/no-unresolved import { meta } from 'virtual:meta'; @@ -32,10 +32,10 @@ export class ImageDiff extends LitElement { @state() private _baselineDimension?: string; @state() private _failedDimension?: string; - @state() private _showDiff: boolean = true; + @property() public showDiff: boolean = true; private _toggleDiff(event: Event): void { - this._showDiff = (event.target as SbbToggleCheckElement).checked; + this.showDiff = (event.target as SbbToggleCheckElement).checked; } private _setFailedImageDimension(event: Event): void { @@ -88,7 +88,7 @@ export class ImageDiff extends LitElement { ${!this.screenshotFiles.isNew && this.screenshotFiles.diffFile ? html` this._showFullscreen('diffFile')} class="app-image-button" - ?hidden=${!this._showDiff || this.screenshotFiles.isNew} + ?hidden=${!this.showDiff || this.screenshotFiles.isNew} > this._showFullscreen('failedFile')} class="app-image-button" - ?hidden=${this._showDiff && !this.screenshotFiles.isNew} + ?hidden=${this.showDiff && !this.screenshotFiles.isNew} > ): void { super.willUpdate(changedProperties); @@ -86,6 +90,10 @@ export class TestCase extends LitElement { }; } + private _toggleGlobalDiff(event: Event): void { + this._showGlobalDiff = (event.target as SbbToggleCheckElement).checked; + } + public override render(): TemplateResult { return html` @@ -116,11 +124,25 @@ export class TestCase extends LitElement { ${this._testCase ? html`
- +
+ + ${this._testCase + ?.filter(this._filter.viewport, this._filter.browser) + .some((screenshotFiles) => !screenshotFiles.isNew && !!screenshotFiles.diffFile) + ? html` + Show Diff + ` + : nothing} +
@@ -128,7 +150,10 @@ export class TestCase extends LitElement { ?.filter(this._filter.viewport, this._filter.browser) .map( (screenshotFiles) => - html``, + html``, )}