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


##########
superset-frontend/plugins/plugin-chart-country-map/test/controlPanel.test.ts:
##########
@@ -0,0 +1,89 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import {
+  DatasourceType,
+  QueryFormData,
+  getChartControlPanelRegistry,
+} from '@superset-ui/core';
+import { ControlStateMapping } from '@superset-ui/chart-controls';
+import {
+  getAllControlsState,
+  getFormDataFromControls,
+} from 'src/explore/controlUtils';
+import controlPanel from '../src/controlPanel';
+
+const controlNames = (): string[] =>
+  (controlPanel.controlPanelSections ?? [])
+    .flatMap(section => section?.controlSetRows ?? [])
+    .flat()
+    .map(item =>
+      typeof item === 'string'
+        ? item
+        : (item as { name?: string } | null)?.name,
+    )
+    .filter((name): name is string => Boolean(name));
+
+test('keeps the MCP geographic marker and row limit through Explore 
hydration', () => {
+  expect(controlNames()).toEqual(
+    expect.arrayContaining([
+      'mcp_geographic',
+      'row_limit',
+      '_mcp_dashboard_time_filter_subject',
+    ]),
+  );
+});
+
+test.each(['event_time', null])(
+  'Explore saves preserve dashboard-time provenance %s',
+  subject => {
+    const vizType = 'test-geographic-time-binding';
+    const registry = getChartControlPanelRegistry();
+    registry.registerValue(vizType, controlPanel);
+    try {
+      const input: QueryFormData = {
+        viz_type: vizType,
+        datasource: '3__table',
+        mcp_geographic: true,
+        _mcp_dashboard_time_filter_subject: subject,
+        adhoc_filters: subject
+          ? [
+              {
+                subject,
+                operator: 'TEMPORAL_RANGE',
+                comparator: 'No filter',
+                clause: 'WHERE',
+                expressionType: 'SIMPLE',
+              },
+            ]
+          : [],
+      };
+      const controls = getAllControlsState(
+        vizType,
+        DatasourceType.Table,
+        null,
+        input,
+      );
+      const saved = getFormDataFromControls(controls as ControlStateMapping);
+      expect(saved._mcp_dashboard_time_filter_subject).toBe(subject);
+      expect(saved.adhoc_filters).toEqual(input.adhoc_filters);
+    } finally {
+      registry.remove(vizType);
+    }
+  },
+);

Review Comment:
   Addressed in 31fa8002ed8d2cb1544783e8bf07bce824aba11b. Extracted the 
unchanged parameterized hydration/provenance test into 
spec/helpers/geographicControlPanel.ts and invoked it from all three 
control-panel test files. The existing spec/helpers alias is already used by 
plugin tests, so this adds no cross-package dependency. Both subject cases, 
assertions, and registry cleanup are unchanged. All three Jest suites passed (9 
tests); Prettier and staged-file pre-commit passed, including frontend lint and 
type checking. The standalone npx eslint command could not run because 
installed ESLint 10 requires a flat config absent from this checkout.



##########
superset-frontend/plugins/preset-chart-deckgl/src/layers/Scatter/controlPanel.test.ts:
##########
@@ -0,0 +1,89 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+import {
+  DatasourceType,
+  QueryFormData,
+  getChartControlPanelRegistry,
+} from '@superset-ui/core';
+import { ControlStateMapping } from '@superset-ui/chart-controls';
+import {
+  getAllControlsState,
+  getFormDataFromControls,
+} from 'src/explore/controlUtils';
+import controlPanel from './controlPanel';
+
+const controlNames = (): string[] =>
+  (controlPanel.controlPanelSections ?? [])
+    .flatMap(section => section?.controlSetRows ?? [])
+    .flat()
+    .map(item =>
+      typeof item === 'string'
+        ? item
+        : (item as { name?: string } | null)?.name,
+    )
+    .filter((name): name is string => Boolean(name));
+
+test('keeps the MCP geographic marker and row limit through Explore 
hydration', () => {
+  expect(controlNames()).toEqual(
+    expect.arrayContaining([
+      'mcp_geographic',
+      'row_limit',
+      '_mcp_dashboard_time_filter_subject',
+    ]),
+  );
+});
+
+test.each(['event_time', null])(
+  'Explore saves preserve dashboard-time provenance %s',
+  subject => {
+    const vizType = 'test-geographic-time-binding';
+    const registry = getChartControlPanelRegistry();
+    registry.registerValue(vizType, controlPanel);
+    try {
+      const input: QueryFormData = {
+        viz_type: vizType,
+        datasource: '3__table',
+        mcp_geographic: true,
+        _mcp_dashboard_time_filter_subject: subject,
+        adhoc_filters: subject
+          ? [
+              {
+                subject,
+                operator: 'TEMPORAL_RANGE',
+                comparator: 'No filter',
+                clause: 'WHERE',
+                expressionType: 'SIMPLE',
+              },
+            ]
+          : [],
+      };
+      const controls = getAllControlsState(
+        vizType,
+        DatasourceType.Table,
+        null,
+        input,
+      );
+      const saved = getFormDataFromControls(controls as ControlStateMapping);
+      expect(saved._mcp_dashboard_time_filter_subject).toBe(subject);
+      expect(saved.adhoc_filters).toEqual(input.adhoc_filters);
+    } finally {
+      registry.remove(vizType);
+    }
+  },
+);

Review Comment:
   Addressed in 31fa8002ed8d2cb1544783e8bf07bce824aba11b. Extracted the 
unchanged parameterized hydration/provenance test into 
spec/helpers/geographicControlPanel.ts and invoked it from all three 
control-panel test files. The existing spec/helpers alias is already used by 
plugin tests, so this adds no cross-package dependency. Both subject cases, 
assertions, and registry cleanup are unchanged. All three Jest suites passed (9 
tests); Prettier and staged-file pre-commit passed, including frontend lint and 
type checking. The standalone npx eslint command could not run because 
installed ESLint 10 requires a flat config absent from this checkout.



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