/
channel-management.spec.ts
133 lines (108 loc) · 5.37 KB
/
channel-management.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import type { Page } from '@playwright/test';
import faker from '@faker-js/faker';
import { test, expect } from './utils/test';
import { HomeChannel } from './page-objects';
import { createTargetChannel } from './utils';
test.use({ storageState: 'admin-session.json' });
test.describe.serial('channel-management', () => {
let poHomeChannel: HomeChannel;
let targetChannel: string;
let regularUserPage: Page;
test.beforeAll(async ({ api, browser }) => {
targetChannel = await createTargetChannel(api);
regularUserPage = await browser.newPage({ storageState: 'user2-session.json' });
await regularUserPage.goto('/home');
await regularUserPage.waitForSelector('[data-qa-id="home-header"]');
});
test.beforeEach(async ({ page }) => {
poHomeChannel = new HomeChannel(page);
await page.goto('/home');
});
test('expect add "user1" to "targetChannel"', async () => {
await poHomeChannel.sidenav.openChat(targetChannel);
await poHomeChannel.tabs.btnTabMembers.click();
await poHomeChannel.tabs.members.showAllUsers();
await poHomeChannel.tabs.members.addUser('user1');
await expect(poHomeChannel.toastSuccess).toBeVisible();
});
test('expect create invite to the room', async () => {
await poHomeChannel.sidenav.openChat(targetChannel);
await poHomeChannel.tabs.btnTabMembers.click();
await poHomeChannel.tabs.members.inviteUser();
await expect(poHomeChannel.toastSuccess).toBeVisible();
});
test('expect mute "user1"', async () => {
await poHomeChannel.sidenav.openChat(targetChannel);
await poHomeChannel.tabs.btnTabMembers.click();
await poHomeChannel.tabs.members.showAllUsers();
await poHomeChannel.tabs.members.muteUser('user1');
});
test('expect set "user1" as owner', async () => {
await poHomeChannel.sidenav.openChat(targetChannel);
await poHomeChannel.tabs.btnTabMembers.click();
await poHomeChannel.tabs.members.showAllUsers();
await poHomeChannel.tabs.members.setUserAsOwner('user1');
});
test('expect set "user1" as moderator', async () => {
await poHomeChannel.sidenav.openChat(targetChannel);
await poHomeChannel.tabs.btnTabMembers.click();
await poHomeChannel.tabs.members.showAllUsers();
await poHomeChannel.tabs.members.setUserAsModerator('user1');
});
test('expect edit topic of "targetChannel"', async () => {
await poHomeChannel.sidenav.openChat(targetChannel);
await poHomeChannel.tabs.btnRoomInfo.click();
await poHomeChannel.tabs.room.btnEdit.click();
await poHomeChannel.tabs.room.inputTopic.fill('hello-topic-edited');
await poHomeChannel.tabs.room.btnSave.click();
});
test('expect edit announcement of "targetChannel"', async () => {
await poHomeChannel.sidenav.openChat(targetChannel);
await poHomeChannel.tabs.btnRoomInfo.click();
await poHomeChannel.tabs.room.btnEdit.click();
await poHomeChannel.tabs.room.inputAnnouncement.fill('hello-announcement-edited');
await poHomeChannel.tabs.room.btnSave.click();
});
test('expect edit description of "targetChannel"', async () => {
await poHomeChannel.sidenav.openChat(targetChannel);
await poHomeChannel.tabs.btnRoomInfo.click();
await poHomeChannel.tabs.room.btnEdit.click();
await poHomeChannel.tabs.room.inputDescription.fill('hello-description-edited');
await poHomeChannel.tabs.room.btnSave.click();
});
test('expect edit name of "targetChannel"', async ({ page }) => {
await poHomeChannel.sidenav.openChat(targetChannel);
await poHomeChannel.tabs.btnRoomInfo.click();
await poHomeChannel.tabs.room.btnEdit.click();
await poHomeChannel.tabs.room.inputName.fill(`NAME-EDITED-${targetChannel}`);
await poHomeChannel.tabs.room.btnSave.click();
await poHomeChannel.sidenav.openChat(`NAME-EDITED-${targetChannel}`);
await expect(page).toHaveURL(`/channel/NAME-EDITED-${targetChannel}`);
});
test.skip('expect edit notification preferences of "targetChannel"', async () => {
await poHomeChannel.sidenav.openChat(targetChannel);
await poHomeChannel.tabs.kebab.click({ force: true });
await poHomeChannel.tabs.btnNotificationPreferences.click({ force: true });
await poHomeChannel.tabs.notificationPreferences.updateAllNotificationPreferences();
await poHomeChannel.tabs.notificationPreferences.btnSave.click();
await expect(poHomeChannel.toastSuccess).toBeVisible();
});
test('expect "readOnlyChannel" to show join button', async () => {
const channelName = faker.datatype.uuid();
await poHomeChannel.sidenav.openNewByLabel('Channel');
await poHomeChannel.sidenav.inputChannelName.type(channelName);
await poHomeChannel.sidenav.checkboxPrivateChannel.click();
await poHomeChannel.sidenav.checkboxReadOnly.click();
await poHomeChannel.sidenav.btnCreate.click();
await regularUserPage.goto(`/channel/${channelName}`);
await expect(regularUserPage.locator('button', { hasText: 'Join' })).toBeVisible();
});
test.skip('expect all notification preferences of "targetChannel" to be "Mentions"', async () => {
await poHomeChannel.sidenav.openChat(targetChannel);
await poHomeChannel.tabs.kebab.click({ force: true });
await poHomeChannel.tabs.btnNotificationPreferences.click({ force: true });
await expect(poHomeChannel.tabs.notificationPreferences.getPreferenceByDevice('Desktop')).toContainText('Mentions');
await expect(poHomeChannel.tabs.notificationPreferences.getPreferenceByDevice('Mobile')).toContainText('Mentions');
await expect(poHomeChannel.tabs.notificationPreferences.getPreferenceByDevice('Email')).toContainText('Mentions');
});
});