bito-code-review[bot] commented on code in PR #32995:
URL: https://github.com/apache/superset/pull/32995#discussion_r3557929796


##########
superset-frontend/src/pages/ChartList/ChartList.listview.test.tsx:
##########
@@ -43,6 +43,24 @@ jest.mock('src/utils/export', () => ({
   default: jest.fn(),
 }));
 
+// Mock bootstrap data so isUserEditorOrAdmin's subject-based check resolves
+// the mock user (userId 1) as a subject editor of the fixtures below.
+jest.mock('src/utils/getBootstrapData', () => {
+  const actual = jest.requireActual('src/utils/getBootstrapData');
+  const { DEFAULT_BOOTSTRAP_DATA } = jest.requireActual('src/constants');
+  return {
+    __esModule: true,
+    ...actual,
+    default: jest.fn(() => ({
+      ...DEFAULT_BOOTSTRAP_DATA,
+      common: {
+        ...DEFAULT_BOOTSTRAP_DATA.common,
+        user_subjects: [1],
+      },
+    })),
+  };
+});

Review Comment:
   <!-- Bito Reply -->
   The suggestion is a false positive. The `jest.mock` implementation uses a 
factory function `mockUserSubjectsBootstrapData` imported from 
`spec/helpers/mockBootstrapData.ts`, which correctly returns a `jest.fn()` that 
is properly encapsulated. This pattern is consistent across the test files in 
this PR, ensuring test isolation without needing to manually capture and reset 
a mock variable in every test file.
   
   **superset-frontend/spec/helpers/mockBootstrapData.ts**
   ```
   export const mockUserSubjectsBootstrapData = (userSubjects: number[]) => {
     const actual = jest.requireActual('src/utils/getBootstrapData');
     const { DEFAULT_BOOTSTRAP_DATA } = jest.requireActual('src/constants');
     return {
       __esModule: true,
       ...actual,
       default: jest.fn(() => ({
         ...DEFAULT_BOOTSTRAP_DATA,
         common: {
           ...DEFAULT_BOOTSTRAP_DATA.common,
           user_subjects: userSubjects,
         },
       })),
     };
   };
   ```



-- 
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