@@ -8,7 +8,7 @@ import { TestResult, TestResultStat } from '../shared/models/test-result';
8
8
export class TestResultService extends SimpleRequester {
9
9
10
10
getTestResult ( testresult : TestResult ) : Promise < TestResult [ ] > {
11
- testresult . project_id = this . route . snapshot . params [ 'projectId' ] ;
11
+ testresult = this . setProjectId ( testresult ) ;
12
12
return this . doGet ( '/testresult' , testresult ) . map ( res => res . json ( ) ) . toPromise ( ) ;
13
13
}
14
14
@@ -19,7 +19,7 @@ export class TestResultService extends SimpleRequester {
19
19
20
20
bulkUpdate ( testresults : TestResult [ ] ) : Promise < void > {
21
21
testresults . forEach ( testresult => {
22
- testresult . project_id = this . route . snapshot . params [ 'projectId' ] ;
22
+ testresult = this . setProjectId ( testresult ) ;
23
23
if ( testresult . test_resolution ) {
24
24
testresult . test_resolution_id = testresult . test_resolution . id ;
25
25
}
@@ -31,12 +31,21 @@ export class TestResultService extends SimpleRequester {
31
31
}
32
32
33
33
removeTestResult ( testresult : TestResult ) : Promise < void > {
34
+ testresult = this . setProjectId ( testresult ) ;
34
35
return this . doDelete ( `/testrun?id=${ testresult . id } &project_id=${ testresult . project_id } ` )
35
36
. map ( ( ) => this . handleSuccess ( `Test result '${ testresult . id } ' was deleted.` ) ) . toPromise ( ) ;
36
37
}
37
38
38
- getTestResultsStat ( projectId , testRunStartedFrom , testRunStartedTo ) : Promise < TestResultStat [ ] > {
39
- const params = { projectId , testRunStartedFrom, testRunStartedTo } ;
39
+ getTestResultsStat ( project_id : number , testRunStartedFrom : string , testRunStartedTo : string ) : Promise < TestResultStat [ ] > {
40
+ const params = { project_id , testRunStartedFrom, testRunStartedTo } ;
40
41
return this . doGet ( `/stats/testresult` , params ) . map ( res => res . json ( ) ) . toPromise ( ) ;
41
42
}
43
+
44
+ private setProjectId ( testResult : TestResult ) : TestResult {
45
+ if ( ! testResult . project_id ) {
46
+ testResult . project_id = this . route . snapshot . params . projectId ;
47
+ }
48
+
49
+ return testResult ;
50
+ }
42
51
}
0 commit comments