From bf2c39621b1484de16befed2e61a81e07272d2bc Mon Sep 17 00:00:00 2001 From: Hellgren Heikki Date: Wed, 6 Aug 2025 15:31:36 +0300 Subject: [PATCH] test(notification): add test for settings rendering Signed-off-by: Hellgren Heikki --- .../UserNotificationSettingsPanel.test.tsx | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 plugins/notifications/src/components/UserNotificationSettingsCard/UserNotificationSettingsPanel.test.tsx diff --git a/plugins/notifications/src/components/UserNotificationSettingsCard/UserNotificationSettingsPanel.test.tsx b/plugins/notifications/src/components/UserNotificationSettingsCard/UserNotificationSettingsPanel.test.tsx new file mode 100644 index 0000000000..6fc7eed55f --- /dev/null +++ b/plugins/notifications/src/components/UserNotificationSettingsCard/UserNotificationSettingsPanel.test.tsx @@ -0,0 +1,58 @@ +/* + * Copyright 2025 The Backstage Authors + * + * Licensed 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. + */ +import { render, screen } from '@testing-library/react'; +import { UserNotificationSettingsPanel } from './UserNotificationSettingsPanel'; +import { NotificationFormatProvider } from './UserNotificationSettingsCard.tsx'; + +describe('UserNotificationSettingsPanel', () => { + it('renders each origin only once even if present in multiple channels', () => { + const settings = { + channels: [ + { + id: 'email', + origins: [ + { + id: 'origin-1', + enabled: true, + topics: [], + }, + ], + }, + { + id: 'slack', + origins: [ + { + id: 'origin-1', + enabled: false, + topics: [], + }, + ], + }, + ], + }; + render( + + {}} + /> + , + ); + + const originRows = screen.getAllByText('Origin 1'); + expect(originRows).toHaveLength(1); + }); +});