Skip to content

Commit 4c869c5

Browse files
authored
TestVariation. Cannot load data if TestRUn was deleted (#227)
closes Visual-Regression-Tracker/Visual-Regression-Tracker#292
1 parent 27c6d1e commit 4c869c5

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

src/pages/TestVariationDetailsPage.tsx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import {
2727
import { useSnackbar } from "notistack";
2828
import { formatDateTime } from "../_helpers/format.helper";
2929
import TestStatusChip from "../components/TestStatusChip";
30+
import { Baseline } from "../types/baseline";
3031

3132
const useStyles = makeStyles({
3233
media: {
@@ -68,39 +69,39 @@ const TestVariationDetailsPage: React.FunctionComponent = () => {
6869
<Grid item>
6970
<TestVariationDetails testVariation={testVariation} />
7071
</Grid>
71-
{testVariation.baselines.map((baseline) => (
72+
{testVariation.baselines.map((baseline: Baseline) => (
7273
<Grid item key={baseline.id}>
7374
<Card>
7475
<CardActions>
7576
<Button
7677
color="primary"
7778
disabled={!baseline.testRun}
7879
onClick={() => {
79-
if (baseline.testRun) {
80+
const { testRun } = baseline;
81+
if (testRun) {
8082
history.push({
8183
pathname: buildProjectPageUrl(
8284
testVariation.projectId
8385
),
8486
...buildTestRunLocation(
85-
baseline.testRun.buildId,
86-
baseline.testRunId
87+
testRun.buildId,
88+
testRun.id
8789
),
8890
});
8991
selectBuild(
9092
buildDispatch,
91-
baseline.testRun.buildId
93+
testRun.buildId
9294
).then(() =>
93-
selectTestRun(
94-
testRunDispatch,
95-
baseline.testRun.id
96-
)
95+
selectTestRun(testRunDispatch, testRun.id)
9796
);
9897
}
9998
}}
10099
>
101100
Test Run
102101
</Button>
103-
<TestStatusChip status={baseline.testRun.status} />
102+
{baseline.testRun && (
103+
<TestStatusChip status={baseline.testRun.status} />
104+
)}
104105
{baseline.user && (
105106
<Typography>
106107
{`${baseline.user.firstName} ${baseline.user.lastName} <${baseline.user.email}>`}

src/types/baseline.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ import { User } from "./user";
44
export interface Baseline {
55
id: string;
66
baselineName: string;
7-
testRunId: string;
87
testVariationId: string;
98
createdAt: string;
109
updatedAt: string;
11-
testRun: TestRun;
12-
user: User;
10+
testRun?: TestRun;
11+
user?: User;
1312
}

0 commit comments

Comments
 (0)