sadpandajoe commented on code in PR #42091: URL: https://github.com/apache/superset/pull/42091#discussion_r3592742511
########## 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: Not applying. fetch-mock v12.6.0 has no `restore()` — that call would throw `fetchMock.restore is not a function` and break the suite (the API is `removeRoutes`/`clearHistory`/`hardReset`). Also, `count: 1` is the JSON response-body payload the component reads, not a fetch-mock repeat limit: the module-level route serves every matching request, so the first test doesn't consume it and the second doesn't hang — both tests pass across repeated runs. The cited `AlertReportModal.test.tsx` uses `fetchMock.clearHistory()` (not `restore()`) precisely because it asserts on `callHistory` call counts; this file never inspects call history, so there's nothing to reset between tests. _🤖 Addressed by [Claude Code](https://claude.com/claude-code)_ -- 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]
