aminghadersohi commented on code in PR #44851:
URL: https://github.com/apache/superset/pull/44851#discussion_r4168341316


##########
superset-frontend/src/explore/components/ExploreViewContainer/ExploreViewContainer.test.tsx:
##########
@@ -860,6 +860,79 @@ function setupTableChartControlPanel() {
   });
 }
 
+test('clearing a singleton metric refreshes semantic compatibility after 
metadata sync', async () => {
+  const fetchCompatibilitySpy = jest.spyOn(
+    exploreActions,
+    'fetchCompatibility',
+  );
+  const endpoint = 'path:/api/v1/datasource/semantic_view/7/compatible';
+  fetchMock.post(endpoint, {
+    result: {
+      compatible_metrics: ['metric_a', 'metric_b'],
+      compatible_dimensions: [],
+    },
+  });
+  const initialState = {
+    ...reduxState,
+    explore: {
+      ...reduxState.explore,
+      datasource: {
+        ...reduxState.explore.datasource,
+        id: 7,
+        type: 'semantic_view',
+      },
+      form_data: {
+        datasource: '7__semantic_view',
+        viz_type: VizType.BigNumberTotal,
+        metric: 'metric_a',
+      },
+      controls: {
+        datasource: { value: '7__semantic_view' },
+        viz_type: { value: VizType.BigNumberTotal },
+        metric: { value: 'metric_a' },
+      },
+    },
+  };
+  const store = createStore(initialState, reducerIndex);
+  renderWithRouter({ initialState, store });
+  await waitFor(() =>
+    expect(store.getState()).toMatchObject({
+      explore: { compatibility: { status: 'verified' } },
+    }),
+  );
+  // Model the completed sync answer: metric B cannot combine with metric A.
+  act(() => {
+    store.dispatch(
+      exploreActions.setCompatibility({
+        status: 'verified',
+        metrics: ['metric_a'],
+        dimensions: [],
+      }),
+    );
+  });
+  fetchCompatibilitySpy.mockClear();

Review Comment:
   Dropping `formData.metric` from this helper keeps all 48 tests in both 
suites green, so the shared-extraction half is unpinned — this test asserts 
only the post-clear `[], []`, which the unfixed helper also produces. Measured 
at mount: `['metric_a']` vs `[]`.
   
   ```suggestion
     expect(fetchCompatibilitySpy).toHaveBeenCalledWith(
       'semantic_view',
       7,
       ['metric_a'],
       [],
     );
     fetchCompatibilitySpy.mockClear();
   ```



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