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


##########
superset-frontend/src/features/alerts/components/NotificationMethod.test.tsx:
##########
@@ -34,6 +34,82 @@ import {
 import { NotificationMethod, mapSlackValues } from './NotificationMethod';
 import { NotificationMethodOption, NotificationSetting } from '../types';
 
+type MockAsyncSelectOption = {
+  label: string;
+  value: string;
+};
+
+type MockAsyncSelectProps = {
+  ariaLabel?: string;
+  'data-test'?: string;
+  name?: string;
+  onChange?: (value: MockAsyncSelectOption[]) => void;
+  options?: (
+    filterValue: string,
+    page: number,
+    pageSize: number,
+  ) => Promise<{ data: MockAsyncSelectOption[]; totalCount: number }>;
+  placeholder?: string;
+  value?: MockAsyncSelectOption[];
+};
+
+jest.mock('@superset-ui/core/components', () => {
+  const actual = jest.requireActual('@superset-ui/core/components');
+  const React = jest.requireActual('react');
+
+  return {
+    ...actual,
+    AsyncSelect: ({
+      ariaLabel,
+      'data-test': dataTest,
+      name,
+      onChange,
+      options,
+      placeholder,
+      value = [],
+    }: MockAsyncSelectProps) => {
+      const [loadedOptions, setLoadedOptions] = React.useState<
+        MockAsyncSelectOption[]
+      >([]);
+
+      return (
+        <>
+          <input
+            aria-label={ariaLabel ?? name}
+            data-test={dataTest}
+            placeholder={placeholder}
+            value={value.map(option => option.value).join(',')}
+            onChange={({ target: { value: inputValue } }) =>
+              onChange?.(
+                inputValue
+                  .split(',')
+                  .map(option => option.trim())
+                  .filter(Boolean)
+                  .map(option => ({ label: option, value: option })),
+              )
+            }
+          />
+          {options && dataTest && (
+            <button
+              data-test={`${dataTest}-load-options`}
+              type="button"
+              onClick={async () => {
+                const result = await options('user', 0, 25);

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Hardcoded mock filterValue</b></div>
   <div id="fix">
   
   The AsyncSelect mock always passes hardcoded arguments `('user', 0, 25)` to 
the options function, regardless of actual search input. This doesn't test that 
the component correctly passes filter values from user input to the 
fetchEmailRecipientOptions function.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #d13204</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