Skip to content

Commit

Permalink
chore: reuse image diff component in trace/html
Browse files Browse the repository at this point in the history
  • Loading branch information
pavelfeldman committed Dec 20, 2023
1 parent b33a04b commit 147c528
Show file tree
Hide file tree
Showing 12 changed files with 212 additions and 511 deletions.
47 changes: 0 additions & 47 deletions packages/html-reporter/src/imageDiffView.css

This file was deleted.

197 changes: 0 additions & 197 deletions packages/html-reporter/src/imageDiffView.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion packages/html-reporter/src/testResultView.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
}

.test-result video,
.test-result img {
.test-result img.screenshot {
flex: none;
box-shadow: var(--box-shadow-thick);
margin: 24px auto;
Expand Down
10 changes: 5 additions & 5 deletions packages/html-reporter/src/testResultView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import { AutoChip } from './chip';
import { traceImage } from './images';
import { AttachmentLink, generateTraceUrl } from './links';
import { statusIcon } from './statusIcon';
import type { ImageDiff } from './imageDiffView';
import { ImageDiffView } from './imageDiffView';
import type { ImageDiff } from '@web/shared/imageDiffView';
import { ImageDiffView } from '@web/shared/imageDiffView';
import { TestErrorView } from './testErrorView';
import './testResultView.css';

Expand Down Expand Up @@ -102,15 +102,15 @@ export const TestResultView: React.FC<{

{diffs.map((diff, index) =>
<AutoChip key={`diff-${index}`} header={`Image mismatch: ${diff.name}`} targetRef={imageDiffRef}>
<ImageDiffView key='image-diff' imageDiff={diff}></ImageDiffView>
<ImageDiffView key='image-diff' diff={diff}></ImageDiffView>
</AutoChip>
)}

{!!screenshots.length && <AutoChip header='Screenshots'>
{screenshots.map((a, i) => {
return <div key={`screenshot-${i}`}>
<a href={a.path}>
<img src={a.path} />
<img className='screenshot' src={a.path} />
</a>
<AttachmentLink attachment={a}></AttachmentLink>
</div>;
Expand All @@ -120,7 +120,7 @@ export const TestResultView: React.FC<{
{!!traces.length && <AutoChip header='Traces'>
{<div>
<a href={generateTraceUrl(traces)}>
<img src={traceImage} style={{ width: 192, height: 117, marginLeft: 20 }} />
<img className='screenshot' src={traceImage} style={{ width: 192, height: 117, marginLeft: 20 }} />
</a>
{traces.map((a, i) => <AttachmentLink key={`trace-${i}`} attachment={a} linkName={traces.length === 1 ? 'trace' : `trace-${i + 1}`}></AttachmentLink>)}
</div>}
Expand Down
4 changes: 2 additions & 2 deletions packages/trace-viewer/src/ui/attachmentsTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import * as React from 'react';
import './attachmentsTab.css';
import { ImageDiffView } from '@web/components/imageDiffView';
import { ImageDiffView } from '@web/shared/imageDiffView';
import type { MultiTraceModel } from './modelUtil';
import { PlaceholderPanel } from './placeholderPanel';
import type { AfterActionTraceEventAttachment } from '@trace/trace';
Expand Down Expand Up @@ -63,7 +63,7 @@ export const AttachmentsTab: React.FunctionComponent<{
{[...diffMap.values()].map(({ expected, actual, diff }) => {
return <>
{expected && actual && <div className='attachments-section'>Image diff</div>}
{expected && actual && <ImageDiffView imageDiff={{
{expected && actual && <ImageDiffView diff={{
name: 'Image diff',
expected: { attachment: { ...expected, path: attachmentURL(expected) }, title: 'Expected' },
actual: { attachment: { ...actual, path: attachmentURL(actual) } },
Expand Down
2 changes: 1 addition & 1 deletion packages/trace-viewer/src/ui/timeline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

import { msToString, useMeasure } from '@web/uiUtils';
import { GlassPane } from '@web/components/glassPane';
import { GlassPane } from '@web/shared/glassPane';
import * as React from 'react';
import type { Boundaries } from '../geometry';
import { FilmStrip } from './filmStrip';
Expand Down
46 changes: 0 additions & 46 deletions packages/web/src/components/imageDiffView.css

This file was deleted.

Loading

0 comments on commit 147c528

Please sign in to comment.