@@ -52,16 +52,9 @@ expect.addSnapshotSerializer(createAbsolutePathSerializer());
52
52
} ) ;
53
53
} ) ;
54
54
55
- const OSS_PLUGIN_PATH_POSIX = '/kibana/src/plugins/ossPlugin' ;
56
- const OSS_PLUGIN_PATH_WINDOWS = 'C:\\kibana\\src\\plugins\\ossPlugin' ;
57
- const XPACK_PLUGIN_PATH_POSIX = '/kibana/x-pack/plugins/xPackPlugin' ;
58
- const XPACK_PLUGIN_PATH_WINDOWS = 'C:\\kibana\\x-pack\\plugins\\xPackPlugin' ;
59
- [
60
- OSS_PLUGIN_PATH_POSIX ,
61
- OSS_PLUGIN_PATH_WINDOWS ,
62
- XPACK_PLUGIN_PATH_POSIX ,
63
- XPACK_PLUGIN_PATH_WINDOWS ,
64
- ] . forEach ( ( path ) => {
55
+ const OSS_PLUGIN_PATH = '/kibana/src/plugins/ossPlugin' ;
56
+ const XPACK_PLUGIN_PATH = '/kibana/x-pack/plugins/xPackPlugin' ;
57
+ [ OSS_PLUGIN_PATH , XPACK_PLUGIN_PATH ] . forEach ( ( path ) => {
65
58
jest . doMock ( join ( path , 'server' ) , ( ) => ( { } ) , {
66
59
virtual : true ,
67
60
} ) ;
@@ -272,6 +265,7 @@ describe('PluginsService', () => {
272
265
xPackPath : string ;
273
266
dependency : 'requiredPlugin' | 'requiredBundle' | 'optionalPlugin' ;
274
267
} ) {
268
+ // Each plugin's source is derived from its path; the PluginWrapper test suite contains more detailed test cases around the paths (for both POSIX and Windows)
275
269
mockDiscover . mockReturnValue ( {
276
270
error$ : from ( [ ] ) ,
277
271
plugin$ : from ( [
@@ -296,7 +290,7 @@ describe('PluginsService', () => {
296
290
297
291
async function expectError ( ) {
298
292
await expect ( pluginsService . discover ( { environment : environmentPreboot } ) ) . rejects . toThrow (
299
- `X-Pack plugin or bundle with id "xPackPlugin" is required by OSS plugin "ossPlugin", which is prohibited.`
293
+ `X-Pack plugin or bundle with id "xPackPlugin" is required by OSS plugin "ossPlugin", which is prohibited. Consider making this an optional dependency instead. `
300
294
) ;
301
295
expect ( standardMockPluginSystem . addPlugin ) . not . toHaveBeenCalled ( ) ;
302
296
}
@@ -307,64 +301,31 @@ describe('PluginsService', () => {
307
301
expect ( standardMockPluginSystem . addPlugin ) . toHaveBeenCalledTimes ( 2 ) ;
308
302
}
309
303
310
- describe ( 'throws if an OSS plugin requires an X-Pack plugin' , ( ) => {
311
- it ( 'in POSIX' , async ( ) => {
312
- mockDiscoveryResults ( {
313
- ossPath : OSS_PLUGIN_PATH_POSIX ,
314
- xPackPath : XPACK_PLUGIN_PATH_POSIX ,
315
- dependency : 'requiredPlugin' ,
316
- } ) ;
317
- await expectError ( ) ;
318
- } ) ;
319
-
320
- it ( 'in Windows' , async ( ) => {
321
- mockDiscoveryResults ( {
322
- ossPath : OSS_PLUGIN_PATH_WINDOWS ,
323
- xPackPath : XPACK_PLUGIN_PATH_WINDOWS ,
324
- dependency : 'requiredPlugin' ,
325
- } ) ;
326
- await expectError ( ) ;
304
+ it ( 'throws if an OSS plugin requires an X-Pack plugin' , async ( ) => {
305
+ mockDiscoveryResults ( {
306
+ ossPath : OSS_PLUGIN_PATH ,
307
+ xPackPath : XPACK_PLUGIN_PATH ,
308
+ dependency : 'requiredPlugin' ,
327
309
} ) ;
310
+ await expectError ( ) ;
328
311
} ) ;
329
312
330
- describe ( 'throws if an OSS plugin requires an X-Pack bundle' , ( ) => {
331
- it ( 'in POSIX' , async ( ) => {
332
- mockDiscoveryResults ( {
333
- ossPath : OSS_PLUGIN_PATH_POSIX ,
334
- xPackPath : XPACK_PLUGIN_PATH_POSIX ,
335
- dependency : 'requiredBundle' ,
336
- } ) ;
337
- await expectError ( ) ;
338
- } ) ;
339
-
340
- it ( 'in Windows' , async ( ) => {
341
- mockDiscoveryResults ( {
342
- ossPath : OSS_PLUGIN_PATH_WINDOWS ,
343
- xPackPath : XPACK_PLUGIN_PATH_WINDOWS ,
344
- dependency : 'requiredBundle' ,
345
- } ) ;
346
- await expectError ( ) ;
313
+ it ( 'throws if an OSS plugin requires an X-Pack bundle' , async ( ) => {
314
+ mockDiscoveryResults ( {
315
+ ossPath : OSS_PLUGIN_PATH ,
316
+ xPackPath : XPACK_PLUGIN_PATH ,
317
+ dependency : 'requiredBundle' ,
347
318
} ) ;
319
+ await expectError ( ) ;
348
320
} ) ;
349
321
350
- describe ( 'does not throw if an OSS plugin has an optional dependency on an X-Pack plugin' , ( ) => {
351
- it ( 'in POSIX' , async ( ) => {
352
- mockDiscoveryResults ( {
353
- ossPath : OSS_PLUGIN_PATH_POSIX ,
354
- xPackPath : XPACK_PLUGIN_PATH_POSIX ,
355
- dependency : 'optionalPlugin' ,
356
- } ) ;
357
- await expectSuccess ( ) ;
358
- } ) ;
359
-
360
- it ( 'in Windows' , async ( ) => {
361
- mockDiscoveryResults ( {
362
- ossPath : OSS_PLUGIN_PATH_WINDOWS ,
363
- xPackPath : XPACK_PLUGIN_PATH_WINDOWS ,
364
- dependency : 'optionalPlugin' ,
365
- } ) ;
366
- await expectSuccess ( ) ;
322
+ it ( 'does not throw if an OSS plugin has an optional dependency on an X-Pack plugin' , async ( ) => {
323
+ mockDiscoveryResults ( {
324
+ ossPath : OSS_PLUGIN_PATH ,
325
+ xPackPath : XPACK_PLUGIN_PATH ,
326
+ dependency : 'optionalPlugin' ,
367
327
} ) ;
328
+ await expectSuccess ( ) ;
368
329
} ) ;
369
330
} ) ;
370
331
0 commit comments