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


##########
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:
   <!-- Bito Reply -->
   The updates to the AsyncSelect mock correctly address the previous feedback 
by removing the hardcoded filter values and ensuring the component properly 
handles the typed search input. These changes improve the test's reliability 
and alignment with the production implementation.



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