Skip to content

Commit 83e2e76

Browse files
committed
recalculateDiff added
1 parent a3ecc6d commit 83e2e76

File tree

2 files changed

+33
-6
lines changed

2 files changed

+33
-6
lines changed

src/components/TestDetailsModal.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ const TestDetailsModal: React.FunctionComponent<{
8484
testRun.diffName && staticService.getImage(testRun.diffName)
8585
);
8686

87-
const [isDiffShown, setIsDiffShown] = useState(!!testRun.diffName);
87+
const [isDiffShown, setIsDiffShown] = useState(false);
8888
const [selectedRectId, setSelectedRectId] = React.useState<string>();
8989

9090
const [ignoreAreas, setIgnoreAreas] = React.useState<IgnoreArea[]>(
@@ -141,6 +141,10 @@ const TestDetailsModal: React.FunctionComponent<{
141141
// eslint-disable-next-line
142142
}, [image]);
143143

144+
React.useEffect(() => {
145+
setIsDiffShown(!!testRun.diffName);
146+
}, [testRun.diffName]);
147+
144148
return (
145149
<React.Fragment>
146150
<Prompt
@@ -241,7 +245,12 @@ const TestDetailsModal: React.FunctionComponent<{
241245
// update in test run
242246
testRunService
243247
.setIgnoreAreas(testRun.id, ignoreAreas)
244-
.then((testRun) => updateTestRun(testRun));
248+
.then(() =>
249+
// recalculate diff
250+
testRunService
251+
.recalculateDiff(testRun.id)
252+
.then((testRun) => updateTestRun(testRun))
253+
);
245254

246255
// update in variation
247256
testVariationService.setIgnoreAreas(

src/services/testRun.service.ts

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ import { handleResponse, authHeader } from "../_helpers/service.helpers";
33
import { API_URL } from "../_config/api.config";
44
import { IgnoreArea } from "../types/ignoreArea";
55

6-
const ENDPOINT_URL = "/test-runs"
6+
const ENDPOINT_URL = "/test-runs";
77

88
export const testRunService = {
99
getList,
1010
remove,
11+
recalculateDiff,
1112
approve,
1213
reject,
1314
setIgnoreAreas,
@@ -19,7 +20,10 @@ function getList(buildId: string): Promise<TestRun[]> {
1920
headers: authHeader(),
2021
};
2122

22-
return fetch(`${API_URL}${ENDPOINT_URL}?buildId=${buildId}`, requestOptions).then(handleResponse);
23+
return fetch(
24+
`${API_URL}${ENDPOINT_URL}?buildId=${buildId}`,
25+
requestOptions
26+
).then(handleResponse);
2327
}
2428

2529
function remove(id: string): Promise<Number> {
@@ -28,7 +32,21 @@ function remove(id: string): Promise<Number> {
2832
headers: authHeader(),
2933
};
3034

31-
return fetch(`${API_URL}${ENDPOINT_URL}/${id}`, requestOptions).then(handleResponse);
35+
return fetch(`${API_URL}${ENDPOINT_URL}/${id}`, requestOptions).then(
36+
handleResponse
37+
);
38+
}
39+
40+
function recalculateDiff(id: string): Promise<TestRun> {
41+
const requestOptions = {
42+
method: "GET",
43+
headers: authHeader(),
44+
};
45+
46+
return fetch(
47+
`${API_URL}${ENDPOINT_URL}/recalculateDiff/${id}`,
48+
requestOptions
49+
).then(handleResponse);
3250
}
3351

3452
function approve(id: string): Promise<TestRun> {
@@ -67,4 +85,4 @@ function setIgnoreAreas(
6785
`${API_URL}${ENDPOINT_URL}/ignoreArea/${id}`,
6886
requestOptions
6987
).then(handleResponse);
70-
}
88+
}

0 commit comments

Comments
 (0)