bito-code-review[bot] commented on code in PR #41505: URL: https://github.com/apache/superset/pull/41505#discussion_r3557016386
########## superset-frontend/plugins/plugin-chart-echarts/src/utils/formatters.test.ts: ########## @@ -0,0 +1,55 @@ +/** + * 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 { TimeGranularity } from '@superset-ui/core'; +import { getSmartDateFormatter } from './formatters'; + +test('getSmartDateFormatter returns a formatter for MINUTE grain', () => { + const formatter = getSmartDateFormatter(TimeGranularity.MINUTE); + // Verify formatter is defined and callable + expect(formatter).toBeDefined(); + const date = new Date('2024-01-15T10:35:00Z'); + expect(() => formatter(date)).not.toThrow(); +}); + +test('getSmartDateFormatter returns a formatter for FIFTEEN_MINUTES grain', () => { + const formatter = getSmartDateFormatter(TimeGranularity.FIFTEEN_MINUTES); + expect(formatter).toBeDefined(); + const date = new Date('2024-01-15T10:15:00Z'); + expect(() => formatter(date)).not.toThrow(); +}); Review Comment: <div> <div id="suggestion"> <div id="issue"><b>Tests lack behavioral assertions</b></div> <div id="fix"> This test previously validated that FIFTEEN_MINUTES grain distinguishes times with different minute values. The new `not.toThrow()` assertion does not verify this behavior - a formatter that collapsed to hour precision would still pass. </div> </div> <small><i>Code Review Run #13a75e</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 ########## superset-frontend/plugins/plugin-chart-echarts/src/utils/formatters.test.ts: ########## @@ -0,0 +1,55 @@ +/** + * 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 { TimeGranularity } from '@superset-ui/core'; +import { getSmartDateFormatter } from './formatters'; + +test('getSmartDateFormatter returns a formatter for MINUTE grain', () => { + const formatter = getSmartDateFormatter(TimeGranularity.MINUTE); + // Verify formatter is defined and callable + expect(formatter).toBeDefined(); + const date = new Date('2024-01-15T10:35:00Z'); + expect(() => formatter(date)).not.toThrow(); +}); Review Comment: <div> <div id="suggestion"> <div id="issue"><b>Tests lack behavioral assertions</b></div> <div id="fix"> This test previously validated that MINUTE grain preserves minute-level precision. The new assertion `expect(() => formatter(date)).not.toThrow()` only checks the formatter is callable, not that it correctly preserves minutes. If the formatter incorrectly collapsed to hour-level, this test would still pass. </div> </div> <small><i>Code Review Run #13a75e</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 ########## superset-frontend/plugins/plugin-chart-echarts/src/utils/formatters.test.ts: ########## @@ -0,0 +1,55 @@ +/** + * 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 { TimeGranularity } from '@superset-ui/core'; +import { getSmartDateFormatter } from './formatters'; + +test('getSmartDateFormatter returns a formatter for MINUTE grain', () => { + const formatter = getSmartDateFormatter(TimeGranularity.MINUTE); + // Verify formatter is defined and callable + expect(formatter).toBeDefined(); + const date = new Date('2024-01-15T10:35:00Z'); + expect(() => formatter(date)).not.toThrow(); +}); + +test('getSmartDateFormatter returns a formatter for FIFTEEN_MINUTES grain', () => { + const formatter = getSmartDateFormatter(TimeGranularity.FIFTEEN_MINUTES); + expect(formatter).toBeDefined(); + const date = new Date('2024-01-15T10:15:00Z'); + expect(() => formatter(date)).not.toThrow(); +}); + +test('getSmartDateFormatter returns a formatter for HOUR grain', () => { + const formatter = getSmartDateFormatter(TimeGranularity.HOUR); + expect(formatter).toBeDefined(); + const date = new Date('2024-01-15T10:00:00Z'); + expect(() => formatter(date)).not.toThrow(); +}); + +test('getSmartDateFormatter returns a formatter for SECOND grain', () => { + const formatter = getSmartDateFormatter(TimeGranularity.SECOND); + expect(formatter).toBeDefined(); + const date = new Date('2024-01-15T10:35:45Z'); + expect(() => formatter(date)).not.toThrow(); +}); Review Comment: <div> <div id="suggestion"> <div id="issue"><b>New SECOND grain test lacks behavioral assertions</b></div> <div id="fix"> New test for SECOND grain only checks `expect(formatter).toBeDefined()`. According to implementation (formatters.ts lines 127-139), SECOND grain preserves hour, minute, AND second. The test should verify this behavior. </div> </div> <small><i>Code Review Run #13a75e</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 ########## superset-frontend/plugins/plugin-chart-echarts/src/utils/formatters.test.ts: ########## @@ -0,0 +1,55 @@ +/** + * 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 { TimeGranularity } from '@superset-ui/core'; +import { getSmartDateFormatter } from './formatters'; + +test('getSmartDateFormatter returns a formatter for MINUTE grain', () => { + const formatter = getSmartDateFormatter(TimeGranularity.MINUTE); + // Verify formatter is defined and callable + expect(formatter).toBeDefined(); + const date = new Date('2024-01-15T10:35:00Z'); + expect(() => formatter(date)).not.toThrow(); +}); + +test('getSmartDateFormatter returns a formatter for FIFTEEN_MINUTES grain', () => { + const formatter = getSmartDateFormatter(TimeGranularity.FIFTEEN_MINUTES); + expect(formatter).toBeDefined(); + const date = new Date('2024-01-15T10:15:00Z'); + expect(() => formatter(date)).not.toThrow(); +}); + +test('getSmartDateFormatter returns a formatter for HOUR grain', () => { + const formatter = getSmartDateFormatter(TimeGranularity.HOUR); + expect(formatter).toBeDefined(); + const date = new Date('2024-01-15T10:00:00Z'); + expect(() => formatter(date)).not.toThrow(); +}); Review Comment: <div> <div id="suggestion"> <div id="issue"><b>Tests lack behavioral assertions</b></div> <div id="fix"> This test previously validated that HOUR grain produces identical outputs for different times within the same hour (e.g., 10:00 and 10:30 both format as '10:00'). The new `not.toThrow()` assertion does not test this behavior. </div> </div> <small><i>Code Review Run #13a75e</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]
