8000 chore: update tests to check notification titles · podman-desktop/podman-desktop@18b7cb7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 18b7cb7

Browse files
committed
chore: update tests to check notification titles
Signed-off-by: Jiri Dostal <jdostal@redhat.com>
1 parent 739f7b2 commit 18b7cb7

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

packages/renderer/src/lib/dashboard/NotificationCardItem.spec.ts

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ test('Expect notification card to show notification title, description and close
5252

5353
const deleteButton = screen.getByRole('button', { name: 'Delete notification 1' });
5454
expect(deleteButton).toBeInTheDocument();
55+
expect(deleteButton).toHaveAttribute('title', 'Delete notification');
5556

5657
await fireEvent.click(deleteButton);
5758

@@ -66,16 +67,19 @@ test('Test info notification style and icon', () => {
6667
body: 'Info notification description',
6768
type: 'info',
6869
};
69-
const { getAllByRole } = render(NotificationCardItem, {
70+
const { getByTitle } = render(NotificationCardItem, {
7071
notification,
7172
});
72-
const icon = getAllByRole('img', { hidden: true })[0];
73+
const iconTitle = getByTitle('Notification icon', { exact: false });
74+
const icon = iconTitle.parentElement;
7375
// check icon shape
74-
const pdIconPath = icon.querySelector('path')?.getAttribute('d');
76+
const pdIconPath = icon?.querySelector('path')?.getAttribute('d');
7577
const faIconPath = faCircleInfo.icon[4]; // index 4 is the actual path as per FA IconDefinition
7678
expect(pdIconPath).toBe(faIconPath);
7779
// check icon color
7880
expect(icon).toHaveClass('text-[var(--pd-state-info)]');
81+
// check icon title contains the text from nested title element
82+
expect(iconTitle.textContent).toBe('Notification icon - info');
7983
// check region top border
8084
expect(screen.getByRole('region', { name: 'id: 1' })).toHaveClass('border-[var(--pd-state-info)]');
8185
});
@@ -88,16 +92,19 @@ test('Test warning notification style and icon', () => {
8892
body: 'Warning notification description',
8993
type: 'warn',
9094
};
91-
const { getAllByRole } = render(NotificationCardItem, {
95+
const { getByTitle } = render(NotificationCardItem, {
9296
notification,
9397
});
94-
const icon = getAllByRole('img', { hidden: true })[0];
98+
const iconTitle = getByTitle('Notification icon', { exact: false });
99+
const icon = iconTitle.parentElement;
95100
// check icon shape
96-
const pdIconPath = icon.querySelector('path')?.getAttribute('d');
101+
const pdIconPath = icon?.querySelector('path')?.getAttribute('d');
97102
const faIconPath = faExclamationTriangle.icon[4]; // index 4 is the actual path as per FA IconDefinition
98103
expect(pdIconPath).toBe(faIconPath);
99104
// check icon color
100105
expect(icon).toHaveClass('text-[var(--pd-state-warning)]');
106+
// check icon title
107+
expect(iconTitle.textContent).toBe('Notification icon - warn');
101108
// check region top border
102109
expect(screen.getByRole('region', { name: 'id: 1' })).toHaveClass('border-[var(--pd-state-warning)]');
103110
});
@@ -110,16 +117,19 @@ test('Test error notification style and icon', () => {
110117
body: 'Error notification description',
111118
type: 'error',
112119
};
113-
const { getAllByRole } = render(NotificationCardItem, {
120+
const { getByTitle } = render(NotificationCardItem, {
114121
notification,
115122
});
116-
const icon = getAllByRole('img', { hidden: true })[0];
123+
const iconTitle = getByTitle('Notification icon', { exact: false });
124+
const icon = iconTitle.parentElement;
117125
// check icon shape
118-
const pdIconPath = icon.querySelector('path')?.getAttribute('d');
126+
const pdIconPath = icon?.querySelector('path')?.getAttribute('d');
119127
const faIconPath = faCircleExclamation.icon[4]; // index 4 is the actual path as per FA IconDefinition
120128
expect(pdIconPath).toBe(faIconPath);
121129
// check icon color
122130
expect(icon).toHaveClass('text-[var(--pd-state-error)]');
131+
// check icon title
132+
expect(iconTitle.textContent).toBe('Notification icon - error');
123133
// check region top border
124134
expect(screen.getByRole('region', { name: 'id: 1' })).toHaveClass('border-[var(--pd-state-error)]');
125135
});

0 commit comments

Comments
 (0)
0