Skip to content

Commit 62804ea

Browse files
update tests after changes in core-ui
1 parent 89bbd32 commit 62804ea

File tree

5 files changed

+36
-37
lines changed

5 files changed

+36
-37
lines changed

shell-ui/src/navbar/NotificationCenter.spec.tsx

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
1-
import React, { PropsWithChildren } from 'react';
21
import { act, screen, waitFor, within } from '@testing-library/react';
3-
import NotificationCenterProvider, {
4-
InternalNotification,
5-
Notification,
6-
} from '../NotificationCenterProvider';
7-
import NotificationCenter from './NotificationCenter';
82
import userEvent from '@testing-library/user-event';
3+
import { PropsWithChildren } from 'react';
94
import { QueryClient } from 'react-query';
10-
import { prepareRenderMultipleHooks } from './__TESTS__/testMultipleHooks';
115
import { MemoryRouter, Route, Routes } from 'react-router-dom';
126
import { ShellHistoryProvider } from '../initFederation/ShellHistoryProvider';
13-
import { useNotificationCenter } from '../useNotificationCenter';
7+
import NotificationCenterProvider, {
8+
InternalNotification,
9+
Notification,
10+
} from '../NotificationCenterProvider';
1411
import { QueryClientProvider } from '../QueryClientProvider';
12+
import { useNotificationCenter } from '../useNotificationCenter';
13+
import { prepareRenderMultipleHooks } from './__TESTS__/testMultipleHooks';
14+
import NotificationCenter from './NotificationCenter';
15+
import {debug} from "jest-preview";
1516

16-
export const notificationCenterSelectors = {
17+
const notificationCenterSelectors = {
1718
notificationCenterButton: () =>
1819
screen.getByRole('button', { name: /notification center/i }),
1920
emptyNotificationCenterIcon: () =>
@@ -175,21 +176,23 @@ describe('NotificationCenter', () => {
175176
//E open again the notification center
176177
userEvent.click(notificationCenterSelectors.notificationCenterButton());
177178
//V the notification are marked as read
179+
debug();
180+
178181
expect(
179182
within(screen.getAllByRole('option')[0]).queryByRole('img', {
180-
name: /unread notification mark/i,
181-
}),
182-
).toBeNull();
183+
name: /unread notification mark/i,
184+
}),
185+
).not.toBeVisible();
183186
expect(
184187
within(screen.getAllByRole('option')[1]).queryByRole('img', {
185188
name: /unread notification mark/i,
186189
}),
187-
).toBeNull();
190+
).not.toBeVisible();
188191
expect(
189192
within(screen.getAllByRole('option')[2]).queryByRole('img', {
190193
name: /unread notification mark/i,
191194
}),
192-
).toBeNull();
195+
).not.toBeVisible();
193196
});
194197

195198
it('can be navigated with the keyboard', async () => {
@@ -241,7 +244,7 @@ describe('NotificationCenter', () => {
241244
within(lastNotification).queryByRole('img', {
242245
name: /unread notification mark/i,
243246
}),
244-
).toBeNull();
247+
).not.toBeVisible();
245248
});
246249

247250
it('should not display notifications with the same ID', async () => {
@@ -267,17 +270,17 @@ describe('NotificationCenter', () => {
267270
within(screen.getAllByRole('option')[0]).queryByRole('img', {
268271
name: /unread notification mark/i,
269272
}),
270-
).toBeNull();
273+
).not.toBeVisible();
271274
expect(
272275
within(screen.getAllByRole('option')[1]).queryByRole('img', {
273276
name: /unread notification mark/i,
274277
}),
275-
).toBeNull();
278+
).not.toBeVisible();
276279
expect(
277280
within(screen.getAllByRole('option')[2]).queryByRole('img', {
278281
name: /unread notification mark/i,
279282
}),
280-
).toBeNull();
283+
).not.toBeVisible();
281284
//E
282285
userEvent.click(notificationCenterSelectors.notificationCenterButton());
283286
//V

ui/src/components/DashboardInventory.test.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
import React from 'react';
21
import { screen } from '@testing-library/react';
32
import DashboardInventory from './DashboardInventory';
43
import { waitForLoadingToFinish, render } from './__TEST__/util';
5-
import type { Alert } from '../services/alertUtils';
64
import { useHighestSeverityAlerts } from '../containers/AlertProvider';
75
import {
86
getNodesCountQuery,
@@ -63,10 +61,10 @@ describe('the dashboard inventory panel', () => {
6361
await waitForLoadingToFinish();
6462
// Verify
6563
expect(
66-
screen.getAllByLabelText(`Node-backend ${STATUS_CRITICAL}`).length,
64+
screen.getAllByLabelText(`Nodes status is ${STATUS_CRITICAL}`).length,
6765
).toEqual(1);
6866
expect(
69-
screen.getAllByLabelText(`Volume-backend ${STATUS_CRITICAL}`).length,
67+
screen.getAllByLabelText(`Volumes status is ${STATUS_CRITICAL}`).length,
7068
).toEqual(1);
7169
});
7270
test('displays properly the status WARNING for nodes and volumes', async () => {
@@ -78,10 +76,10 @@ describe('the dashboard inventory panel', () => {
7876
await waitForLoadingToFinish();
7977
// Verify
8078
expect(
81-
screen.getAllByLabelText(`Node-backend ${STATUS_WARNING}`).length,
79+
screen.getAllByLabelText(`Nodes status is ${STATUS_WARNING}`).length,
8280
).toEqual(1);
8381
expect(
84-
screen.getAllByLabelText(`Volume-backend ${STATUS_WARNING}`).length,
82+
screen.getAllByLabelText(`Volumes status is ${STATUS_WARNING}`).length,
8583
).toEqual(1);
8684
});
8785
test('displays properly the status HEALTHY for nodes and volumes', async () => {
@@ -93,10 +91,10 @@ describe('the dashboard inventory panel', () => {
9391
await waitForLoadingToFinish();
9492
// Verify
9593
expect(
96-
screen.getAllByLabelText(`Node-backend ${STATUS_HEALTH}`).length,
94+
screen.getAllByLabelText(`Nodes status is ${STATUS_HEALTH}`).length,
9795
).toEqual(1);
9896
expect(
99-
screen.getAllByLabelText(`Volume-backend ${STATUS_HEALTH}`).length,
97+
screen.getAllByLabelText(`Volumes status is ${STATUS_HEALTH}`).length,
10098
).toEqual(1);
10199
});
102100
test('displays the loader if the query does not return a result', async () => {

ui/src/components/DashboardPlane.test.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
import React from 'react';
21
import { screen } from '@testing-library/react';
2+
import { STATUS_CRITICAL, STATUS_HEALTH, STATUS_WARNING } from '../constants';
3+
import { useHighestSeverityAlerts } from '../containers/AlertProvider';
34
import DashboardPlaneHealth from './DashboardPlaneHealth';
45
import { render } from './__TEST__/util';
5-
import type { Alert } from '../services/alertUtils';
6-
import { useHighestSeverityAlerts } from '../containers/AlertProvider';
7-
import { STATUS_WARNING, STATUS_CRITICAL, STATUS_HEALTH } from '../constants';
86
const alertsCritical = [
97
{
108
id: 'alert1',
@@ -49,7 +47,7 @@ describe("the dashboard network's plane panel", () => {
4947
(useHighestSeverityAlerts as any).mockImplementation(() => noAlerts);
5048
render(<DashboardPlaneHealth />);
5149
expect(
52-
screen.getAllByLabelText(`Check-circle status ${STATUS_HEALTH}`),
50+
screen.getAllByLabelText(`status ${STATUS_HEALTH}`),
5351
).toHaveLength(NB_ITEMS);
5452
});
5553
test('displays 2 warning statuses when warning alerts are present as well as link to the alerts page', async () => {
@@ -59,7 +57,7 @@ describe("the dashboard network's plane panel", () => {
5957
render(<DashboardPlaneHealth />);
6058
// Verify
6159
expect(
62-
screen.getAllByLabelText(`Exclamation-circle status ${STATUS_WARNING}`),
60+
screen.getAllByLabelText(`status ${STATUS_WARNING}`),
6361
).toHaveLength(NB_ITEMS);
6462
expect(screen.getAllByTestId('alert-link')).toHaveLength(NB_ITEMS);
6563
});
@@ -70,7 +68,7 @@ describe("the dashboard network's plane panel", () => {
7068
render(<DashboardPlaneHealth />);
7169
// Verify
7270
expect(
73-
screen.getAllByLabelText(`Times-circle status ${STATUS_CRITICAL}`),
71+
screen.getAllByLabelText(`status ${STATUS_CRITICAL}`),
7472
).toHaveLength(NB_ITEMS);
7573
expect(screen.getAllByTestId('alert-link')).toHaveLength(NB_ITEMS);
7674
});

ui/src/components/DashboardServices.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ describe('the dashboard inventory panel', () => {
4848
render(<DashboardServices />);
4949
// Verify
5050
expect(
51-
screen.getAllByLabelText(`Check-circle status ${STATUS_HEALTH}`),
51+
screen.getAllByLabelText(`status ${STATUS_HEALTH}`),
5252
).toHaveLength(8);
5353
});
5454
test('displays the services panel and display all 8 warning statuses when warning alerts are present as well as link to the alerts page', async () => {
@@ -58,7 +58,7 @@ describe('the dashboard inventory panel', () => {
5858
render(<DashboardServices />);
5959
// Verify
6060
expect(
61-
screen.getAllByLabelText(`Exclamation-circle status ${STATUS_WARNING}`),
61+
screen.getAllByLabelText(`status ${STATUS_WARNING}`),
6262
).toHaveLength(8);
6363
expect(screen.getAllByTestId('alert-link')).toHaveLength(8);
6464
});
@@ -69,7 +69,7 @@ describe('the dashboard inventory panel', () => {
6969
render(<DashboardServices />);
7070
// Verify
7171
expect(
72-
screen.getAllByLabelText(`Times-circle status ${STATUS_CRITICAL}`),
72+
screen.getAllByLabelText(`status ${STATUS_CRITICAL}`),
7373
).toHaveLength(8);
7474
expect(screen.getAllByTestId('alert-link')).toHaveLength(8);
7575
});

ui/src/components/NodePartitionTable.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ describe('the system partition table', () => {
350350
);
351351
// Verify
352352
expect(
353-
screen.getByLabelText('Exclamation-circle status warning'),
353+
screen.getByLabelText('status warning'),
354354
).toBeInTheDocument();
355355
expect(screen.getByLabelText('97%')).toBeInTheDocument();
356356
expect(screen.getByText('/mnt/testpart')).toBeInTheDocument();

0 commit comments

Comments
 (0)