@@ -10,28 +10,28 @@ type APIPatchMessageRequestTestCase = {
1010 expectedResponse ?: PatchMessageResponseBody | PatchErrorMessageBody ;
1111} ;
1212
13- type PatchMessageRequestBody = {
13+ export type PatchMessageRequestBody = {
1414 data : {
1515 type : string ;
1616 id : string ;
1717 attributes : {
18- reasonCode : number ;
19- reasonText : string ;
18+ reasonCode ? : number ;
19+ reasonText ? : string ;
2020 status : string ;
2121 } ;
2222 } ;
2323} ;
2424
25- type PatchMessageResponseBody = {
25+ export type PatchMessageResponseBody = {
2626 data : {
2727 type : string ;
2828 id : string ;
2929 attributes : {
30- reasonCode : number ;
31- reasonText : string ;
30+ reasonCode ? : number ;
31+ reasonText ? : string ;
3232 status : string ;
3333 specificationId :string ;
34- groupId :string ;
34+ groupId ? :string ;
3535 } ;
3636 } ;
3737} ;
@@ -49,15 +49,15 @@ type PatchErrorResponse = {
4949 detail : string ;
5050} ;
5151
52- type PatchErrorMessageBody = {
52+ export type PatchErrorMessageBody = {
5353 errors : PatchErrorResponse [ ] ;
5454} ;
5555
5656
5757
5858export const apiPatchMessageRequestTestData : APIPatchMessageRequestTestCase [ ] = [
5959 {
60- testCase : '200 response if record is updated and status is REJECTED' ,
60+ testCase : '200 response if record is updated with status REJECTED' ,
6161 id : '00c61654-24f0-410e-a77e-04deef7d1eeb' ,
6262 body : {
6363 data : {
@@ -86,6 +86,34 @@ export const apiPatchMessageRequestTestData: APIPatchMessageRequestTestCase[] =
8686 } ,
8787 } ,
8888
89+ {
90+ testCase : '200 response if record is updated with status ACCEPTED' ,
91+ id : '00c61654-24f0-410e-a77e-04deef7d1eeb' ,
92+ body : {
93+ data : {
94+ type : 'Letter' ,
95+ id : '00c61654-24f0-410e-a77e-04deef7d1eeb' ,
96+ attributes : {
97+ status : 'ACCEPTED' ,
98+ } ,
99+ }
100+ } ,
101+ expectedStatus : 200 ,
102+ expectedResponse : {
103+ data : {
104+ type : 'Letter' ,
105+ id : '00c61654-24f0-410e-a77e-04deef7d1eeb' ,
106+ attributes : {
107+ reasonCode : 123 ,
108+ reasonText : 'Test Reason Text' ,
109+ status : 'ACCEPTED' ,
110+ specificationId :'specification-id' ,
111+ groupId :'group-id'
112+ } ,
113+ }
114+ } ,
115+ } ,
116+
89117 {
90118 testCase : '400 response if request body is invalid' ,
91119 id : '00c61654-24f0-410e-a77e-04deef7d1eeb' ,
@@ -114,4 +142,31 @@ export const apiPatchMessageRequestTestData: APIPatchMessageRequestTestCase[] =
114142 } ]
115143 } ,
116144 } ,
145+
146+ {
147+ testCase : '500 response if id doesnt exist supplierid' ,
148+ id : '0' ,
149+ body : {
150+ data : {
151+ type : 'Letter' ,
152+ id : '0' ,
153+ attributes : {
154+ status : 'ACCEPTED' ,
155+ } ,
156+ }
157+ } ,
158+ expectedStatus : 500 ,
159+ expectedResponse : {
160+ errors : [ {
161+ id : '1234' ,
162+ code : 'NOTIFY_INTERNAL_SERVER_ERROR' ,
163+ links : {
164+ about : "https://digital.nhs.uk/developer/api-catalogue/nhs-notify-supplier"
165+ } ,
166+ status : '500' ,
167+ title : 'Internal server error' ,
168+ detail : 'Letter with id 0 not found for supplier supplier-id'
169+ } ]
170+ } ,
171+ } ,
117172] ;
0 commit comments