]>
Commit | Line | Data |
---|---|---|
9f95a23c TL |
1 | import { PoolPageHelper } from '../pools/pools.po'; |
2 | import { NotificationSidebarPageHelper } from './notification.po'; | |
3 | ||
4 | describe('Notification page', () => { | |
5 | let notification: NotificationSidebarPageHelper; | |
6 | let pools: PoolPageHelper; | |
7 | ||
8 | beforeAll(() => { | |
9 | notification = new NotificationSidebarPageHelper(); | |
10 | pools = new PoolPageHelper(); | |
11 | }); | |
12 | ||
13 | afterEach(async () => { | |
14 | await NotificationSidebarPageHelper.checkConsole(); | |
15 | }); | |
16 | ||
17 | it('should open notification sidebar', async () => { | |
18 | await notification.waitInvisibility(notification.getSidebar()); | |
19 | await notification.open(); | |
20 | await notification.waitVisibility(notification.getSidebar()); | |
21 | }); | |
22 | ||
23 | it('should display a running task', async () => { | |
24 | const poolName = 'e2e_notification_pool'; | |
25 | ||
26 | await pools.navigateTo('create'); | |
801d1391 TL |
27 | await pools.create(poolName, 8); |
28 | await pools.edit_pool_pg(poolName, 4, false); | |
9f95a23c TL |
29 | await notification.waitStaleness(notification.getToast()); |
30 | ||
801d1391 | 31 | // Check that running task is shown. |
9f95a23c | 32 | await notification.open(); |
801d1391 TL |
33 | await notification.waitFn(async () => { |
34 | const task = await notification.getTasks().first(); | |
35 | const text = await task.getText(); | |
36 | return text.includes(poolName); | |
37 | }, 'Timed out verifying task.'); | |
9f95a23c | 38 | |
801d1391 TL |
39 | // Delete pool after task is complete (otherwise we get an error). |
40 | await notification.waitFn( | |
41 | async () => { | |
42 | const tasks = await notification.getTasks(); | |
43 | return tasks.length === 0 ? true : !(await tasks[0].getText()).includes(poolName); | |
44 | }, | |
45 | 'Timed out waiting for task to complete.', | |
46 | 40000 | |
47 | ); | |
9f95a23c TL |
48 | await pools.delete(poolName); |
49 | }); | |
50 | ||
51 | it('should have notifications', async () => { | |
52 | await notification.open(); | |
53 | await expect((await notification.getNotifications()).length).toBeGreaterThan(0); | |
54 | }); | |
55 | ||
56 | it('should clear notifications', async () => { | |
57 | await notification.waitStaleness(notification.getToast()); | |
58 | await expect((await notification.getNotifications()).length).toBeGreaterThan(0); | |
59 | await notification.waitVisibility(notification.getClearNotficationsBtn()); | |
801d1391 TL |
60 | |
61 | // It can happen that although notifications are cleared, by the time we check the | |
62 | // notifications amount, another notification can appear, so we check it more than once (if needed). | |
9f95a23c | 63 | await notification.waitClickableAndClick(notification.getClearNotficationsBtn()); |
801d1391 TL |
64 | await notification.waitFn(async () => { |
65 | const notifications = await notification.getNotifications(); | |
66 | if (notifications.length > 0) { | |
67 | await notification.waitClickableAndClick(notification.getClearNotficationsBtn()); | |
68 | return false; | |
69 | } | |
70 | return true; | |
71 | }, 'Timed out checking that notifications are cleared.'); | |
9f95a23c TL |
72 | }); |
73 | }); |