-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathContextProject.test.js
More file actions
165 lines (134 loc) · 5 KB
/
ContextProject.test.js
File metadata and controls
165 lines (134 loc) · 5 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
describe('ContextProject', () => {
test('cors can be enabled', async () => {
const response = await page.goto('http://localhost:6969/context-project')
const status = response.status()
expect([200, 304]).toContain(status)
})
})
describe('ContextProject', () => {
beforeAll(async () => {
await page.goto('http://localhost:6969/context-project', { waitUntil: 'networkidle0' })
await page.waitForSelector('[data-project]')
})
test('project is part of the context', async () => {
const element = await page.$('[data-project]')
expect(element).toBeTruthy()
})
test('has a name key', async () => {
const element = await page.$('[data-name="Nullstack Tests"]')
expect(element).toBeTruthy()
})
test('has a shortName key', async () => {
const element = await page.$('[data-short-name="Nullstack"]')
expect(element).toBeTruthy()
})
test('has a domain key', async () => {
const element = await page.$('[data-domain="localhost"]')
expect(element).toBeTruthy()
})
test('has a color key', async () => {
const element = await page.$('[data-color="#d22365"]')
expect(element).toBeTruthy()
})
test('has a backgroundColor key', async () => {
const element = await page.$('[data-background-color="#d22365"]')
expect(element).toBeTruthy()
})
test('has a type key', async () => {
const element = await page.$('[data-type="website"]')
expect(element).toBeTruthy()
})
test('has a display key', async () => {
const element = await page.$('[data-display="standalone"]')
expect(element).toBeTruthy()
})
test('has an orientation key', async () => {
const element = await page.$('[data-orientation="portrait"]')
expect(element).toBeTruthy()
})
test('has a scope key', async () => {
const element = await page.$('[data-scope="/"]')
expect(element).toBeTruthy()
})
test('has a root key', async () => {
const element = await page.$('[data-root="/"]')
expect(element).toBeTruthy()
})
test('has an icons key', async () => {
const element = await page.$('[data-icons]')
expect(element).toBeTruthy()
})
test('icons that do not match the pattern are not loaded into icon key', async () => {
const element = await page.$('[data-ignored-unmatched-icon]')
expect(element).toBeTruthy()
})
test('icons accepts an object with sizes', async () => {
const element = await page.$('[data-icon-72="/icon-72x72.png"]')
expect(element).toBeTruthy()
})
test('has a favicon key', async () => {
const element = await page.$('[data-favicon="/favicon-96x96.png"]')
expect(element).toBeTruthy()
})
test('has a disallow key', async () => {
const element = await page.$('[data-disallow]')
expect(element).toBeTruthy()
})
test('disallow accepts an array with paths', async () => {
const element = await page.$('[data-disallow-admin="/admin"]')
expect(element).toBeTruthy()
})
test('has a sitemap key', async () => {
const element = await page.$('[data-sitemap]')
expect(element).toBeTruthy()
})
test('has a viewport key', async () => {
const element = await page.$(
'[data-viewport="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no viewport-fit=cover"]',
)
expect(element).toBeTruthy()
})
test('css bundle can use a cdn', async () => {
const text = await page.$eval('[rel="stylesheet"]', (element) => element.href)
expect(text).toMatch('localhost:6969')
})
test('javacript bundle can use a cdn', async () => {
const text = await page.$eval('script[integrity]', (element) => element.src)
expect(text).toMatch('localhost:6969')
})
test('css bundle has an empty integrity in dev mode', async () => {
const text = await page.$eval('[rel="stylesheet"]', (element) => element.integrity)
expect(text).toMatch('')
})
test('javacript bundle has an empty integrity in dev mode', async () => {
const text = await page.$eval('script[integrity]', (element) => element.integrity)
expect(text).toMatch('')
})
test('manifest has an empty integrity in dev mode', async () => {
const text = await page.$eval('[rel="manifest"]', (element) => element.integrity)
expect(text).toMatch('')
})
})
describe('robots.txt', () => {
let text
beforeAll(async () => {
await page.goto('http://localhost:6969/robots.txt', { waitUntil: 'networkidle0' })
text = await page.evaluate(() => document.body.innerHTML)
})
test('it generates a robot.txt', async () => {
const index = text.indexOf('User-Agent: *')
expect(index).toBeGreaterThan(-1)
})
test('it allows project.root', async () => {
const index = text.indexOf('Allow: /')
expect(index).toBeGreaterThan(-1)
})
test('it reflects project.disallow', async () => {
const index = text.indexOf('Disallow: /admin')
expect(index).toBeGreaterThan(-1)
})
test('it reflects project.sitemap', async () => {
const index = text.indexOf('Sitemap: https://localhost:6969/sitemap.xml')
expect(index).toBeGreaterThan(-1)
})
})