-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy paththread.test.ts
More file actions
86 lines (66 loc) · 3.25 KB
/
thread.test.ts
File metadata and controls
86 lines (66 loc) · 3.25 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
import test, { expect } from '@playwright/test'
import { login, randomString } from './generic'
import { createGroup, gotoGroup } from './group'
import { createThread } from './thread'
const group = { name: 'Test Group Thread' + randomString(), public: false }
test('Thread-Create', async ({ page }) => {
await login(page)
await createGroup(page, group)
await gotoGroup(page, group)
await createThread(page, group)
})
test('Thread-Comments', async ({ page }) => {
await login(page)
await createGroup(page, group)
await gotoGroup(page, group)
await createThread(page, group)
// GOTO THREAD
await page.getByPlaceholder('Write a comment...').click()
await page.getByPlaceholder('Write a comment...').fill('Test Comment')
await page.locator('button[type="submit"]').first().click()
await page.getByRole('button', { name: 'Reply' }).click()
await page.getByPlaceholder('Write a comment...').nth(1).click()
await page.getByPlaceholder('Write a comment...').nth(1).fill('Test Reply with file')
await page.locator('button[type="submit"]').nth(1).click()
//TODO: Test images in comment
// Test multiple users
// TODO Test likes
})
test('Thread-Create-Report-Delete', async ({ page }) => {
await login(page)
const group = { name: 'Test Group Thread' + randomString(), public: false }
await createGroup(page, group)
await gotoGroup(page, group)
await createThread(page, group)
await page.getByPlaceholder('Write a comment...').click()
await page.getByPlaceholder('Write a comment...').fill('Test Comment')
await page.locator('button[type="submit"]').first().click()
await page.getByRole('button', { name: 'Reply' }).click()
await page.getByPlaceholder('Write a comment...').nth(1).click()
await page.getByPlaceholder('Write a comment...').nth(1).fill('Test Reply with file')
await page.locator('button[type="submit"]').nth(1).click()
//TODO Test images in comment
await page.locator('#poll-header-multiple-choices > button').click()
await page.getByRole('button', { name: 'Report Thread' }).click()
await page.getByRole('textbox', { name: 'Title' }).click()
await page.getByRole('textbox', { name: 'Title' }).fill('Report Test')
await page.locator('#report-description').click()
await page.locator('#report-description').fill('This is a test report')
await page.getByRole('button', { name: 'Report', exact: true }).click()
await expect(page.getByText('Thread reported successfully')).toBeVisible()
await page.waitForTimeout(500)
// Dropdown stays open after report — click Delete Thread directly
await page.getByRole('button', { name: 'Delete Thread' }).click()
await expect(page.getByRole('button', { name: 'Cancel', exact: true })).toHaveCount(1)
await page.getByRole('button', { name: 'Cancel', exact: true }).click()
await page.waitForTimeout(300)
// After cancel, check if dropdown is visible or needs toggling
const deleteBtn = page.getByRole('button', { name: 'Delete Thread' })
if (!(await deleteBtn.isVisible())) {
await page.locator('#poll-header-multiple-choices > button').click()
await page.waitForTimeout(300)
}
await deleteBtn.click()
await page.getByRole('button', { name: 'Remove', exact: true }).click()
await expect(page.getByText('Successfully deleted thread')).toBeVisible()
})