@@ -12,7 +12,7 @@ import {
1212} from "@material-ui/core" ;
1313import { TestRun } from "../types" ;
1414import { createStyles , makeStyles , Theme } from "@material-ui/core/styles" ;
15- import { testsService } from "../services" ;
15+ import { testRunService , testVariationService } from "../services" ;
1616import DrawArea from "./DrawArea" ;
1717import { TestStatus } from "../types/testStatus" ;
1818import { useHistory , Prompt } from "react-router-dom" ;
@@ -36,17 +36,15 @@ const TestDetailsModal: React.FunctionComponent<{
3636 const history = useHistory ( ) ;
3737 const classes = useStyles ( ) ;
3838
39- const [ isDiffShown , setIsDiffShown ] = useState (
40- testRun . status === TestStatus . unresolved
41- ) ;
39+ const [ isDiffShown , setIsDiffShown ] = useState ( ! ! testRun . diffName ) ;
4240 const [ selectedRectId , setSelectedRectId ] = React . useState < string > ( ) ;
4341
4442 const [ ignoreAreas , setIgnoreAreas ] = React . useState < IgnoreArea [ ] > (
45- JSON . parse ( testRun . testVariation . ignoreAreas )
43+ JSON . parse ( testRun . ignoreAreas )
4644 ) ;
4745
4846 React . useEffect ( ( ) => {
49- setIgnoreAreas ( JSON . parse ( testRun . testVariation . ignoreAreas ) ) ;
47+ setIgnoreAreas ( JSON . parse ( testRun . ignoreAreas ) ) ;
5048 } , [ testRun ] ) ;
5149
5250 const removeSelection = ( event : KonvaEventObject < MouseEvent > ) => {
@@ -72,7 +70,7 @@ const TestDetailsModal: React.FunctionComponent<{
7270 } ;
7371
7472 const isIgnoreAreasSaved = ( ) => {
75- return testRun . testVariation . ignoreAreas === JSON . stringify ( ignoreAreas ) ;
73+ return testRun . ignoreAreas === JSON . stringify ( ignoreAreas ) ;
7674 } ;
7775
7876 return (
@@ -85,24 +83,22 @@ const TestDetailsModal: React.FunctionComponent<{
8583 < Toolbar >
8684 < Grid container justify = "space-between" >
8785 < Grid item >
88- < Typography variant = "h6" > { testRun . testVariation . name } </ Typography >
86+ < Typography variant = "h6" > { testRun . name } </ Typography >
87+ </ Grid >
88+ < Grid item >
89+ < Switch
90+ checked = { isDiffShown }
91+ onChange = { ( ) => setIsDiffShown ( ! isDiffShown ) }
92+ name = "Show diff"
93+ />
8994 </ Grid >
90- { testRun . status === TestStatus . unresolved && (
91- < Grid item >
92- < Switch
93- checked = { isDiffShown }
94- onChange = { ( ) => setIsDiffShown ( ! isDiffShown ) }
95- name = "Show diff"
96- />
97- </ Grid >
98- ) }
9995 { ( testRun . status === TestStatus . unresolved ||
10096 testRun . status === TestStatus . new ) && (
10197 < Grid item >
10298 < Button
10399 color = "inherit"
104100 onClick = { ( ) =>
105- testsService . approve ( testRun . id ) . then ( ( testRun ) => {
101+ testRunService . approve ( testRun . id ) . then ( ( testRun ) => {
106102 updateTestRun ( testRun ) ;
107103 } )
108104 }
@@ -112,7 +108,7 @@ const TestDetailsModal: React.FunctionComponent<{
112108 < Button
113109 color = "secondary"
114110 onClick = { ( ) =>
115- testsService
111+ testRunService
116112 . reject ( testRun . id )
117113 . then ( ( testRun ) => updateTestRun ( testRun ) )
118114 }
@@ -135,30 +131,24 @@ const TestDetailsModal: React.FunctionComponent<{
135131 < Paper variant = "outlined" >
136132 < Grid container spacing = { 2 } >
137133 < Grid item >
138- < Typography > OS: { testRun . testVariation . os } </ Typography >
134+ < Typography > OS: { testRun . os } </ Typography >
139135 </ Grid >
140136 < Grid item >
141- < Typography >
142- Browser: { testRun . testVariation . browser }
143- </ Typography >
137+ < Typography > Browser: { testRun . browser } </ Typography >
144138 </ Grid >
145139 < Grid item >
146- < Typography >
147- Viewport: { testRun . testVariation . viewport }
148- </ Typography >
140+ < Typography > Viewport: { testRun . viewport } </ Typography >
149141 </ Grid >
150142 < Grid item >
151- < Typography >
152- Diff: { testRun . diffPercent } %
153- </ Typography >
143+ < Typography > Diff: { testRun . diffPercent } %</ Typography >
154144 </ Grid >
155145 < Grid item >
156146 < Typography >
157147 Diff tollerance: { testRun . diffTollerancePercent } %
158148 </ Typography >
159149 </ Grid >
160150 < Grid item >
161- < Typography display = ' inline' > Status: </ Typography >
151+ < Typography display = " inline" > Status: </ Typography >
162152 < TestStatusChip status = { testRun . status } />
163153 </ Grid >
164154 </ Grid >
@@ -202,14 +192,16 @@ const TestDetailsModal: React.FunctionComponent<{
202192 < IconButton
203193 disabled = { isIgnoreAreasSaved ( ) }
204194 onClick = { ( ) => {
205- testsService
206- . setIgnoreAreas ( testRun . testVariation . id , ignoreAreas )
207- . then ( ( testVariation ) =>
208- updateTestRun ( {
209- ...testRun ,
210- testVariation,
211- } )
212- ) ;
195+ // update in test run
196+ testRunService
197+ . setIgnoreAreas ( testRun . id , ignoreAreas )
198+ . then ( ( testRun ) => updateTestRun ( testRun ) ) ;
199+
200+ // update in variation
201+ testVariationService . setIgnoreAreas (
202+ testRun . testVariationId ,
203+ ignoreAreas
204+ ) ;
213205 } }
214206 >
215207 < Save />
@@ -225,7 +217,7 @@ const TestDetailsModal: React.FunctionComponent<{
225217 < DrawArea
226218 width = { stageWidth }
227219 height = { stageHeigth }
228- imageUrl = { testRun . testVariation . baselineName }
220+ imageUrl = { testRun . baselineName }
229221 ignoreAreas = { [ ] }
230222 setIgnoreAreas = { setIgnoreAreas }
231223 selectedRectId = { selectedRectId }
0 commit comments