-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathContextPage.test.js
More file actions
114 lines (94 loc) · 4.67 KB
/
ContextPage.test.js
File metadata and controls
114 lines (94 loc) · 4.67 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
107
108
109
110
111
112
113
114
describe('ContextPage', () => {
beforeAll(async () => {
await page.goto('http://localhost:6969/context-page')
})
test('is part of the client context', async () => {
const element = await page.$('[data-page]')
expect(element).toBeTruthy()
})
test('the title key updates the document title', async () => {
const text = await page.title()
expect(text).toMatch('Nullstack Tests')
})
test('the title key updates the open graph title', async () => {
const text = await page.$eval('head > meta[property="og:title"]', (element) => element.content)
expect(text).toMatch('Nullstack Tests')
})
test('the title key updates the apple mobile web app title', async () => {
const text = await page.$eval('head > meta[name="apple-mobile-web-app-title"]', (element) => element.content)
expect(text).toMatch('Nullstack Tests')
})
test('the robots key updates the meta robots', async () => {
const text = await page.$eval('head > meta[name="robots"]', (element) => element.content)
expect(text).toMatch('index, follow')
})
test('the locale key updates the open graph locale', async () => {
const text = await page.$eval('head > meta[property="og:locale"]', (element) => element.content)
expect(text).toMatch('pt-BR')
})
test('the locale key updates the html lang', async () => {
const text = await page.$eval('html', (element) => element.lang)
expect(text).toMatch('pt-BR')
})
test('the image key updates the open graph image with a cdn url', async () => {
const text = await page.$eval('head > meta[property="og:image"]', (element) => element.content)
expect(text).toMatch('http://localhost:6969/image.jpg')
})
test('the description key updates the open graph description', async () => {
const text = await page.$eval('head > meta[property="og:description"]', (element) => element.content)
expect(text).toMatch('Nullstack tests page that tests the context page')
})
test('the description key updates the meta description', async () => {
const text = await page.$eval('head > meta[name="description"]', (element) => element.content)
expect(text).toMatch('Nullstack tests page that tests the context page')
})
test('the canonical tag is generated if the canonical key is omitted', async () => {
const text = await page.$eval('head > link[rel="canonical"]', (element) => element.href)
expect(text).toMatch('https://localhost:6969/context-page')
})
test('the schema key generates a json schema', async () => {
const text = await page.$eval('head > script[type="application/ld+json"]', (element) => element.textContent)
expect(text).toMatch('{"@type":"WebSite","@id":"#website","name":"Nullstack","url":"https://nullstack.app"}')
})
test('has a changes key', async () => {
const element = await page.$('[data-changes="weekly"]')
expect(element).toBeTruthy()
})
test('has a priority key', async () => {
const element = await page.$('[data-priority="1"]')
expect(element).toBeTruthy()
})
test('the page reacts to a server function status', async () => {
await page.click('[data-request-status]')
await page.waitForSelector('[data-page-status="401"]')
const element = await page.$('[data-page-status="401"]')
expect(element).toBeTruthy()
})
})
describe('ContextPage updated', () => {
beforeAll(async () => {
await page.goto('http://localhost:6969/context-page')
await page.waitForSelector('[data-application-hydrated]')
await page.click('[data-update-head]')
})
test('updates meta og:title', async () => {
await page.waitForSelector('meta[property="og:title"][content="Nullstack Tests Updated"]')
const element = await page.$('meta[property="og:title"][content="Nullstack Tests Updated"]')
expect(element).toBeTruthy()
})
test('updates meta og:description', async () => {
await page.waitForSelector('meta[property="og:description"][content="Nullstack tests page that tests the context page updated"]')
const element = await page.$('meta[property="og:description"][content="Nullstack tests page that tests the context page updated"]')
expect(element).toBeTruthy()
})
test('updates meta description', async () => {
await page.waitForSelector('meta[name="description"][content="Nullstack tests page that tests the context page updated"]')
const element = await page.$('meta[name="description"][content="Nullstack tests page that tests the context page updated"]')
expect(element).toBeTruthy()
})
test('a custom event is triggered when the title changes', async () => {
await page.waitForSelector('[data-event-triggered]')
const element = await page.$('[data-event-triggered]')
expect(element).toBeTruthy()
})
})