Skip to content

Commit 0bd3450

Browse files
committed
TestRun modal. Image details are added
1 parent a264895 commit 0bd3450

File tree

3 files changed

+68
-37
lines changed

3 files changed

+68
-37
lines changed

src/components/ImageDetails.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import React from "react";
2+
import { Typography } from "@material-ui/core";
3+
import { staticService } from "../services";
4+
import useImage from "use-image";
5+
6+
interface IProps {
7+
type: "Baseline" | "Image" | "Diff";
8+
imageName: string;
9+
}
10+
11+
const ImageDetails: React.FunctionComponent<IProps> = ({ type, imageName }) => {
12+
const [image] = useImage(staticService.getImage(imageName));
13+
return (
14+
<React.Fragment>
15+
<Typography>{type}</Typography>
16+
{imageName ? (
17+
<React.Fragment>
18+
<Typography variant='caption'>Real size: {`${image?.width} x ${image?.height}`}</Typography>
19+
</React.Fragment>
20+
) : (
21+
<Typography variant='caption'>No image</Typography>
22+
)}
23+
</React.Fragment>
24+
);
25+
};
26+
27+
export default ImageDetails;

src/components/TestDetailsModal.tsx

Lines changed: 35 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
Box,
1212
} from "@material-ui/core";
1313
import { TestRun } from "../types";
14-
import { createStyles, makeStyles, Theme } from "@material-ui/core/styles";
1514
import { testRunService, testVariationService } from "../services";
1615
import DrawArea from "./DrawArea";
1716
import { TestStatus } from "../types/testStatus";
@@ -20,21 +19,13 @@ import { IgnoreArea } from "../types/ignoreArea";
2019
import { KonvaEventObject } from "konva/types/Node";
2120
import { Close, Add, Delete, Save } from "@material-ui/icons";
2221
import TestStatusChip from "./TestStatusChip";
23-
24-
const useStyles = makeStyles((theme: Theme) =>
25-
createStyles({
26-
appBar: {
27-
position: "relative",
28-
},
29-
})
30-
);
22+
import ImageDetails from "./ImageDetails";
3123

3224
const TestDetailsModal: React.FunctionComponent<{
3325
testRun: TestRun;
3426
updateTestRun: (testRun: TestRun) => void;
3527
}> = ({ testRun, updateTestRun }) => {
3628
const history = useHistory();
37-
const classes = useStyles();
3829

3930
const [isDiffShown, setIsDiffShown] = useState(!!testRun.diffName);
4031
const [selectedRectId, setSelectedRectId] = React.useState<string>();
@@ -79,7 +70,7 @@ const TestDetailsModal: React.FunctionComponent<{
7970
when={!isIgnoreAreasSaved()}
8071
message={`You have unsaved changes that will be lost`}
8172
/>
82-
<AppBar className={classes.appBar}>
73+
<AppBar position="sticky">
8374
<Toolbar>
8475
<Grid container justify="space-between">
8576
<Grid item>
@@ -214,6 +205,9 @@ const TestDetailsModal: React.FunctionComponent<{
214205
</Box>
215206
<Grid container>
216207
<Grid item xs={6}>
208+
<Box m={1}>
209+
<ImageDetails type="Baseline" imageName={testRun.baselineName} />
210+
</Box>
217211
<DrawArea
218212
width={stageWidth}
219213
height={stageHeigth}
@@ -227,27 +221,37 @@ const TestDetailsModal: React.FunctionComponent<{
227221
</Grid>
228222
<Grid item xs={6}>
229223
{isDiffShown ? (
230-
<DrawArea
231-
width={stageWidth}
232-
height={stageHeigth}
233-
imageUrl={testRun.diffName}
234-
ignoreAreas={ignoreAreas}
235-
setIgnoreAreas={setIgnoreAreas}
236-
selectedRectId={selectedRectId}
237-
setSelectedRectId={setSelectedRectId}
238-
onStageClick={removeSelection}
239-
/>
224+
<React.Fragment>
225+
<Box m={1}>
226+
<ImageDetails type="Diff" imageName={testRun.diffName} />
227+
</Box>
228+
<DrawArea
229+
width={stageWidth}
230+
height={stageHeigth}
231+
imageUrl={testRun.diffName}
232+
ignoreAreas={ignoreAreas}
233+
setIgnoreAreas={setIgnoreAreas}
234+
selectedRectId={selectedRectId}
235+
setSelectedRectId={setSelectedRectId}
236+
onStageClick={removeSelection}
237+
/>
238+
</React.Fragment>
240239
) : (
241-
<DrawArea
242-
width={stageWidth}
243-
height={stageHeigth}
244-
imageUrl={testRun.imageName}
245-
ignoreAreas={ignoreAreas}
246-
setIgnoreAreas={setIgnoreAreas}
247-
selectedRectId={selectedRectId}
248-
setSelectedRectId={setSelectedRectId}
249-
onStageClick={removeSelection}
250-
/>
240+
<React.Fragment>
241+
<Box m={1}>
242+
<ImageDetails type="Image" imageName={testRun.imageName} />
243+
</Box>
244+
<DrawArea
245+
width={stageWidth}
246+
height={stageHeigth}
247+
imageUrl={testRun.imageName}
248+
ignoreAreas={ignoreAreas}
249+
setIgnoreAreas={setIgnoreAreas}
250+
selectedRectId={selectedRectId}
251+
setSelectedRectId={setSelectedRectId}
252+
onStageClick={removeSelection}
253+
/>
254+
</React.Fragment>
251255
)}
252256
</Grid>
253257
</Grid>

src/types/testStatus.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
export enum TestStatus {
2-
new = 'new',
3-
ok = 'ok',
4-
unresolved = 'unresolved',
5-
failed = 'failed',
6-
}
7-
2+
new = "new",
3+
ok = "ok",
4+
unresolved = "unresolved",
5+
failed = "failed",
6+
approved = "approved",
7+
}

0 commit comments

Comments
 (0)