Copilot commented on code in PR #38591:
URL: https://github.com/apache/superset/pull/38591#discussion_r3001931984


##########
superset-frontend/src/pages/AlertReportList/AlertReportList.test.tsx:
##########
@@ -17,270 +17,467 @@
  * under the License.
  */
 import fetchMock from 'fetch-mock';
-import configureStore from 'redux-mock-store';
-import thunk from 'redux-thunk';
 import {
   render,
   screen,
   fireEvent,
   waitFor,
+  createStore,
 } from 'spec/helpers/testing-library';
+import { Provider } from 'react-redux';
 import { MemoryRouter } from 'react-router-dom';
 import { QueryParamProvider } from 'use-query-params';
 import { ReactRouter5Adapter } from 'use-query-params/adapters/react-router-5';
-import React from 'react';
 import AlertListComponent from 'src/pages/AlertReportList';
 
-// Cast to accept partial mock props in tests
+jest.setTimeout(30000);
+
 const AlertList = AlertListComponent as unknown as React.FC<
   Record<string, any>
 >;

Review Comment:
   `AlertListComponent` is cast to `React.FC`, but `React` isn't imported in 
this file. With the current linting setup (`no-undef`) this can be flagged as 
an undefined identifier in type position, and it’s also inconsistent with 
similar list-view tests that import React for `React.FC`. Import `React` 
(prefer `import type React from 'react'`) or avoid referencing the `React` 
namespace (e.g., use `FC`/`ComponentType`).



##########
superset-frontend/src/features/alerts/components/NumberInput.test.tsx:
##########
@@ -0,0 +1,67 @@
+/**
+ * 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 { render, screen, fireEvent } from 'spec/helpers/testing-library';
+import NumberInput from './NumberInput';
+
+const defaultProps = {
+  timeUnit: 'seconds',
+  min: 0,
+  name: 'timeout',
+  value: '30',
+  placeholder: 'Enter value',
+  onChange: jest.fn(),
+};
+
+test('renders value with timeUnit suffix when not focused', () => {
+  render(<NumberInput {...defaultProps} />);
+  const input = screen.getByPlaceholderText('Enter value');
+  expect(input).toHaveValue('30 seconds');
+});
+
+test('strips suffix on focus and restores on blur', () => {
+  render(<NumberInput {...defaultProps} />);
+  const input = screen.getByPlaceholderText('Enter value');
+
+  fireEvent.focus(input);
+  expect(input).toHaveValue('30');
+
+  fireEvent.blur(input);
+  expect(input).toHaveValue('30 seconds');
+});
+
+test('renders empty string when value is falsy', () => {
+  render(<NumberInput {...defaultProps} value="" />);
+  const input = screen.getByPlaceholderText('Enter value');
+  expect(input).toHaveValue('');
+});
+
+test('renders empty string when value is zero', () => {
+  render(<NumberInput {...defaultProps} value={0} />);
+  const input = screen.getByPlaceholderText('Enter value');
+  expect(input).toHaveValue('');

Review Comment:
   This test asserts that `value={0}` renders an empty string. However, 
`NumberInput` currently formats the displayed value via a truthiness check 
(`value ? ... : ''`), which drops valid numeric `0` values. If `0` is a 
meaningful/allowed value when `min={0}`, the component should treat `0` as 
present (check `value !== '' && value !== null && value !== undefined`) and 
this test should expect `0 seconds` (or `0` when focused) instead of empty.
   ```suggestion
   test('renders zero with timeUnit suffix when value is zero', () => {
     render(<NumberInput {...defaultProps} value={0} />);
     const input = screen.getByPlaceholderText('Enter value');
     expect(input).toHaveValue('0 seconds');
   ```



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