-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathgroup.ts
More file actions
106 lines (96 loc) · 4.62 KB
/
group.ts
File metadata and controls
106 lines (96 loc) · 4.62 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
import { idfy } from './generic'
import { expect } from '@playwright/test'
export type group = {
name: string
public?: boolean
invite?: boolean
}
export async function createGroup(page: any, group: group = { name: 'Test Group', public: false, invite: false }) {
await page.locator('#groups').click()
await page.getByPlaceholder('Search groups').click()
await page.getByPlaceholder('Search groups').fill(group.name)
await page.waitForTimeout(500)
// await expect(page.getByRole('heading', { name: group.name, exact: true }).first()).toBeVisible();
const button = await page.getByRole('heading', { name: group.name, exact: true }).first()
await page.waitForTimeout(500)
if (await button.isVisible()) {
await button.click()
} else {
await page.getByRole('button', { name: 'Groups' }).click()
await page.getByRole('button', { name: 'Create Group' }).click()
await page.getByLabel('Title').click()
await page.getByLabel('Title').fill(group.name)
await page.getByLabel('Description').click()
await page.getByLabel('Description').fill('Test Group Description')
await page.locator('.image-upload > input').nth(0).setInputFiles('./image.png')
await page.getByRole('button', { name: 'Confirm' }).click()
await page.waitForTimeout(500)
await page.locator('.image-upload > input').nth(1).setInputFiles('./image.png')
await page.locator('#cropper-confirm').first().click()
await page
.locator('fieldset')
.filter({ hasText: 'Public? Yes No' })
.getByLabel(group.public ? 'Yes' : 'No')
.check()
if (group.public)
await page
.locator('fieldset')
.filter({ hasText: 'Invitation Required? Yes No' })
.getByLabel(group.invite ? 'Yes' : 'No')
.check()
await page.locator('fieldset').filter({ hasText: 'Hide creators? Yes No' }).getByLabel('No').check()
await page.getByRole('button', { name: 'Create' }).click()
try {
await expect(page.getByRole('button', { name: group.name })).toBeVisible()
} catch {
await page.getByRole('button', { name: 'Cancel' }).click()
}
}
}
export async function gotoGroup(page: any, group = { name: 'Test Group' }) {
await page.locator('#groups').click()
await page.waitForLoadState('networkidle')
await page.getByPlaceholder('Search groups').click()
await page.getByPlaceholder('Search groups').fill('')
await page.waitForLoadState('networkidle')
await page.getByPlaceholder('Search groups').pressSequentially(group.name, { delay: 20 })
await expect(page.getByRole('heading', { name: group.name, exact: true })).toBeVisible()
await page.getByRole('heading', { name: group.name, exact: true }).click()
}
export async function gotoFirstGroup(page: any) {
await page.locator('#groups').click()
await page.locator('#groups-list > button').nth(1).click()
}
export async function joinGroup(page: any, group = { name: 'Test Group' }) {
await page.locator('#groups').click()
await page.waitForLoadState('networkidle')
await page.getByPlaceholder('Search groups').click()
await page.getByPlaceholder('Search groups').fill('')
await page.waitForTimeout(500)
await page.getByPlaceholder('Search groups').type(group.name)
await page.waitForTimeout(500)
const joinButton = page.locator(`#join-${idfy(group.name)}`)
await expect(joinButton).toBeVisible({ timeout: 10000 })
if ((await joinButton.innerText()).trim() === 'Join' || (await joinButton.innerText()).trim() === 'Ask to join')
await joinButton.click()
}
export async function deleteGroup(page: any, group = { name: 'Test Group', public: false }) {
// Deleting Group
await page.getByRole('button', { name: 'Edit Group' }).click()
await page.getByRole('button', { name: 'Delete Group' }).click()
await page.getByRole('button', { name: 'Cancel', exact: true }).click()
await page.getByRole('button', { name: 'Delete Group' }).click()
await page.getByRole('button', { name: 'Yes', exact: true }).click()
await expect(page).toHaveURL(`${process.env.LINK}/groups`)
}
export async function createArea(page: any, group = { name: 'Test Group', public: false }, tag = 'Test Tag') {
await page.getByRole('button', { name: 'Edit Group' }).dispatchEvent('click')
await expect(page.getByRole('button', { name: 'Areas' })).toBeVisible()
await page.getByRole('button', { name: 'Areas' }).click()
await page.getByLabel('Tag').click()
await page.getByLabel('Tag').fill(tag)
await page.getByLabel('Description').click()
await page.getByLabel('Description').fill('Tag description')
await page.getByRole('button', { name: 'Add' }).click()
await expect(page.locator('div:nth-child(3) > div').filter({ hasText: tag })).toHaveText(tag)
}