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


##########
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:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Missing type_generic assertion</b></div>
   <div id="fix">
   
   The test for `semanticViewDimensionsToColumns` omits assertion for 
`type_generic`, a field returned by the implementation at line 189 and consumed 
by downstream filter-type logic. Without this check, a regression in 
`mapSemanticTypeToGenericDataType` would pass silently.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #c63ed6</i></small>
   </div>
   
   ---
   Should Bito avoid suggestions like this for future reviews? (<a 
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
   - [ ] Yes, avoid them



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