bito-code-review[bot] commented on code in PR #42091: URL: https://github.com/apache/superset/pull/42091#discussion_r3592742989
########## 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: <!-- Bito Reply --> The suggestion to add `fetchMock.restore()` is not appropriate for this test file. As noted, `fetch-mock` v12.6.0 does not provide a `restore()` method, and the test suite relies on the module-level route remaining active across tests, which is standard behavior for this mock configuration. The existing approach of using `fetchMock.clearHistory()` in other files is specific to tests that inspect call history, which is not required here. -- 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]
