11import { TestRun } from "../types" ;
22import { handleResponse , authHeader } from "../_helpers/service.helpers" ;
33import { API_URL } from "../_config/env.config" ;
4- import { IgnoreArea } from "../types/ignoreArea" ;
4+ import { UpdateIgnoreAreaDto } from "../types/ignoreArea" ;
55
66const ENDPOINT_URL = "/test-runs" ;
77
@@ -17,61 +17,74 @@ async function getList(buildId: string): Promise<TestRun[]> {
1717 ) . then ( handleResponse ) ;
1818}
1919
20- async function remove ( id : string ) : Promise < TestRun > {
20+ async function removeBulk ( ids : string [ ] ) : Promise < void > {
2121 const requestOptions = {
22- method : "DELETE" ,
23- headers : authHeader ( ) ,
22+ method : "POST" ,
23+ headers : { "Content-Type" : "application/json" , ...authHeader ( ) } ,
24+ body : JSON . stringify ( ids ) ,
2425 } ;
2526
26- return fetch ( `${ API_URL } ${ ENDPOINT_URL } /${ id } ` , requestOptions ) . then (
27+ return fetch ( `${ API_URL } ${ ENDPOINT_URL } /delete ` , requestOptions ) . then (
2728 handleResponse
2829 ) ;
2930}
3031
31- async function approve ( id : string , merge : boolean ) : Promise < TestRun > {
32+ async function rejectBulk ( ids : string [ ] ) : Promise < void > {
3233 const requestOptions = {
33- method : "GET" ,
34- headers : authHeader ( ) ,
34+ method : "POST" ,
35+ headers : { "Content-Type" : "application/json" , ...authHeader ( ) } ,
36+ body : JSON . stringify ( ids ) ,
37+ } ;
38+
39+ return fetch ( `${ API_URL } ${ ENDPOINT_URL } /reject` , requestOptions ) . then (
40+ handleResponse
41+ ) ;
42+ }
43+
44+ async function approveBulk ( ids : string [ ] , merge : boolean ) : Promise < void > {
45+ const requestOptions = {
46+ method : "POST" ,
47+ headers : { "Content-Type" : "application/json" , ...authHeader ( ) } ,
48+ body : JSON . stringify ( ids ) ,
3549 } ;
3650
3751 return fetch (
38- `${ API_URL } ${ ENDPOINT_URL } /approve?id= ${ id } & merge=${ merge } ` ,
52+ `${ API_URL } ${ ENDPOINT_URL } /approve?merge=${ merge } ` ,
3953 requestOptions
4054 ) . then ( handleResponse ) ;
4155}
4256
43- async function reject ( id : string ) : Promise < TestRun > {
57+ async function updateIgnoreAreas ( data : UpdateIgnoreAreaDto ) : Promise < void > {
4458 const requestOptions = {
45- method : "GET" ,
46- headers : authHeader ( ) ,
59+ method : "POST" ,
60+ headers : { "Content-Type" : "application/json" , ...authHeader ( ) } ,
61+ body : JSON . stringify ( data ) ,
4762 } ;
4863
49- return fetch ( `${ API_URL } ${ ENDPOINT_URL } /reject/${ id } ` , requestOptions ) . then (
50- handleResponse
51- ) ;
64+ return fetch (
65+ `${ API_URL } ${ ENDPOINT_URL } /ignoreAreas/update` ,
66+ requestOptions
67+ ) . then ( handleResponse ) ;
5268}
5369
54- async function setIgnoreAreas (
55- id : string ,
56- ignoreAreas : IgnoreArea [ ]
57- ) : Promise < TestRun > {
70+ async function addIgnoreAreas ( data : UpdateIgnoreAreaDto ) : Promise < void > {
5871 const requestOptions = {
59- method : "PUT " ,
72+ method : "POST " ,
6073 headers : { "Content-Type" : "application/json" , ...authHeader ( ) } ,
61- body : JSON . stringify ( ignoreAreas ) ,
74+ body : JSON . stringify ( data ) ,
6275 } ;
6376
6477 return fetch (
65- `${ API_URL } ${ ENDPOINT_URL } /ignoreArea/ ${ id } ` ,
78+ `${ API_URL } ${ ENDPOINT_URL } /ignoreAreas/add ` ,
6679 requestOptions
6780 ) . then ( handleResponse ) ;
6881}
6982
70- async function setComment ( id : string , comment : string ) : Promise < TestRun > {
83+ async function update ( id : string , data : { comment : string } ) : Promise < TestRun > {
7184 const requestOptions = {
7285 method : "PUT" ,
7386 headers : { "Content-Type" : "application/json" , ...authHeader ( ) } ,
74- body : JSON . stringify ( { comment } ) ,
87+ body : JSON . stringify ( data ) ,
7588 } ;
7689
7790 return fetch ( `${ API_URL } ${ ENDPOINT_URL } /comment/${ id } ` , requestOptions ) . then (
@@ -81,9 +94,10 @@ async function setComment(id: string, comment: string): Promise<TestRun> {
8194
8295export const testRunService = {
8396 getList,
84- remove,
85- approve,
86- reject,
87- setIgnoreAreas,
88- setComment,
97+ removeBulk,
98+ rejectBulk,
99+ approveBulk,
100+ updateIgnoreAreas,
101+ addIgnoreAreas,
102+ update,
89103} ;
0 commit comments