-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathintegration.test.mjs
124 lines (102 loc) · 4.08 KB
/
integration.test.mjs
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
import assert from 'node:assert'
import { join } from 'node:path'
import { join as posixJoin } from 'node:path/posix'
import { test, describe } from 'node:test'
import { fileURLToPath } from 'node:url'
import build from '@netlify/build'
import { getAngularVersion } from '../src/helpers/getPackageVersion.js'
import validateAngularVersion from '../src/helpers/validateAngularVersion.js'
test('project without angular config file fails the plugin execution but does not error', async () => {
const { severityCode, success } = await build({
repositoryRoot: fileURLToPath(new URL('fixtures/non-angular-project', import.meta.url)),
})
assert.deepEqual(severityCode, 0)
assert.deepEqual(success, true)
})
test('project with missing angular dependencies does not error', async () => {
const { severityCode, success } = await build({
repositoryRoot: fileURLToPath(new URL('fixtures/missing-angular-deps', import.meta.url)),
})
assert.deepEqual(severityCode, 0)
assert.deepEqual(success, true)
})
test('application builder uses /browser publish dir', async () => {
const { severityCode, success, logs } = await build({
repositoryRoot: fileURLToPath(new URL('fixtures/application-builder', import.meta.url)),
buffer: true,
})
assert(
logs.stderr.includes(
`Publish directory is configured incorrectly. Updating to "${join('dist', 'test-browser-dir', 'browser')}".`,
),
)
assert.deepEqual(severityCode, 0)
assert.deepEqual(success, true)
})
test('browser builder uses different publish dir', async () => {
const { severityCode, success, logs } = await build({
repositoryRoot: fileURLToPath(new URL('fixtures/browser-builder', import.meta.url)),
buffer: true,
})
assert(
logs.stderr.includes(
`Publish directory is configured incorrectly. Updating to "${posixJoin('dist', 'test-browser-dir')}".`,
),
)
assert.deepEqual(severityCode, 0)
assert.deepEqual(success, true)
})
test('doesnt fail if prerender-routes.json file is missing', async () => {
const { success } = await build({
repositoryRoot: fileURLToPath(new URL('fixtures/prerender-false', import.meta.url)),
buffer: true,
})
assert.deepEqual(success, true)
})
test('doesnt fail if prerender-routes.json file is missing (Angular 19)', async () => {
const { success } = await build({
repositoryRoot: fileURLToPath(new URL('fixtures/angular-19-prerender-false', import.meta.url)),
buffer: true,
})
assert.deepEqual(success, true)
})
test('Angular 19 using CommonEngine', async () => {
const { severityCode, success } = await build({
repositoryRoot: fileURLToPath(new URL('fixtures/angular-19-common-engine', import.meta.url)),
})
assert.deepEqual(severityCode, 0)
assert.deepEqual(success, true)
})
test('Angular 19 using App Engine (Developer Preview)', async () => {
const { severityCode, success } = await build({
repositoryRoot: fileURLToPath(new URL('fixtures/angular-19-app-engine', import.meta.url)),
})
assert.deepEqual(severityCode, 0)
assert.deepEqual(success, true)
})
describe('Angular version validation', () => {
test('checks version for angular 19', async () => {
const result = validateAngularVersion(
await getAngularVersion(fileURLToPath(new URL('fixtures/angular-19-common-engine', import.meta.url))),
)
assert.strictEqual(result, true)
})
test('checks version for angular 18', async () => {
const result = validateAngularVersion(
await getAngularVersion(fileURLToPath(new URL('fixtures/application-builder', import.meta.url))),
)
assert.strictEqual(result, true)
})
test('checks version for angular 17', async () => {
const result = validateAngularVersion(
await getAngularVersion(fileURLToPath(new URL('fixtures/angular-17', import.meta.url))),
)
assert.strictEqual(result, true)
})
test('fails angular version validation when angular dependencies are missing', async () => {
const result = validateAngularVersion(
await getAngularVersion(fileURLToPath(new URL('fixtures/missing-angular-deps', import.meta.url))),
)
assert.strictEqual(result, false)
})
})