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


##########
superset-frontend/plugins/legacy-plugin-chart-calendar/test/cal-heatmap.test.ts:
##########
@@ -0,0 +1,45 @@
+/**
+ * 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 CalendarChartPlugin from '../src/index';
+import CalHeatMap from '../src/vendor/cal-heatmap';
+
+/**
+ * The example tests in this file act as a starting point, and
+ * we encourage you to build more.
+ */
+describe('@superset-ui/legacy-plugin-chart-calendar', () => {
+  it('exists', () => {
+    expect(CalendarChartPlugin).toBeDefined();
+  });
+});
+
+/**
+ * This test tests that a reasonble starting date is selected given range
+ * and starting date. Since time offset is calculated, 2024-12-31 is also
+ * acceptable.
+ */
+describe('getMonthDomain filter month-day', () => {
+it('returns correct month domain for 2025-01-01 to 2025-02-31', () => {
+  const getMonthDomain = (CalHeatMap as any).prototype.getMonthDomain;
+  const d = new Date(Date.UTC(2025, 0, 1));
+  const range = 2;
+  const result = getMonthDomain(d, range);
+  expect(result[0].toISOString()).toContain('2025-01-01' || '2024-12-31');

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Constant truthiness in logical OR expression</b></div>
   <div id="fix">
   
   Line 43 has a logical error: `'2025-01-01' || '2024-12-31'` will always 
evaluate to `'2025-01-01'` since it's a non-empty string constant. The intent 
appears to be checking if the result contains either date. Use `.toMatch()` or 
separate assertions instead.
   </div>
   
   
   <details>
   <summary>
   <b>Code suggestion</b>
   </summary>
   <blockquote>Check the AI-generated fix before applying</blockquote>
   <div id="code">
   
   
   ````suggestion
     expect(result[0].toISOString()).toMatch(/2025-01-01|2024-12-31/);
   ````
   
   </div>
   </details>
   
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run <a 
href=https://github.com/apache/superset/pull/36315#issuecomment-3587576339>#281930</a></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