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


##########
superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/utils.test.ts:
##########
@@ -377,3 +377,67 @@ test('doesChartMatchFilterDatasource falls back to 
datasource UID parsing', () =
     ),
   ).toBe(true);
 });
+
+test('fetchSemanticViewStructure returns name, dimensions, and metrics from 
the structure payload', async () => {
+  const fetchMock = require('fetch-mock').default;
+  const { fetchSemanticViewStructure: fetchStructure } = require('./utils');
+  fetchMock.get('glob:*/api/v1/semantic_view/9101/structure', {
+    result: {
+      name: 'orders',
+      dimensions: [{ name: 'Orders Status', type: 'VARCHAR' }],
+      metrics: [{ name: 'order_count', definition: 'COUNT(*)' }],
+    },
+  });
+
+  const structure = await fetchStructure(9101);
+
+  expect(structure.name).toBe('orders');
+  expect(structure.dimensions).toEqual([
+    { name: 'Orders Status', type: 'VARCHAR' },
+  ]);
+  expect(structure.metrics).toEqual([
+    { name: 'order_count', definition: 'COUNT(*)' },
+  ]);
+  fetchMock.removeRoutes();
+  fetchMock.clearHistory();
+});
+
+test('fetchSemanticViewStructure defaults missing arrays to empty', async () 
=> {
+  const fetchMock = require('fetch-mock').default;
+  const { fetchSemanticViewStructure: fetchStructure } = require('./utils');
+  fetchMock.get('glob:*/api/v1/semantic_view/9102/structure', {
+    result: { name: 'sparse' },
+  });
+
+  const structure = await fetchStructure(9102);
+
+  expect(structure.dimensions).toEqual([]);
+  expect(structure.metrics).toEqual([]);
+  fetchMock.removeRoutes();
+  fetchMock.clearHistory();
+});
+
+test('semanticViewDimensionsToColumns maps dimension fields incl. temporal 
detection', () => {
+  const { semanticViewDimensionsToColumns: toColumns } = require('./utils');
+  const columns = toColumns([
+    { name: 'ordered_at', type: 'TIMESTAMP' },
+    { name: 'status', type: 'VARCHAR' },
+  ]);
+
+  expect(columns[0]).toMatchObject({
+    column_name: 'ordered_at',
+    type: 'TIMESTAMP',
+    is_dttm: true,
+    filterable: true,
+  });
+  expect(columns[1]).toMatchObject({
+    column_name: 'status',
+    is_dttm: false,
+    filterable: true,
+  });

Review Comment:
   <!-- Bito Reply -->
   The suggestion to include an assertion for `type_generic` is valid and 
appropriate. Adding this check ensures that the downstream filter-type logic 
receives the expected data format, preventing potential silent regressions in 
the `mapSemanticTypeToGenericDataType` mapping function.
   
   
**superset-frontend/src/dashboard/components/nativeFilters/FiltersConfigModal/FiltersConfigForm/utils.test.ts**
   ```
   expect(columns[0]).toMatchObject({
       column_name: 'ordered_at',
       type: 'TIMESTAMP',
       is_dttm: true,
       filterable: true,
       type_generic: 1,
     });
   ```



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