@@ -107,25 +107,27 @@ func TestAdminHandler_GetDocumentStatus_WithUnexpectedSignatures(t *testing.T) {
107107 t .Fatalf ("Expected status 200, got %d" , w .Code )
108108 }
109109
110- // Parse response
110+ // Parse response (API responses are wrapped under {"data": ...})
111111 var response struct {
112- DocID string `json:"docId"`
113- ExpectedSigners []struct {
114- Email string `json:"email"`
115- HasSigned bool `json:"hasSigned"`
116- } `json:"expectedSigners"`
117- UnexpectedSignatures []struct {
118- UserEmail string `json:"userEmail"`
119- UserName * string `json:"userName,omitempty"`
120- SignedAtUTC string `json:"signedAtUTC"`
121- } `json:"unexpectedSignatures"`
122- Stats struct {
123- ExpectedCount int `json:"expectedCount"`
124- SignedCount int `json:"signedCount"`
125- PendingCount int `json:"pendingCount"`
126- CompletionRate float64 `json:"completionRate"`
127- } `json:"stats"`
128- ShareLink string `json:"shareLink"`
112+ Data struct {
113+ DocID string `json:"docId"`
114+ ExpectedSigners []struct {
115+ Email string `json:"email"`
116+ HasSigned bool `json:"hasSigned"`
117+ } `json:"expectedSigners"`
118+ UnexpectedSignatures []struct {
119+ UserEmail string `json:"userEmail"`
120+ UserName * string `json:"userName,omitempty"`
121+ SignedAtUTC string `json:"signedAtUTC"`
122+ } `json:"unexpectedSignatures"`
123+ Stats struct {
124+ ExpectedCount int `json:"expectedCount"`
125+ SignedCount int `json:"signedCount"`
126+ PendingCount int `json:"pendingCount"`
127+ CompletionRate float64 `json:"completionRate"`
128+ } `json:"stats"`
129+ ShareLink string `json:"shareLink"`
130+ } `json:"data"`
129131 }
130132
131133 err = json .NewDecoder (w .Body ).Decode (& response )
@@ -134,48 +136,48 @@ func TestAdminHandler_GetDocumentStatus_WithUnexpectedSignatures(t *testing.T) {
134136 }
135137
136138 // Verify response
137- if response .DocID != docID {
138- t .Errorf ("Expected docId %s, got %s" , docID , response .DocID )
139+ if response .Data . DocID != docID {
140+ t .Errorf ("Expected docId %s, got %s" , docID , response .Data . DocID )
139141 }
140142
141143 // Check expected signers
142- if len (response .ExpectedSigners ) != 1 {
143- t .Errorf ("Expected 1 expected signer, got %d" , len (response .ExpectedSigners ))
144+ if len (response .Data . ExpectedSigners ) != 1 {
145+ t .Errorf ("Expected 1 expected signer, got %d" , len (response .Data . ExpectedSigners ))
144146 } else {
145- if response .ExpectedSigners [0 ].Email != "expected@example.com" {
146- t .Errorf ("Expected email 'expected@example.com', got '%s'" , response .ExpectedSigners [0 ].Email )
147+ if response .Data . ExpectedSigners [0 ].Email != "expected@example.com" {
148+ t .Errorf ("Expected email 'expected@example.com', got '%s'" , response .Data . ExpectedSigners [0 ].Email )
147149 }
148- if ! response .ExpectedSigners [0 ].HasSigned {
150+ if ! response .Data . ExpectedSigners [0 ].HasSigned {
149151 t .Error ("Expected signer should have signed" )
150152 }
151153 }
152154
153155 // Check unexpected signatures
154- if len (response .UnexpectedSignatures ) != 1 {
155- t .Fatalf ("Expected 1 unexpected signature, got %d" , len (response .UnexpectedSignatures ))
156+ if len (response .Data . UnexpectedSignatures ) != 1 {
157+ t .Fatalf ("Expected 1 unexpected signature, got %d" , len (response .Data . UnexpectedSignatures ))
156158 }
157- if response .UnexpectedSignatures [0 ].UserEmail != "unexpected@example.com" {
158- t .Errorf ("Expected unexpected email 'unexpected@example.com', got '%s'" , response .UnexpectedSignatures [0 ].UserEmail )
159+ if response .Data . UnexpectedSignatures [0 ].UserEmail != "unexpected@example.com" {
160+ t .Errorf ("Expected unexpected email 'unexpected@example.com', got '%s'" , response .Data . UnexpectedSignatures [0 ].UserEmail )
159161 }
160- if response .UnexpectedSignatures [0 ].UserName == nil || * response .UnexpectedSignatures [0 ].UserName != "Unexpected User" {
162+ if response .Data . UnexpectedSignatures [0 ].UserName == nil || * response . Data .UnexpectedSignatures [0 ].UserName != "Unexpected User" {
161163 t .Error ("Expected unexpected userName to be 'Unexpected User'" )
162164 }
163165
164166 // Check stats
165- if response .Stats .ExpectedCount != 1 {
166- t .Errorf ("Expected expectedCount 1, got %d" , response .Stats .ExpectedCount )
167+ if response .Data . Stats .ExpectedCount != 1 {
168+ t .Errorf ("Expected expectedCount 1, got %d" , response .Data . Stats .ExpectedCount )
167169 }
168- if response .Stats .SignedCount != 1 {
169- t .Errorf ("Expected signedCount 1, got %d" , response .Stats .SignedCount )
170+ if response .Data . Stats .SignedCount != 1 {
171+ t .Errorf ("Expected signedCount 1, got %d" , response .Data . Stats .SignedCount )
170172 }
171- if response .Stats .CompletionRate != 100.0 {
172- t .Errorf ("Expected completionRate 100.0, got %f" , response .Stats .CompletionRate )
173+ if response .Data . Stats .CompletionRate != 100.0 {
174+ t .Errorf ("Expected completionRate 100.0, got %f" , response .Data . Stats .CompletionRate )
173175 }
174176
175177 // Check share link
176178 expectedShareLink := "https://example.com/?doc=" + docID
177- if response .ShareLink != expectedShareLink {
178- t .Errorf ("Expected shareLink '%s', got '%s'" , expectedShareLink , response .ShareLink )
179+ if response .Data . ShareLink != expectedShareLink {
180+ t .Errorf ("Expected shareLink '%s', got '%s'" , expectedShareLink , response .Data . ShareLink )
179181 }
180182}
181183
@@ -228,12 +230,14 @@ func TestAdminHandler_GetDocumentStatus_NoExpectedSigners(t *testing.T) {
228230 t .Fatalf ("Expected status 200, got %d" , w .Code )
229231 }
230232
231- // Parse response
233+ // Parse response (wrapped in {"data": ...})
232234 var response struct {
233- ExpectedSigners []interface {} `json:"expectedSigners"`
234- UnexpectedSignatures []struct {
235- UserEmail string `json:"userEmail"`
236- } `json:"unexpectedSignatures"`
235+ Data struct {
236+ ExpectedSigners []interface {} `json:"expectedSigners"`
237+ UnexpectedSignatures []struct {
238+ UserEmail string `json:"userEmail"`
239+ } `json:"unexpectedSignatures"`
240+ } `json:"data"`
237241 }
238242
239243 err = json .NewDecoder (w .Body ).Decode (& response )
@@ -242,15 +246,15 @@ func TestAdminHandler_GetDocumentStatus_NoExpectedSigners(t *testing.T) {
242246 }
243247
244248 // Verify response
245- if len (response .ExpectedSigners ) != 0 {
246- t .Errorf ("Expected 0 expected signers, got %d" , len (response .ExpectedSigners ))
249+ if len (response .Data . ExpectedSigners ) != 0 {
250+ t .Errorf ("Expected 0 expected signers, got %d" , len (response .Data . ExpectedSigners ))
247251 }
248252
249253 // All signatures should be unexpected since there are no expected signers
250- if len (response .UnexpectedSignatures ) != 1 {
251- t .Fatalf ("Expected 1 unexpected signature, got %d" , len (response .UnexpectedSignatures ))
254+ if len (response .Data . UnexpectedSignatures ) != 1 {
255+ t .Fatalf ("Expected 1 unexpected signature, got %d" , len (response .Data . UnexpectedSignatures ))
252256 }
253- if response .UnexpectedSignatures [0 ].UserEmail != "user@example.com" {
254- t .Errorf ("Expected email 'user@example.com', got '%s'" , response .UnexpectedSignatures [0 ].UserEmail )
257+ if response .Data . UnexpectedSignatures [0 ].UserEmail != "user@example.com" {
258+ t .Errorf ("Expected email 'user@example.com', got '%s'" , response .Data . UnexpectedSignatures [0 ].UserEmail )
255259 }
256260}
0 commit comments