2025-05-09 13:26:47 +05:30
|
|
|
/* eslint-disable sonarjs/no-identical-functions */
|
2025-03-28 11:36:40 +05:30
|
|
|
import ROUTES from 'constants/routes';
|
2024-08-08 08:52:15 +04:30
|
|
|
import AlertChannels from 'container/AllAlertChannels';
|
|
|
|
|
import { fireEvent, render, screen, waitFor } from 'tests/test-utils';
|
|
|
|
|
|
|
|
|
|
const successNotification = jest.fn();
|
|
|
|
|
jest.mock('hooks/useNotifications', () => ({
|
|
|
|
|
__esModule: true,
|
|
|
|
|
useNotifications: jest.fn(() => ({
|
|
|
|
|
notifications: {
|
|
|
|
|
success: successNotification,
|
|
|
|
|
error: jest.fn(),
|
|
|
|
|
},
|
|
|
|
|
})),
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
jest.mock('hooks/useComponentPermission', () => ({
|
|
|
|
|
__esModule: true,
|
|
|
|
|
default: jest.fn().mockImplementation(() => [false]),
|
|
|
|
|
}));
|
|
|
|
|
|
2025-03-28 11:36:40 +05:30
|
|
|
jest.mock('react-router-dom', () => ({
|
|
|
|
|
...jest.requireActual('react-router-dom'),
|
|
|
|
|
useLocation: (): { pathname: string } => ({
|
|
|
|
|
pathname: `${process.env.FRONTEND_API_ENDPOINT}${ROUTES.ALL_CHANNELS}`,
|
|
|
|
|
}),
|
|
|
|
|
}));
|
|
|
|
|
|
2024-08-08 08:52:15 +04:30
|
|
|
describe('Alert Channels Settings List page (Normal User)', () => {
|
2025-05-09 13:26:47 +05:30
|
|
|
beforeEach(async () => {
|
2025-09-18 12:19:57 +05:30
|
|
|
jest.useFakeTimers();
|
2024-08-08 08:52:15 +04:30
|
|
|
render(<AlertChannels />);
|
2025-05-09 13:26:47 +05:30
|
|
|
await waitFor(() =>
|
|
|
|
|
expect(screen.getByText('sending_channels_note')).toBeInTheDocument(),
|
|
|
|
|
);
|
2024-08-08 08:52:15 +04:30
|
|
|
});
|
|
|
|
|
afterEach(() => {
|
|
|
|
|
jest.restoreAllMocks();
|
2025-09-18 12:19:57 +05:30
|
|
|
jest.useRealTimers();
|
2024-08-08 08:52:15 +04:30
|
|
|
});
|
|
|
|
|
describe('Should display the Alert Channels page properly', () => {
|
2025-05-09 13:26:47 +05:30
|
|
|
it('Should check if "The alerts will be sent to all the configured channels." is visible ', async () => {
|
|
|
|
|
await waitFor(() =>
|
|
|
|
|
expect(screen.getByText('sending_channels_note')).toBeInTheDocument(),
|
|
|
|
|
);
|
2024-08-08 08:52:15 +04:30
|
|
|
});
|
|
|
|
|
|
2025-05-09 13:26:47 +05:30
|
|
|
it('Should check if "New Alert Channel" Button is visble and disabled', async () => {
|
2024-08-08 08:52:15 +04:30
|
|
|
const newAlertButton = screen.getByRole('button', {
|
|
|
|
|
name: 'plus button_new_channel',
|
|
|
|
|
});
|
2025-05-09 13:26:47 +05:30
|
|
|
await waitFor(() => expect(newAlertButton).toBeInTheDocument());
|
2024-08-08 08:52:15 +04:30
|
|
|
expect(newAlertButton).toBeDisabled();
|
|
|
|
|
});
|
|
|
|
|
it('Should check if the help icon is visible and displays "tooltip_notification_channels ', async () => {
|
|
|
|
|
const helpIcon = screen.getByLabelText('question-circle');
|
|
|
|
|
fireEvent.mouseOver(helpIcon);
|
|
|
|
|
|
|
|
|
|
await waitFor(() => {
|
|
|
|
|
const tooltip = screen.getByText('tooltip_notification_channels');
|
|
|
|
|
expect(tooltip).toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
describe('Should check if the channels table is properly displayed', () => {
|
2025-05-09 13:26:47 +05:30
|
|
|
it('Should check if the table columns are properly displayed', async () => {
|
2024-08-08 08:52:15 +04:30
|
|
|
expect(screen.getByText('column_channel_name')).toBeInTheDocument();
|
|
|
|
|
expect(screen.getByText('column_channel_type')).toBeInTheDocument();
|
|
|
|
|
expect(screen.queryByText('column_channel_action')).not.toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
|
2025-05-09 13:26:47 +05:30
|
|
|
it('Should check if the data in the table is displayed properly', async () => {
|
2024-08-08 08:52:15 +04:30
|
|
|
expect(screen.getByText('Dummy-Channel')).toBeInTheDocument();
|
|
|
|
|
expect(screen.getAllByText('slack')[0]).toBeInTheDocument();
|
|
|
|
|
expect(screen.queryByText('column_channel_edit')).not.toBeInTheDocument();
|
|
|
|
|
expect(screen.queryByText('Delete')).not.toBeInTheDocument();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|