-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgroup.test.ts
More file actions
178 lines (150 loc) · 7.7 KB
/
group.test.ts
File metadata and controls
178 lines (150 loc) · 7.7 KB
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
import { test, expect } from '@playwright/test'
import { idfy, login, newWindow, randomString } from './generic'
import { createGroup, deleteGroup, gotoFirstGroup, gotoGroup, joinGroup } from './group'
import { createPermission } from './permission'
// TODO: Add test for this situation:
// User a creates a group which is invite only
// User b asks to join
// User a accepts b's request to join
// User b leaves the group
// User b asks to join again
// User a tries to reject, but it says error 400, "User already joined"
test.describe('Group-Integration-Tests', () => {
test.describe.configure({ mode: 'serial' })
const group = { name: 'Test Group Group-Testing Public' + randomString(), public: true, invite: false }
test('Create Group', async ({ page }) => {
await login(page)
await createGroup(page, group)
})
test('Go To Group', async ({ page }) => {
await login(page)
await gotoGroup(page, group)
})
test('Join Group', async ({ page }) => {
await login(page, { username: process.env.SECONDUSER_NAME, password: process.env.SECONDUSER_PASS })
await joinGroup(page, group)
})
test('Leave Group', async ({ page }) => {
await login(page, { username: process.env.SECONDUSER_NAME, password: process.env.SECONDUSER_PASS })
await gotoGroup(page, group)
await page.getByRole('button', { name: 'Leave group' }).click()
await page.getByRole('button', { name: 'Yes', exact: true }).click()
})
test('Delete Group', async ({ page }) => {
await login(page)
await gotoGroup(page, group)
await deleteGroup(page)
})
})
test.describe('Create-Delete-Group Invite only', () => {
test.describe.configure({ mode: 'serial' })
const groupInvite = { name: 'Test Group Group-Testing Invite only' + randomString(), public: true, invite: true }
test('Create Group Invite', async ({ page }) => {
await login(page)
await createGroup(page, groupInvite)
})
test('Go To Group Invite', async ({ page }) => {
await login(page)
await gotoGroup(page, groupInvite)
})
test('Ask to Join Group Invite', async ({ page }) => {
await login(page)
const bPage = await newWindow()
await login(bPage, { username: process.env.SECONDUSER_NAME, password: process.env.SECONDUSER_PASS })
await joinGroup(bPage, groupInvite)
await gotoGroup(page, groupInvite)
await page.getByRole('button', { name: 'Members', exact: true }).click()
await page.getByRole('button', { name: 'Accept' }).click()
await gotoGroup(bPage, groupInvite)
})
test('Leave Group Invite', async ({ page }) => {
const bPage = await newWindow()
await login(bPage, { username: process.env.SECONDUSER_NAME, password: process.env.SECONDUSER_PASS })
await gotoGroup(bPage, groupInvite)
await bPage.getByRole('button', { name: 'Leave group' }).click()
await bPage.getByRole('button', { name: 'Yes', exact: true }).click()
})
test('Delete Group Invite', async ({ page }) => {
await login(page)
await gotoGroup(page, groupInvite)
await deleteGroup(page)
})
})
test('Group-Invite', async ({ page }) => {
const group = { name: 'Invitation ' + randomString() }
await login(page)
await createGroup(page, group)
await page.getByRole('button', { name: 'Members', exact: true }).click()
await page.getByRole('button', { name: 'avatar + Invite user' }).click()
await page.getByRole('textbox', { name: 'User to invite' }).click()
await page.getByRole('textbox', { name: 'User to invite' }).fill(process.env.SECONDUSER_NAME)
await page.getByRole('listitem').getByRole('button').filter({ hasText: /^$/ }).click()
await expect(page.getByText('Successfully sent invite')).toBeVisible()
const bPage = await newWindow()
await login(bPage, { username: process.env.SECONDUSER_NAME, password: process.env.SECONDUSER_PASS })
await bPage.getByText(`You have been invited to ${group.name} Accept Reject`).getByText('Reject').click()
await page.getByRole('textbox', { name: 'User to invite' }).click()
await page.getByRole('textbox', { name: 'User to invite' }).fill(process.env.SECONDUSER_NAME)
await page.getByRole('listitem').getByRole('button').filter({ hasText: /^$/ }).click()
await expect(page.getByText('Successfully sent invite')).toBeVisible()
await bPage.reload()
await bPage.getByText(`You have been invited to ${group.name} Accept Reject`).getByText('Accept').click()
await gotoGroup(bPage, group)
})
test('Create-Delete-Group', async ({ page }) => {
await login(page)
const group = { name: 'Test Group Group-Test-' + randomString(), public: false }
await createGroup(page, group)
// Attempting to leave group as owner
await page.getByRole('button', { name: 'Leave group' }).click()
await page.getByRole('button', { name: 'Yes', exact: true }).click()
await expect(page.getByText("Group owner isn't allowed to")).toBeVisible()
await page.getByRole('button', { name: 'No', exact: true }).click()
// Workgroup testing
await page.getByRole('button', { name: 'Work Groups' }).click()
await page.getByRole('button', { name: '+ Add Workgroup' }).click()
await page.getByLabel('Name').click()
await page.getByLabel('Name').fill('Test Workgroup directjoin')
await page.getByRole('button', { name: 'Create', exact: true }).click()
await page.getByRole('button', { name: 'Join', exact: true }).click()
await page.getByRole('button', { name: '+ Add Workgroup' }).click()
await page.getByLabel('No').check()
await page.getByLabel('Name').click()
await page.getByLabel('Name').fill('Test group invite only')
await page.getByRole('button', { name: 'Create', exact: true }).click()
await page.getByRole('button', { name: 'Ask to join' }).click()
await expect(page.getByText('Pending')).toBeVisible()
await expect(page.getByRole('button', { name: 'Leave', exact: true }).nth(0)).toBeVisible()
await page.getByRole('button', { name: 'Add User' }).nth(0).click()
await page.getByText('Test Workgroup directjoin Members: 1').nth(0)
await page.getByText('Test Workgroup directjoin Members: 1').nth(0).getByRole('button').nth(1).click()
await page.getByRole('button', { name: 'Cancel', exact: true }).click()
await page.getByText('Test Workgroup directjoin Members: 1').nth(0).getByRole('button').nth(1).click()
await page.getByRole('button', { name: 'Delete', exact: true }).click()
await page.locator('.dark\\:text-darkmodeText > .text-center').nth(1).click()
await page.getByRole('button', { name: 'Delete', exact: true }).click()
// Editing Group
await expect(page.locator('#group-header-title')).toHaveText(group.name)
await page.getByRole('button', { name: 'Edit Group' }).click()
// Create, deactive and delete permission
await createPermission(page, group, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
await page.getByRole('button', { name: 'Assign' }).click()
await page.getByRole('button', { name: 'List' }).click()
await page.locator('[id="delete-permission-button Test Permission"]').click()
await page.getByRole('button', { name: 'Delete', exact: true }).nth(1).click()
// Create, deactive and delete area
// await page.getByRole('button', { name: 'Areas' }).click()
// await page.getByLabel('Tag').click()
// await page.getByLabel('Tag').fill('Test Tag')
// await page.getByLabel('Description').click()
// await page.getByLabel('Description').fill('Test tag description')
// await page.getByRole('button', { name: 'Add' }).click()
// await expect(page.locator(`#test-tag`).first()).toHaveText('Test Tag')
// await page.locator('.slider').first().click()
// await page.locator('.text-red-500').first().click()
// await page.getByRole('button', { name: 'No', exact: true }).click()
// await page.locator('.text-red-500').first().click()
// await page.getByRole('button', { name: 'Yes', exact: true }).click()
//
await deleteGroup(page, group)
})