@@ -279,6 +279,60 @@ test('return error when manifest contains unrecognized properties', async () =>
279
279
} ) ;
280
280
} ) ;
281
281
282
+ test ( 'return error when plugin `requiredOpenSearchPlugins` is a string and not an array of string' , async ( ) => {
283
+ mockReadFile . mockImplementation ( ( path , cb ) => {
284
+ cb (
285
+ null ,
286
+ Buffer . from (
287
+ JSON . stringify ( {
288
+ id : 'id1' ,
289
+ version : '7.0.0' ,
290
+ server : true ,
291
+ requiredOpenSearchPlugins : 'abc' ,
292
+ } )
293
+ )
294
+ ) ;
295
+ } ) ;
296
+
297
+ await expect ( parseManifest ( pluginPath , packageInfo , logger ) ) . rejects . toMatchObject ( {
298
+ message : `The "requiredOpenSearchPlugins" in plugin manifest for "id1" should be an array of strings. (invalid-manifest, ${ pluginManifestPath } )` ,
299
+ type : PluginDiscoveryErrorType . InvalidManifest ,
300
+ path : pluginManifestPath ,
301
+ } ) ;
302
+ } ) ;
303
+
304
+ test ( 'return error when `requiredOpenSearchPlugins` is not a string' , async ( ) => {
305
+ mockReadFile . mockImplementation ( ( path , cb ) => {
306
+ cb (
307
+ null ,
308
+ Buffer . from ( JSON . stringify ( { id : 'id2' , version : '7.0.0' , requiredOpenSearchPlugins : 2 } ) )
309
+ ) ;
310
+ } ) ;
311
+
312
+ await expect ( parseManifest ( pluginPath , packageInfo , logger ) ) . rejects . toMatchObject ( {
313
+ message : `The "requiredOpenSearchPlugins" in plugin manifest for "id2" should be an array of strings. (invalid-manifest, ${ pluginManifestPath } )` ,
314
+ type : PluginDiscoveryErrorType . InvalidManifest ,
315
+ path : pluginManifestPath ,
316
+ } ) ;
317
+ } ) ;
318
+
319
+ test ( 'return error when plugin requiredOpenSearchPlugins is an array that contains non-string values' , async ( ) => {
320
+ mockReadFile . mockImplementation ( ( path , cb ) => {
321
+ cb (
322
+ null ,
323
+ Buffer . from (
324
+ JSON . stringify ( { id : 'id3' , version : '7.0.0' , requiredOpenSearchPlugins : [ 'plugin1' , 2 ] } )
325
+ )
326
+ ) ;
327
+ } ) ;
328
+
329
+ await expect ( parseManifest ( pluginPath , packageInfo , logger ) ) . rejects . toMatchObject ( {
330
+ message : `The "requiredOpenSearchPlugins" in plugin manifest for "id3" should be an array of strings. (invalid-manifest, ${ pluginManifestPath } )` ,
331
+ type : PluginDiscoveryErrorType . InvalidManifest ,
332
+ path : pluginManifestPath ,
333
+ } ) ;
334
+ } ) ;
335
+
282
336
describe ( 'configPath' , ( ) => {
283
337
test ( 'falls back to plugin id if not specified' , async ( ) => {
284
338
mockReadFile . mockImplementation ( ( path , cb ) => {
@@ -339,6 +393,7 @@ test('set defaults for all missing optional fields', async () => {
339
393
opensearchDashboardsVersion : '7.0.0' ,
340
394
optionalPlugins : [ ] ,
341
395
requiredPlugins : [ ] ,
396
+ requiredOpenSearchPlugins : [ ] ,
342
397
requiredBundles : [ ] ,
343
398
server : true ,
344
399
ui : false ,
@@ -357,6 +412,7 @@ test('return all set optional fields as they are in manifest', async () => {
357
412
opensearchDashboardsVersion : '7.0.0' ,
358
413
requiredPlugins : [ 'some-required-plugin' , 'some-required-plugin-2' ] ,
359
414
optionalPlugins : [ 'some-optional-plugin' ] ,
415
+ requiredOpenSearchPlugins : [ 'test-opensearch-plugin-1' , 'test-opensearch-plugin-2' ] ,
360
416
ui : true ,
361
417
} )
362
418
)
@@ -371,6 +427,7 @@ test('return all set optional fields as they are in manifest', async () => {
371
427
optionalPlugins : [ 'some-optional-plugin' ] ,
372
428
requiredBundles : [ ] ,
373
429
requiredPlugins : [ 'some-required-plugin' , 'some-required-plugin-2' ] ,
430
+ requiredOpenSearchPlugins : [ 'test-opensearch-plugin-1' , 'test-opensearch-plugin-2' ] ,
374
431
server : false ,
375
432
ui : true ,
376
433
} ) ;
@@ -387,6 +444,7 @@ test('return manifest when plugin expected OpenSearch Dashboards version matches
387
444
version : 'some-version' ,
388
445
opensearchDashboardsVersion : '7.0.0-alpha2' ,
389
446
requiredPlugins : [ 'some-required-plugin' ] ,
447
+ requiredOpenSearchPlugins : [ ] ,
390
448
server : true ,
391
449
} )
392
450
)
@@ -400,6 +458,7 @@ test('return manifest when plugin expected OpenSearch Dashboards version matches
400
458
opensearchDashboardsVersion : '7.0.0-alpha2' ,
401
459
optionalPlugins : [ ] ,
402
460
requiredPlugins : [ 'some-required-plugin' ] ,
461
+ requiredOpenSearchPlugins : [ ] ,
403
462
requiredBundles : [ ] ,
404
463
server : true ,
405
464
ui : false ,
@@ -430,6 +489,7 @@ test('return manifest when plugin expected OpenSearch Dashboards version is `ope
430
489
opensearchDashboardsVersion : 'opensearchDashboards' ,
431
490
optionalPlugins : [ ] ,
432
491
requiredPlugins : [ 'some-required-plugin' ] ,
492
+ requiredOpenSearchPlugins : [ ] ,
433
493
requiredBundles : [ ] ,
434
494
server : true ,
435
495
ui : true ,
0 commit comments