5
5
*/
6
6
7
7
import { User } from "@gitpod/gitpod-protocol" ;
8
- import { IDEOption , IDEOptions } from "@gitpod/gitpod-protocol/lib/ide-protocol" ;
9
8
import * as chai from "chai" ;
10
- import { migrationIDESettings , chooseIDE } from "./workspace-starter " ;
9
+ import { IDEService } from "../ide-service " ;
11
10
const expect = chai . expect ;
12
11
13
- describe ( "workspace-starter" , function ( ) {
14
- describe ( "migrationIDESettings" , function ( ) {
12
+ describe ( "ide-service" , function ( ) {
13
+ describe ( "ideService.migrateSettings" , function ( ) {
14
+ const ideService = new IDEService ( ) ;
15
15
it ( "with no ideSettings should be undefined" , function ( ) {
16
16
const user : User = {
17
17
id : "string" ,
18
18
creationDate : "string" ,
19
19
identities : [ ] ,
20
20
additionalData : { } ,
21
21
} ;
22
- const result = migrationIDESettings ( user ) ;
22
+ const result = ideService . migrateSettings ( user ) ;
23
23
expect ( result ) . to . undefined ;
24
24
} ) ;
25
25
@@ -36,7 +36,7 @@ describe("workspace-starter", function () {
36
36
} ,
37
37
} ,
38
38
} ;
39
- const result = migrationIDESettings ( user ) ;
39
+ const result = ideService . migrateSettings ( user ) ;
40
40
expect ( result ) . to . undefined ;
41
41
} ) ;
42
42
@@ -52,7 +52,7 @@ describe("workspace-starter", function () {
52
52
} ,
53
53
} ,
54
54
} ;
55
- const result = migrationIDESettings ( user ) ;
55
+ const result = ideService . migrateSettings ( user ) ;
56
56
expect ( result ?. defaultIde ) . to . equal ( "code" ) ;
57
57
expect ( result ?. useLatestVersion ?? false ) . to . be . true ;
58
58
} ) ;
@@ -70,7 +70,7 @@ describe("workspace-starter", function () {
70
70
} ,
71
71
} ,
72
72
} ;
73
- const result = migrationIDESettings ( user ) ;
73
+ const result = ideService . migrateSettings ( user ) ;
74
74
expect ( result ?. defaultIde ) . to . equal ( "code-desktop" ) ;
75
75
expect ( result ?. useLatestVersion ?? false ) . to . be . true ;
76
76
} ) ;
@@ -88,7 +88,7 @@ describe("workspace-starter", function () {
88
88
} ,
89
89
} ,
90
90
} ;
91
- const result = migrationIDESettings ( user ) ;
91
+ const result = ideService . migrateSettings ( user ) ;
92
92
expect ( result ?. defaultIde ) . to . equal ( "code-desktop" ) ;
93
93
expect ( result ?. useLatestVersion ?? false ) . to . be . false ;
94
94
} ) ;
@@ -107,7 +107,7 @@ describe("workspace-starter", function () {
107
107
} ,
108
108
} ,
109
109
} ;
110
- const result = migrationIDESettings ( user ) ;
110
+ const result = ideService . migrateSettings ( user ) ;
111
111
expect ( result ?. defaultIde ) . to . equal ( "intellij" ) ;
112
112
expect ( result ?. useLatestVersion ?? false ) . to . be . false ;
113
113
} ) ;
@@ -126,7 +126,7 @@ describe("workspace-starter", function () {
126
126
} ,
127
127
} ,
128
128
} ;
129
- const result = migrationIDESettings ( user ) ;
129
+ const result = ideService . migrateSettings ( user ) ;
130
130
expect ( result ?. defaultIde ) . to . equal ( "intellij" ) ;
131
131
expect ( result ?. useLatestVersion ?? false ) . to . be . true ;
132
132
} ) ;
@@ -145,123 +145,9 @@ describe("workspace-starter", function () {
145
145
} ,
146
146
} ,
147
147
} ;
148
- const result = migrationIDESettings ( user ) ;
148
+ const result = ideService . migrateSettings ( user ) ;
149
149
expect ( result ?. defaultIde ) . to . equal ( "code" ) ;
150
150
expect ( result ?. useLatestVersion ?? false ) . to . be . true ;
151
151
} ) ;
152
152
} ) ;
153
- describe ( "chooseIDE" , async function ( ) {
154
- const baseOpt : IDEOption = {
155
- title : "title" ,
156
- type : "desktop" ,
157
- logo : "" ,
158
- image : "image" ,
159
- latestImage : "latestImage" ,
160
- } ;
161
- const ideOptions : IDEOptions = {
162
- options : {
163
- code : Object . assign ( { } , baseOpt , { type : "browser" } ) ,
164
- goland : Object . assign ( { } , baseOpt ) ,
165
- "code-desktop" : Object . assign ( { } , baseOpt ) ,
166
- "no-latest" : Object . assign ( { } , baseOpt ) ,
167
- } ,
168
- defaultIde : "code" ,
169
- defaultDesktopIde : "code-desktop" ,
170
- } ;
171
- delete ideOptions . options [ "no-latest" ] . latestImage ;
172
-
173
- it ( "code with latest" , function ( ) {
174
- const useLatest = true ;
175
- const hasPerm = false ;
176
- const result = chooseIDE ( "code" , ideOptions , useLatest , hasPerm ) ;
177
- expect ( result . ideImage ) . to . equal ( ideOptions . options [ "code" ] . latestImage ) ;
178
- } ) ;
179
-
180
- it ( "code without latest" , function ( ) {
181
- const useLatest = false ;
182
- const hasPerm = false ;
183
- const result = chooseIDE ( "code" , ideOptions , useLatest , hasPerm ) ;
184
- expect ( result . ideImage ) . to . equal ( ideOptions . options [ "code" ] . image ) ;
185
- } ) ;
186
-
187
- it ( "desktop ide with latest" , function ( ) {
188
- const useLatest = true ;
189
- const hasPerm = false ;
190
- const result = chooseIDE ( "code-desktop" , ideOptions , useLatest , hasPerm ) ;
191
- expect ( result . ideImage ) . to . equal ( ideOptions . options [ "code" ] . latestImage ) ;
192
- expect ( result . desktopIdeImage ) . to . equal ( ideOptions . options [ "code-desktop" ] . latestImage ) ;
193
- } ) ;
194
-
195
- it ( "desktop ide (JetBrains) without latest" , function ( ) {
196
- const useLatest = false ;
197
- const hasPerm = false ;
198
- const result = chooseIDE ( "goland" , ideOptions , useLatest , hasPerm ) ;
199
- expect ( result . ideImage ) . to . equal ( ideOptions . options [ "code" ] . image ) ;
200
- expect ( result . desktopIdeImage ) . to . equal ( ideOptions . options [ "goland" ] . image ) ;
201
- } ) ;
202
-
203
- it ( "desktop ide with no latest image" , function ( ) {
204
- const useLatest = true ;
205
- const hasPerm = false ;
206
- const result = chooseIDE ( "no-latest" , ideOptions , useLatest , hasPerm ) ;
207
- expect ( result . ideImage ) . to . equal ( ideOptions . options [ "code" ] . latestImage ) ;
208
- expect ( result . desktopIdeImage ) . to . equal ( ideOptions . options [ "no-latest" ] . image ) ;
209
- } ) ;
210
-
211
- it ( "unknown ide with custom permission should be unknown" , function ( ) {
212
- const customOptions = Object . assign ( { } , ideOptions ) ;
213
- customOptions . options [ "unknown-custom" ] = {
214
- title : "unknown title" ,
215
- type : "browser" ,
216
- logo : "" ,
217
- image : "" ,
218
- } ;
219
- const useLatest = true ;
220
- const hasPerm = true ;
221
- const result = chooseIDE ( "unknown-custom" , customOptions , useLatest , hasPerm ) ;
222
- expect ( result . ideImage ) . to . equal ( "unknown-custom" ) ;
223
- } ) ;
224
-
225
- it ( "unknown desktop ide with custom permission desktop should be unknown" , function ( ) {
226
- const customOptions = Object . assign ( { } , ideOptions ) ;
227
- customOptions . options [ "unknown-custom" ] = {
228
- title : "unknown title" ,
229
- type : "desktop" ,
230
- logo : "" ,
231
- image : "" ,
232
- } ;
233
- const useLatest = true ;
234
- const hasPerm = true ;
235
- const result = chooseIDE ( "unknown-custom" , customOptions , useLatest , hasPerm ) ;
236
- expect ( result . desktopIdeImage ) . to . equal ( "unknown-custom" ) ;
237
- } ) ;
238
-
239
- it ( "unknown browser ide without custom permission should fallback to code" , function ( ) {
240
- const customOptions = Object . assign ( { } , ideOptions ) ;
241
- customOptions . options [ "unknown-custom" ] = {
242
- title : "unknown title" ,
243
- type : "browser" ,
244
- logo : "" ,
245
- image : "" ,
246
- } ;
247
- const useLatest = true ;
248
- const hasPerm = false ;
249
- const result = chooseIDE ( "unknown-custom" , customOptions , useLatest , hasPerm ) ;
250
- expect ( result . ideImage ) . to . equal ( ideOptions . options [ "code" ] . latestImage ) ;
251
- } ) ;
252
-
253
- it ( "not exists ide with custom permission" , function ( ) {
254
- const useLatest = true ;
255
- const hasPerm = true ;
256
- const result = chooseIDE ( "not-exists" , ideOptions , useLatest , hasPerm ) ;
257
- expect ( result . ideImage ) . to . equal ( ideOptions . options [ "code" ] . latestImage ) ;
258
- } ) ;
259
-
260
- it ( "not exists ide with custom permission" , function ( ) {
261
- const useLatest = true ;
262
- const hasPerm = false ;
263
- const result = chooseIDE ( "not-exists" , ideOptions , useLatest , hasPerm ) ;
264
- expect ( result . ideImage ) . to . equal ( ideOptions . options [ "code" ] . latestImage ) ;
265
- } ) ;
266
- } ) ;
267
153
} ) ;
0 commit comments