forked from mattkenney/wildebeest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexplore-page.spec.ts
34 lines (27 loc) · 1.46 KB
/
explore-page.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
import { test, expect } from '@playwright/test'
test('Display the list of toots in the explore page', async ({ page }) => {
await page.goto('http://127.0.0.1:8788/explore')
const tootsTextsToCheck = [
'We did it!',
"I'm Rafael and I am a web designer!",
"Fine. I'll use Wildebeest",
'A very simple update: all good!',
]
for (const tootText of tootsTextsToCheck) {
await expect(page.locator('article').filter({ hasText: tootText })).toBeVisible()
}
})
test('Correctly displays toots with truncated urls', async ({ page }) => {
await page.goto('http://127.0.0.1:8788/explore')
const articleLocator = page.locator('article').filter({ hasText: "Fine. I'll use Wildebeest" })
await expect(articleLocator.getByRole('link', { name: 'blog.cloudflare.com/welcome-to…' })).toBeVisible()
})
test('Correctly displays toots with spoiler text', async ({ page }) => {
await page.goto('http://127.0.0.1:8788/explore')
const articleLocator = page.getByRole('article').filter({ hasText: 'who am I?' })
await expect(articleLocator.getByRole('paragraph').getByText('Hi! My name is Rafael! 👋')).not.toBeVisible()
await articleLocator.getByRole('button', { name: 'show more' }).click()
await expect(articleLocator.getByRole('paragraph').getByText('Hi! My name is Rafael! 👋')).toBeVisible()
await articleLocator.getByRole('button', { name: 'show less' }).click()
await expect(articleLocator.getByRole('paragraph').getByText('Hi! My name is Rafael! 👋')).not.toBeVisible()
})