-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy paththread.test.ts
More file actions
57 lines (48 loc) · 2.38 KB
/
Copy paththread.test.ts
File metadata and controls
57 lines (48 loc) · 2.38 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
import test, { expect } from '@playwright/test'
import { randomString, register } from './generic'
import { createGroup, gotoGroup } from './group'
import { createThread } from './thread'
test('Thread-Full', async ({ page }) => {
await register(page)
const group = { name: 'Test Group Thread' + randomString(), public: false }
await createGroup(page, group)
await gotoGroup(page, group)
// Create
await createThread(page, group)
// Comment + reply
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
// Report
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)
// Delete
// 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()
})