forked from ietf-tools/datatracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstatus.spec.js
More file actions
66 lines (58 loc) · 2 KB
/
Copy pathstatus.spec.js
File metadata and controls
66 lines (58 loc) · 2 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
const {
test,
expect
} = require('@playwright/test')
const { STATUS_STORAGE_KEY, generateStatusTestId } = require('../../../client/shared/status-common.js')
test.describe('site status', () => {
const noStatus = {
hasMessage: false
}
const status1 = {
hasMessage: true,
id: 1,
slug: '2024-7-9fdfdf-sdfsdf',
title: 'My status title',
body: 'My status body',
url: '/status/2024-7-9fdfdf-sdfsdf',
date: '2024-07-09T07:05:13+00:00',
by: 'Exile is a cool Amiga game'
}
test.beforeEach(({ page, browserName }) => {
page.setDefaultTimeout(15 * 1000) // increase default timeout
test.skip(browserName === 'firefox', 'bypassing flaky tests on Firefox')
})
test('Renders server status as Notification', async ({ page }) => {
await page.route('/status/latest.json', route => {
route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify(status1)
})
})
await page.goto('/')
await expect(page.getByTestId(generateStatusTestId(status1.id)), 'should have status').toHaveCount(1)
})
test("Doesn't render dismissed server statuses", async ({ page }) => {
await page.route('/status/latest.json', route => {
route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify(status1)
})
})
await page.goto('/')
await page.evaluate(({ key, value }) => localStorage.setItem(key, value), { key: STATUS_STORAGE_KEY, value: JSON.stringify([status1.id]) })
await expect(page.getByTestId(generateStatusTestId(status1.id)), 'should have status').toHaveCount(0)
})
test('Handles no server status', async ({ page }) => {
await page.route('/status/latest.json', route => {
route.fulfill({
status: 200,
contentType: 'application/json',
body: JSON.stringify(noStatus)
})
})
await page.goto('/')
await expect(page.getByTestId(generateStatusTestId(status1.id)), 'should have status').toHaveCount(0)
})
})