rusackas commented on code in PR #37625:
URL: https://github.com/apache/superset/pull/37625#discussion_r2770123288


##########
superset-frontend/src/SqlLab/actions/sqlLab.test.ts:
##########
@@ -281,7 +299,11 @@ describe('async actions', () => {
       };
       const store = mockStore(state);
 
-      store.dispatch(actions.formatQuery(queryEditorWithTemplateString));
+      store.dispatch(
+        actions.formatQuery(
+          queryEditorWithTemplateString as unknown as QueryEditor,
+        ),
+      );

Review Comment:
   The `call.options.body as string` cast is needed because the fetch mock's 
`RequestInit.body` type is `BodyInit | null | undefined` (which includes Blob, 
ArrayBuffer, etc.). In these tests, we know the body is always a JSON string 
because the action uses `JSON.stringify`. The cast narrows the type for 
`JSON.parse`. This is a standard pattern at the fetch mock boundary.



##########
superset-frontend/src/SqlLab/actions/sqlLab.test.ts:
##########
@@ -390,7 +416,7 @@ describe('async actions', () => {
       );
 
       const call = fetchMock.callHistory.calls(formatQueryEndpoint)[0];
-      const body = JSON.parse(call.options.body);
+      const body = JSON.parse(call.options.body as string);

Review Comment:
   Same pattern — `body as string` at the fetch mock boundary.



##########
superset-frontend/src/SqlLab/actions/sqlLab.test.ts:
##########
@@ -633,7 +665,7 @@ describe('async actions', () => {
 
       return makeRequest().then(() => {
         const call = fetchMock.callHistory.calls(stopQueryEndpoint)[0];
-        const body = JSON.parse(call.options.body);
+        const body = JSON.parse(call.options.body as string);

Review Comment:
   Same pattern.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to