forked from electron-userland/electron-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathassistedInstallerTest.ts
195 lines (186 loc) · 5.01 KB
/
assistedInstallerTest.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
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
import { Arch, archFromString, Platform } from "electron-builder"
import * as fs from "fs/promises"
import * as path from "path"
import { app, assertPack, copyTestAsset } from "../helpers/packTester"
import { checkHelpers, doTest, expectUpdateMetadata } from "../helpers/winHelper"
const nsisTarget = Platform.WINDOWS.createTarget(["nsis"])
test.ifNotCiMac(
"assisted",
app(
{
targets: nsisTarget,
config: {
nsis: {
oneClick: false,
language: "1031",
},
win: {
legalTrademarks: "My Trademark",
},
},
},
{
signedWin: true,
projectDirCreated: projectDir => copyTestAsset("license.txt", path.join(projectDir, "build", "license.txt")),
}
)
)
test.ifAll.ifNotCiMac(
"allowElevation false, app requestedExecutionLevel admin",
app({
targets: nsisTarget,
config: {
publish: null,
extraMetadata: {
// mt.exe doesn't like unicode names from wine
name: "test",
productName: "test",
},
win: {
requestedExecutionLevel: "requireAdministrator",
},
nsis: {
oneClick: false,
allowElevation: false,
perMachine: true,
displayLanguageSelector: true,
installerLanguages: ["en_US", "ru_RU"],
differentialPackage: false,
},
},
})
)
test.ifNotCiMac("assisted, MUI_HEADER", () => {
let installerHeaderPath: string | null = null
return assertPack(
"test-app-one",
{
targets: nsisTarget,
config: {
publish: null,
nsis: {
oneClick: false,
differentialPackage: false,
},
},
effectiveOptionComputed: async it => {
const defines = it[0]
expect(defines.MUI_HEADERIMAGE).toBeNull()
expect(defines.MUI_HEADERIMAGE_BITMAP).toEqual(installerHeaderPath)
expect(defines.MUI_HEADERIMAGE_RIGHT).toBeNull()
// speedup, do not build - another MUI_HEADER test will test build
return true
},
},
{
projectDirCreated: projectDir => {
installerHeaderPath = path.join(projectDir, "build", "installerHeader.bmp")
return copyTestAsset("installerHeader.bmp", installerHeaderPath)
},
}
)
})
test.ifAll.ifNotCiMac("assisted, MUI_HEADER as option", () => {
let installerHeaderPath: string | null = null
return assertPack(
"test-app-one",
{
targets: Platform.WINDOWS.createTarget(["nsis"], Arch.ia32, Arch.x64),
config: {
publish: null,
nsis: {
oneClick: false,
installerHeader: "foo.bmp",
differentialPackage: false,
},
},
effectiveOptionComputed: async it => {
const defines = it[0]
expect(defines.MUI_HEADERIMAGE).toBeNull()
expect(defines.MUI_HEADERIMAGE_BITMAP).toEqual(installerHeaderPath)
expect(defines.MUI_HEADERIMAGE_RIGHT).toBeNull()
// test that we can build such installer
return false
},
},
{
projectDirCreated: projectDir => {
installerHeaderPath = path.join(projectDir, "foo.bmp")
return copyTestAsset("installerHeader.bmp", installerHeaderPath)
},
}
)
})
test.skip.ifNotCiMac(
"debug logging enabled",
app({
targets: nsisTarget,
config: {
nsis: {
customNsisBinary: {
url: "https://github.com/electron-userland/electron-builder-binaries/releases/download/nsis-3.0.4.2/nsis-3.0.4.2.7z",
version: "3.0.4.2",
checksum: "o+YZsXHp8LNihhuk7JsCDhdIgx0MKKK+1b3sGD+4zX5djZULe4/4QMcAsfQ+0r+a8FnwBt7BVBHkIkJHjKQ0sg==",
debugLogging: true,
},
},
},
})
)
test.ifNotCiMac(
"assisted, only perMachine",
app({
targets: nsisTarget,
config: {
nsis: {
oneClick: false,
perMachine: true,
},
},
})
)
test.ifNotCiMac(
"assisted, only perMachine and elevated",
app({
targets: nsisTarget,
config: {
nsis: {
oneClick: false,
perMachine: true,
packElevateHelper: true
},
},
})
)
// test release notes also
test.ifAll.ifNotCiMac(
"allowToChangeInstallationDirectory",
app(
{
targets: nsisTarget,
config: {
extraMetadata: {
name: "test-custom-inst-dir",
productName: "Test Custom Installation Dir",
repository: "foo/bar",
},
nsis: {
allowToChangeInstallationDirectory: true,
oneClick: false,
multiLanguageInstaller: false,
},
},
},
{
projectDirCreated: async projectDir => {
await fs.writeFile(path.join(projectDir, "build", "release-notes.md"), "New release with new bugs and\n\nwithout features")
await copyTestAsset("license.txt", path.join(projectDir, "build", "license.txt"))
},
packed: async context => {
await expectUpdateMetadata(context, archFromString(process.arch))
await checkHelpers(context.getResources(Platform.WINDOWS), true)
await doTest(context.outDir, false)
},
}
)
)