@@ -247,6 +247,79 @@ test('return error when manifest contains unrecognized properties', async () =>
247
247
} ) ;
248
248
} ) ;
249
249
250
+ describe ( 'requiredOpenSearchPlugins' , ( ) => {
251
+ test ( 'return error when plugin `requiredOpenSearchPlugins` is a string and not an array of string' , async ( ) => {
252
+ mockReadFilePromise . mockResolvedValue (
253
+ Buffer . from (
254
+ JSON . stringify ( {
255
+ id : 'id1' ,
256
+ version : '7.0.0' ,
257
+ server : true ,
258
+ requiredOpenSearchPlugins : 'abc' ,
259
+ } )
260
+ )
261
+ ) ;
262
+
263
+ await expect ( parseManifest ( pluginPath , packageInfo , logger ) ) . rejects . toMatchObject ( {
264
+ message : `The "requiredOpenSearchPlugins" in plugin manifest for "id1" should be an array of strings. (invalid-manifest, ${ pluginManifestPath } )` ,
265
+ type : PluginDiscoveryErrorType . InvalidManifest ,
266
+ path : pluginManifestPath ,
267
+ } ) ;
268
+ } ) ;
269
+
270
+ test ( 'return error when `requiredOpenSearchPlugins` is not a string' , async ( ) => {
271
+ mockReadFilePromise . mockResolvedValue (
272
+ Buffer . from ( JSON . stringify ( { id : 'id2' , version : '7.0.0' , requiredOpenSearchPlugins : 2 } ) )
273
+ ) ;
274
+
275
+ await expect ( parseManifest ( pluginPath , packageInfo , logger ) ) . rejects . toMatchObject ( {
276
+ message : `The "requiredOpenSearchPlugins" in plugin manifest for "id2" should be an array of strings. (invalid-manifest, ${ pluginManifestPath } )` ,
277
+ type : PluginDiscoveryErrorType . InvalidManifest ,
278
+ path : pluginManifestPath ,
279
+ } ) ;
280
+ } ) ;
281
+
282
+ test ( 'return error when plugin requiredOpenSearchPlugins is an array that contains non-string values' , async ( ) => {
283
+ mockReadFilePromise . mockResolvedValue (
284
+ Buffer . from (
285
+ JSON . stringify ( { id : 'id3' , version : '7.0.0' , requiredOpenSearchPlugins : [ 'plugin1' , 2 ] } )
286
+ )
287
+ ) ;
288
+
289
+ await expect ( parseManifest ( pluginPath , packageInfo , logger ) ) . rejects . toMatchObject ( {
290
+ message : `The "requiredOpenSearchPlugins" in plugin manifest for "id3" should be an array of strings. (invalid-manifest, ${ pluginManifestPath } )` ,
291
+ type : PluginDiscoveryErrorType . InvalidManifest ,
292
+ path : pluginManifestPath ,
293
+ } ) ;
294
+ } ) ;
295
+
296
+ test ( 'Happy path when plugin `requiredOpenSearchPlugins` is an array of string' , async ( ) => {
297
+ mockReadFilePromise . mockResolvedValue (
298
+ Buffer . from (
299
+ JSON . stringify ( {
300
+ id : 'id1' ,
301
+ version : '7.0.0' ,
302
+ server : true ,
303
+ requiredOpenSearchPlugins : [ 'plugin1' , 'plugin2' ] ,
304
+ } )
305
+ )
306
+ ) ;
307
+
308
+ await expect ( parseManifest ( pluginPath , packageInfo , logger ) ) . resolves . toEqual ( {
309
+ id : 'id1' ,
310
+ configPath : 'id_1' ,
311
+ version : '7.0.0' ,
312
+ opensearchDashboardsVersion : '7.0.0' ,
313
+ optionalPlugins : [ ] ,
314
+ requiredPlugins : [ ] ,
315
+ requiredOpenSearchPlugins : [ 'plugin1' , 'plugin2' ] ,
316
+ requiredBundles : [ ] ,
317
+ server : true ,
318
+ ui : false ,
319
+ } ) ;
320
+ } ) ;
321
+ } ) ;
322
+
250
323
describe ( 'configPath' , ( ) => {
251
324
test ( 'falls back to plugin id if not specified' , async ( ) => {
252
325
mockReadFilePromise . mockResolvedValue (
@@ -301,6 +374,7 @@ test('set defaults for all missing optional fields', async () => {
301
374
opensearchDashboardsVersion : '7.0.0' ,
302
375
optionalPlugins : [ ] ,
303
376
requiredPlugins : [ ] ,
377
+ requiredOpenSearchPlugins : [ ] ,
304
378
requiredBundles : [ ] ,
305
379
server : true ,
306
380
ui : false ,
@@ -317,6 +391,7 @@ test('return all set optional fields as they are in manifest', async () => {
317
391
opensearchDashboardsVersion : '7.0.0' ,
318
392
requiredPlugins : [ 'some-required-plugin' , 'some-required-plugin-2' ] ,
319
393
optionalPlugins : [ 'some-optional-plugin' ] ,
394
+ requiredOpenSearchPlugins : [ 'test-opensearch-plugin-1' , 'test-opensearch-plugin-2' ] ,
320
395
ui : true ,
321
396
} )
322
397
)
@@ -330,6 +405,7 @@ test('return all set optional fields as they are in manifest', async () => {
330
405
optionalPlugins : [ 'some-optional-plugin' ] ,
331
406
requiredBundles : [ ] ,
332
407
requiredPlugins : [ 'some-required-plugin' , 'some-required-plugin-2' ] ,
408
+ requiredOpenSearchPlugins : [ 'test-opensearch-plugin-1' , 'test-opensearch-plugin-2' ] ,
333
409
server : false ,
334
410
ui : true ,
335
411
} ) ;
@@ -344,6 +420,7 @@ test('return manifest when plugin expected OpenSearch Dashboards version matches
344
420
version : 'some-version' ,
345
421
opensearchDashboardsVersion : '7.0.0-alpha2' ,
346
422
requiredPlugins : [ 'some-required-plugin' ] ,
423
+ requiredOpenSearchPlugins : [ ] ,
347
424
server : true ,
348
425
} )
349
426
)
@@ -356,6 +433,7 @@ test('return manifest when plugin expected OpenSearch Dashboards version matches
356
433
opensearchDashboardsVersion : '7.0.0-alpha2' ,
357
434
optionalPlugins : [ ] ,
358
435
requiredPlugins : [ 'some-required-plugin' ] ,
436
+ requiredOpenSearchPlugins : [ ] ,
359
437
requiredBundles : [ ] ,
360
438
server : true ,
361
439
ui : false ,
@@ -383,6 +461,7 @@ test('return manifest when plugin expected OpenSearch Dashboards version is `ope
383
461
opensearchDashboardsVersion : 'opensearchDashboards' ,
384
462
optionalPlugins : [ ] ,
385
463
requiredPlugins : [ 'some-required-plugin' ] ,
464
+ requiredOpenSearchPlugins : [ ] ,
386
465
requiredBundles : [ ] ,
387
466
server : true ,
388
467
ui : true ,
0 commit comments