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


##########
superset-frontend/src/features/alerts/components/NotificationMethodEmailRecipients.test.tsx:
##########
@@ -0,0 +1,102 @@
+/**
+ * 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.
+ */
+// Unlike NotificationMethod.test.tsx, this file intentionally renders the
+// real AsyncSelect so it can catch regressions in the interaction between
+// the alerts CSS and the antd Select internals.
+import fetchMock from 'fetch-mock';
+import {
+  render,
+  screen,
+  userEvent,
+  waitFor,
+} from 'spec/helpers/testing-library';
+import { NotificationMethod } from './NotificationMethod';
+import { NotificationMethodOption, NotificationSetting } from '../types';
+
+const RELATED_USERS_ENDPOINT = 'glob:*/api/v1/report/related/created_by?*';
+
+const emailSetting: NotificationSetting = {
+  method: NotificationMethodOption.Email,
+  recipients: '',
+  options: [NotificationMethodOption.Email, NotificationMethodOption.Slack],
+};
+
+const renderComponent = () =>
+  render(
+    <NotificationMethod
+      setting={emailSetting}
+      index={0}
+      onUpdate={jest.fn()}
+      onRemove={jest.fn()}
+      onInputChange={jest.fn()}
+      email_subject=""
+      defaultSubject=""
+      setErrorSubject={jest.fn()}
+    />,
+  );
+
+fetchMock.get(RELATED_USERS_ENDPOINT, {
+  result: [
+    {
+      text: 'Admin User',
+      value: 1,
+      extra: { email: '[email protected]', active: true },
+    },
+  ],
+  count: 1,
+});

Review Comment:
   <div>
   
   
   <div id="suggestion">
   <div id="issue"><b>Missing fetchMock cleanup between tests</b></div>
   <div id="fix">
   
   The module-level fetchMock.get mock for RELATED_USERS_ENDPOINT (line 54) 
with `count: 1` has no cleanup. If both tests run sequentially, the first test 
consumes the single allowed request, potentially causing the second test's 
async operations to fail or hang. Compare with AlertReportModal.test.tsx which 
has explicit afterEach cleanup (lines 296-301). Add `afterEach(() => { 
fetchMock.restore(); });` after line 63.
   </div>
   
   
   </div>
   
   
   
   
   <small><i>Code Review Run #2b9f07</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