forked from vercel/next.js
/
deployment-id-handling.test.ts
50 lines (44 loc) · 1.19 KB
/
deployment-id-handling.test.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { createNextDescribe } from 'e2e-utils'
import { join } from 'node:path'
const deploymentId = Date.now() + ''
createNextDescribe(
'deployment-id-handling',
{
files: join(__dirname, 'app'),
env: {
NEXT_DEPLOYMENT_ID: deploymentId,
},
nextConfig: {
experimental: {
useDeploymentId: true,
},
},
},
({ next }) => {
it.each([
{ urlPath: '/' },
{ urlPath: '/pages-edge' },
{ urlPath: '/from-app' },
{ urlPath: '/from-app/edge' },
])(
'should append dpl query to all assets correctly for $urlPath',
async ({ urlPath }) => {
const $ = await next.render$(urlPath)
const scripts = Array.from($('script'))
expect(scripts.length).toBeGreaterThan(0)
for (const script of scripts) {
if (script.attribs.src) {
expect(script.attribs.src).toContain('dpl=' + deploymentId)
}
}
const links = Array.from($('link'))
expect(links.length).toBeGreaterThan(0)
for (const link of links) {
if (link.attribs.href) {
expect(link.attribs.href).toContain('dpl=' + deploymentId)
}
}
}
)
}
)