test(notification): add test for settings rendering

Signed-off-by: Hellgren Heikki <heikki.hellgren@op.fi>
This commit is contained in:
Hellgren Heikki
2025-08-06 15:31:36 +03:00
parent 5a70981d4a
commit bf2c39621b
@@ -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(
<NotificationFormatProvider originMap={{}} topicMap={{}}>
<UserNotificationSettingsPanel
settings={settings}
onChange={() => {}}
/>
</NotificationFormatProvider>,
);
const originRows = screen.getAllByText('Origin 1');
expect(originRows).toHaveLength(1);
});
});