@@ -96,10 +91,9 @@ export const TestResultView: React.FC<{
{result.steps.map((step, i) =>
)}
}
- {diffs.map(({ tabs, snapshotName, isImageDiff }, index) =>
-
- {isImageDiff && }
- {tabs.map((tab: DiffTab) => )}
+ {diffs.map((diff, index) =>
+
+
)}
@@ -154,23 +148,37 @@ const StepTreeItem: React.FC<{
} : undefined} depth={depth}>;
};
-const ImageDiff: React.FunctionComponent<{
- tabs: DiffTab[],
-}> = ({ tabs }) => {
+const ImageDiffView: React.FunctionComponent<{
+ imageDiff: ImageDiff,
+}> = ({ imageDiff: diff }) => {
// Pre-select a tab called "actual", if any.
- const preselectedTab = tabs.find(tab => tab.title.toLowerCase() === 'actual') || tabs[0];
- const [selectedTab, setSelectedTab] = React.useState(preselectedTab.id);
+ const [selectedTab, setSelectedTab] = React.useState('left');
const diffElement = React.useRef(null);
- const paneTabs = tabs.map(tab => ({
- id: tab.id,
- title: tab.title,
- render: () =>
{
- if (diffElement.current)
- diffElement.current.style.minHeight = diffElement.current.offsetHeight + 'px';
- }}/>
- }));
+ const setMinHeight = () => {
+ if (diffElement.current)
+ diffElement.current.style.minHeight = diffElement.current.offsetHeight + 'px';
+ };
+ const tabs = [
+ {
+ id: 'left',
+ title: diff.left!.title,
+ render: () =>
+ },
+ {
+ id: 'right',
+ title: diff.right!.title,
+ render: () =>
+ },
+ ];
+ if (diff.diff) {
+ tabs.push({
+ id: 'diff',
+ title: diff.diff.title,
+ render: () =>
+ });
+ }
return
-
+
;
};
diff --git a/tests/playwright-test/reporter-html.spec.ts b/tests/playwright-test/reporter-html.spec.ts
index 977fd26c40..70541318ec 100644
--- a/tests/playwright-test/reporter-html.spec.ts
+++ b/tests/playwright-test/reporter-html.spec.ts
@@ -259,9 +259,10 @@ test('should not include image diff with non-images', async ({ runInlineTest, pa
await showReport();
await page.click('text=fails');
- await expect(page.locator('text=Snapshot mismatch')).toBeVisible();
await expect(page.locator('text=Image mismatch')).toHaveCount(0);
await expect(page.locator('img')).toHaveCount(0);
+ await expect(page.locator('a', { hasText: 'expected-actual' })).toBeVisible();
+ await expect(page.locator('a', { hasText: 'expected-expected' })).toBeVisible();
});
test('should include screenshot on failure', async ({ runInlineTest, page, showReport }) => {