diff --git a/packages/web/src/shared/imageDiffView.tsx b/packages/web/src/shared/imageDiffView.tsx index b34393c69c85b..0247afbb4c237 100644 --- a/packages/web/src/shared/imageDiffView.tsx +++ b/packages/web/src/shared/imageDiffView.tsx @@ -64,7 +64,8 @@ export const ImageDiffView: React.FC<{ noTargetBlank?: boolean, hideDetails?: boolean, }> = ({ diff, noTargetBlank, hideDetails }) => { - const [mode, setMode] = React.useState<'diff' | 'actual' | 'expected' | 'slider' | 'sxs'>(diff.diff ? 'diff' : 'actual'); + const [mode, setMode] = React.useState<'diff' | 'actual' | 'expected' | 'slider' | 'sxs' | 'blink'>(diff.diff ? 'diff' : 'actual'); + const [blinkExpected, setBlinkExpected] = React.useState(false); const [showSxsDiff, setShowSxsDiff] = React.useState(false); const [expectedImage, setExpectedImage] = React.useState(null); @@ -82,6 +83,13 @@ export const ImageDiffView: React.FC<{ })(); }, [diff]); + React.useEffect(() => { + if (mode !== 'blink') + return; + const interval = window.setInterval(() => setBlinkExpected(expected => !expected), 500); + return () => window.clearInterval(interval); + }, [mode]); + const isLoaded = expectedImage && actualImage && diffImage; const imageWidth = isLoaded ? Math.max(expectedImage.naturalWidth, actualImage.naturalWidth, 200) : 500; @@ -105,18 +113,21 @@ export const ImageDiffView: React.FC<{ {modeTab('expected', expectedImageTitle)} {modeTab('sxs', 'Side by side')} {modeTab('slider', 'Slider')} + {modeTab('blink', 'Blink')}
{diff.diff && mode === 'diff' && } {diff.diff && mode === 'actual' && } {diff.diff && mode === 'expected' && } {diff.diff && mode === 'slider' && } + {diff.diff && mode === 'blink' && } {diff.diff && mode === 'sxs' &&
setShowSxsDiff(!showSxsDiff)} hideSize={hideDetails} canvasWidth={sxsScale * imageWidth} canvasHeight={sxsScale * imageHeight} scale={sxsScale} />
} {!diff.diff && mode === 'actual' && } {!diff.diff && mode === 'expected' && } + {!diff.diff && mode === 'blink' && } {!diff.diff && mode === 'sxs' &&
diff --git a/tests/playwright-test/reporter-html.spec.ts b/tests/playwright-test/reporter-html.spec.ts index 2bd3d56d4ac97..61e286df5cedb 100644 --- a/tests/playwright-test/reporter-html.spec.ts +++ b/tests/playwright-test/reporter-html.spec.ts @@ -218,6 +218,7 @@ for (const useIntermediateMergeReport of [true, false] as const) { 'Expected', 'Side by side', 'Slider', + 'Blink', ]); for (const testId of ['test-results-image-diff', 'test-screenshot-error-view']) { @@ -252,6 +253,12 @@ for (const useIntermediateMergeReport of [true, false] as const) { await expect(imageDiff.locator('img').first()).toHaveAttribute('alt', 'Expected'); await expect(imageDiff.locator('img').last()).toHaveAttribute('alt', 'Actual'); }); + + await test.step('Blink', async () => { + await imageDiff.getByRole('tab', { name: 'Blink' }).click(); + await expect.poll(() => imageDiff.locator('img').getAttribute('alt')).toBe('Actual'); + await expect.poll(() => imageDiff.locator('img').getAttribute('alt')).toBe('Expected'); + }); }); } });