@@ -32,6 +32,7 @@ const fooAssetIcon = {
32
32
data : 'fooIcon' ,
33
33
} ;
34
34
35
+ // unlisted field is not present (assuming it should be listed then)
35
36
const fakePublishedExtension1 = {
36
37
publisher : {
37
38
publisherName : 'foo' ,
@@ -52,6 +53,52 @@ const fakePublishedExtension1 = {
52
53
} ,
53
54
] ,
54
55
} ;
56
+
57
+ // this one is unlisted with field unlisted being true
58
+ const fakePublishedExtension2 = {
59
+ publisher : {
60
+ publisherName : 'foo2' ,
61
+ displayName : 'Foo publisher display name' ,
62
+ } ,
63
+ extensionName : 'fooName2' ,
64
+ displayName : 'Foo2 extension display name' ,
65
+ shortDescription : 'Foo2 extension short description' ,
66
+ license : 'Apache-2.0' ,
67
+ unlisted : true ,
68
+ categories : [ 'Kubernetes' ] ,
69
+ versions : [
70
+ {
71
+ version : '1.0.0' ,
72
+ preview : false ,
73
+ lastUpdated : '2021-01-01T00:00:00.000Z' ,
74
+ ociUri : 'oci-registry.foo/foo/bar' ,
75
+ files : [ fooAssetIcon ] ,
76
+ } ,
77
+ ] ,
78
+ } ;
79
+
80
+ // this one is unlisted with field unlisted being false
81
+ const fakePublishedExtension3 = {
82
+ publisher : {
83
+ publisherName : 'foo3' ,
84
+ displayName : 'Foo publisher display name' ,
85
+ } ,
86
+ extensionName : 'fooName3' ,
87
+ displayName : 'Foo3 extension display name' ,
88
+ shortDescription : 'Foo3 extension short description' ,
89
+ license : 'Apache-2.0' ,
90
+ unlisted : false ,
91
+ categories : [ 'Kubernetes' ] ,
92
+ versions : [
93
+ {
94
+ version : '1.0.0' ,
95
+ preview : false ,
96
+ lastUpdated : '2021-01-01T00:00:00.000Z' ,
97
+ ociUri : 'oci-registry.foo/foo/bar' ,
98
+ files : [ fooAssetIcon ] ,
99
+ } ,
100
+ ] ,
101
+ } ;
55
102
const isEnabledProxyMock = vi . fn ( ) ;
56
103
const onDidUpdateProxyEmitter = new Emitter < ProxySettings > ( ) ;
57
104
const getAllCertificatesMock = vi . fn ( ) ;
@@ -176,3 +223,34 @@ test('should get all extensions', async () => {
176
223
// no error
177
224
expect ( console . error ) . not . toBeCalled ( ) ;
178
225
} ) ;
226
+
227
+ test ( 'should get proper unlisted fields' , async ( ) => {
228
+ const url = new URL ( ExtensionsCatalog . ALL_EXTENSIONS_URL ) ;
229
+ const host = url . origin ;
230
+ const pathname = url . pathname ;
231
+ nock ( host )
232
+ . get ( pathname )
233
+ . reply ( 200 , {
234
+ extensions : [ fakePublishedExtension1 , fakePublishedExtension2 , fakePublishedExtension3 ] ,
235
+ } ) ;
236
+
237
+ const allExtensions = await extensionsCatalog . getExtensions ( ) ;
238
+ expect ( allExtensions ) . toBeDefined ( ) ;
239
+ expect ( allExtensions . length ) . toBe ( 3 ) ;
240
+
241
+ // check data
242
+ const missingUnlistedExtension = allExtensions . find ( e => e . id === 'foo.fooName' ) ;
243
+ expect ( missingUnlistedExtension ) . toBeDefined ( ) ;
244
+ expect ( missingUnlistedExtension ?. unlisted ) . toBeFalsy ( ) ;
245
+
246
+ const unlistedTrueExtension = allExtensions . find ( e => e . id === 'foo2.fooName2' ) ;
247
+ expect ( unlistedTrueExtension ) . toBeDefined ( ) ;
248
+ expect ( unlistedTrueExtension ?. unlisted ) . toBeTruthy ( ) ;
249
+
250
+ const unlistedFalseExtension = allExtensions . find ( e => e . id === 'foo3.fooName3' ) ;
251
+ expect ( unlistedFalseExtension ) . toBeDefined ( ) ;
252
+ expect ( unlistedFalseExtension ?. unlisted ) . toBeFalsy ( ) ;
253
+
254
+ // no error
255
+ expect ( console . error ) . not . toBeCalled ( ) ;
256
+ } ) ;
0 commit comments