55 * 2.0.
66 */
77
8- import { cloudMock } from '@kbn/cloud-plugin/public/mocks' ;
98import { coreMock } from '@kbn/core/public/mocks' ;
109import { homePluginMock } from '@kbn/home-plugin/public/mocks' ;
1110import {
@@ -20,7 +19,7 @@ describe('Spaces plugin', () => {
2019 it ( 'should register the space selector app when buildFlavor is traditional' , ( ) => {
2120 const coreSetup = coreMock . createSetup ( ) ;
2221 const mockInitializerContext = coreMock . createPluginInitializerContext (
23- { } ,
22+ { allowSolutionVisibility : true } ,
2423 { buildFlavor : 'traditional' }
2524 ) ;
2625
@@ -40,7 +39,7 @@ describe('Spaces plugin', () => {
4039 it ( 'should not register the space selector app when buildFlavor is serverless and maxSpaces is 1' , ( ) => {
4140 const coreSetup = coreMock . createSetup ( ) ;
4241 const mockInitializerContext = coreMock . createPluginInitializerContext (
43- { maxSpaces : 1 } ,
42+ { maxSpaces : 1 , allowSolutionVisibility : true } ,
4443 { buildFlavor : 'serverless' }
4544 ) ;
4645
@@ -60,7 +59,7 @@ describe('Spaces plugin', () => {
6059 it ( 'should register the space selector app when buildFlavor is serverless and and maxSpaces is >1' , ( ) => {
6160 const coreSetup = coreMock . createSetup ( ) ;
6261 const mockInitializerContext = coreMock . createPluginInitializerContext (
63- { maxSpaces : 2 } ,
62+ { maxSpaces : 2 , allowSolutionVisibility : true } ,
6463 { buildFlavor : 'serverless' }
6564 ) ;
6665
@@ -88,7 +87,7 @@ describe('Spaces plugin', () => {
8887 management . sections . section . kibana = mockSection ;
8988
9089 const mockInitializerContext = coreMock . createPluginInitializerContext (
91- { } ,
90+ { allowSolutionVisibility : true } ,
9291 { buildFlavor : 'traditional' }
9392 ) ;
9493
@@ -122,7 +121,9 @@ describe('Spaces plugin', () => {
122121
123122 management . sections . section . kibana = mockSection ;
124123
125- const plugin = new SpacesPlugin ( coreMock . createPluginInitializerContext ( { maxSpaces : 1 } ) ) ;
124+ const plugin = new SpacesPlugin (
125+ coreMock . createPluginInitializerContext ( { maxSpaces : 1 , allowSolutionVisibility : true } )
126+ ) ;
126127 plugin . setup ( coreSetup , {
127128 management,
128129 home,
@@ -152,7 +153,9 @@ describe('Spaces plugin', () => {
152153
153154 management . sections . section . kibana = mockSection ;
154155
155- const plugin = new SpacesPlugin ( coreMock . createPluginInitializerContext ( { maxSpaces : 2 } ) ) ;
156+ const plugin = new SpacesPlugin (
157+ coreMock . createPluginInitializerContext ( { maxSpaces : 2 , allowSolutionVisibility : true } )
158+ ) ;
156159 plugin . setup ( coreSetup , {
157160 management,
158161 home,
@@ -179,7 +182,7 @@ describe('Spaces plugin', () => {
179182 const coreStart = coreMock . createStart ( ) ;
180183
181184 const mockInitializerContext = coreMock . createPluginInitializerContext (
182- { } ,
185+ { allowSolutionVisibility : true } ,
183186 { buildFlavor : 'traditional' }
184187 ) ;
185188
@@ -196,7 +199,7 @@ describe('Spaces plugin', () => {
196199 const coreStart = coreMock . createStart ( ) ;
197200
198201 const mockInitializerContext = coreMock . createPluginInitializerContext (
199- { maxSpaces : 1 } ,
202+ { maxSpaces : 1 , allowSolutionVisibility : true } ,
200203 { buildFlavor : 'serverless' }
201204 ) ;
202205
@@ -214,7 +217,9 @@ describe('Spaces plugin', () => {
214217 const coreSetup = coreMock . createSetup ( ) ;
215218 const coreStart = coreMock . createStart ( ) ;
216219
217- const plugin = new SpacesPlugin ( coreMock . createPluginInitializerContext ( { maxSpaces : 1 } ) ) ;
220+ const plugin = new SpacesPlugin (
221+ coreMock . createPluginInitializerContext ( { maxSpaces : 1 , allowSolutionVisibility : true } )
222+ ) ;
218223 const spacesSetup = plugin . setup ( coreSetup , { } ) ;
219224 const spacesStart = plugin . start ( coreStart ) ;
220225
@@ -226,7 +231,9 @@ describe('Spaces plugin', () => {
226231 const coreSetup = coreMock . createSetup ( ) ;
227232 const coreStart = coreMock . createStart ( ) ;
228233
229- const plugin = new SpacesPlugin ( coreMock . createPluginInitializerContext ( { maxSpaces : 1000 } ) ) ;
234+ const plugin = new SpacesPlugin (
235+ coreMock . createPluginInitializerContext ( { maxSpaces : 1000 , allowSolutionVisibility : true } )
236+ ) ;
230237 const spacesSetup = plugin . setup ( coreSetup , { } ) ;
231238 const spacesStart = plugin . start ( coreStart ) ;
232239
@@ -236,129 +243,45 @@ describe('Spaces plugin', () => {
236243 } ) ;
237244
238245 describe ( 'isSolutionViewEnabled' , ( ) => {
239- it ( 'when onCloud, not serverless and allowSolutionVisibility is "true"' , ( ) => {
246+ it ( 'when allowSolutionVisibility is "true"' , ( ) => {
240247 const coreSetup = coreMock . createSetup ( ) ;
241248 const coreStart = coreMock . createStart ( ) ;
242- const cloud = cloudMock . createSetup ( ) ;
243- cloud . isCloudEnabled = true ;
244249
245250 const plugin = new SpacesPlugin (
246- coreMock . createPluginInitializerContext (
247- { allowSolutionVisibility : true } ,
248- { buildFlavor : 'traditional' }
249- )
251+ coreMock . createPluginInitializerContext ( { allowSolutionVisibility : true } )
250252 ) ;
251- const spacesSetup = plugin . setup ( coreSetup , { cloud } ) ;
253+ const spacesSetup = plugin . setup ( coreSetup , { } ) ;
252254 const spacesStart = plugin . start ( coreStart ) ;
253255
254256 expect ( spacesSetup . isSolutionViewEnabled ) . toBe ( true ) ;
255257 expect ( spacesStart . isSolutionViewEnabled ) . toBe ( true ) ;
256258 } ) ;
257259
258- it ( 'when not onCloud and allowSolutionVisibility is "true "' , ( ) => {
260+ it ( 'when allowSolutionVisibility is "false "' , ( ) => {
259261 const coreSetup = coreMock . createSetup ( ) ;
260262 const coreStart = coreMock . createStart ( ) ;
261263
262264 {
263265 const plugin = new SpacesPlugin (
264- coreMock . createPluginInitializerContext (
265- { allowSolutionVisibility : true } , // it is true but we are not onCloud
266- { buildFlavor : 'traditional' }
267- )
266+ coreMock . createPluginInitializerContext ( { allowSolutionVisibility : false } )
268267 ) ;
269268 const spacesSetup = plugin . setup ( coreSetup , { } ) ;
270269 const spacesStart = plugin . start ( coreStart ) ;
271270
272- expect ( spacesSetup . isSolutionViewEnabled ) . toBe ( false ) ; // so it should be false
273- expect ( spacesStart . isSolutionViewEnabled ) . toBe ( false ) ;
274- }
275-
276- {
277- // unless the forceSolutionVisibility flag is set
278- const plugin = new SpacesPlugin (
279- coreMock . createPluginInitializerContext (
280- { allowSolutionVisibility : false , experimental : { forceSolutionVisibility : true } } ,
281- { buildFlavor : 'traditional' }
282- )
283- ) ;
284- const spacesSetup = plugin . setup ( coreSetup , { } ) ; // we are not onCloud but forceSolutionVisibility is true
285- const spacesStart = plugin . start ( coreStart ) ;
286-
287- expect ( spacesSetup . isSolutionViewEnabled ) . toBe ( true ) ;
288- expect ( spacesStart . isSolutionViewEnabled ) . toBe ( true ) ;
289- }
290- } ) ;
291-
292- it ( 'when onCloud, not serverless and allowSolutionVisibility is "false"' , ( ) => {
293- const coreSetup = coreMock . createSetup ( ) ;
294- const coreStart = coreMock . createStart ( ) ;
295- const cloud = cloudMock . createSetup ( ) ;
296- cloud . isCloudEnabled = true ;
297-
298- {
299- const plugin = new SpacesPlugin (
300- coreMock . createPluginInitializerContext (
301- { allowSolutionVisibility : false } ,
302- { buildFlavor : 'traditional' }
303- )
304- ) ;
305- const spacesSetup = plugin . setup ( coreSetup , { cloud } ) ;
306- const spacesStart = plugin . start ( coreStart ) ;
307-
308271 expect ( spacesSetup . isSolutionViewEnabled ) . toBe ( false ) ;
309272 expect ( spacesStart . isSolutionViewEnabled ) . toBe ( false ) ;
310273 }
311-
312- {
313- // unless the forceSolutionVisibility flag is set
314- const plugin = new SpacesPlugin (
315- coreMock . createPluginInitializerContext (
316- { allowSolutionVisibility : false , experimental : { forceSolutionVisibility : true } } ,
317- { buildFlavor : 'traditional' }
318- )
319- ) ;
320- const spacesSetup = plugin . setup ( coreSetup , { cloud } ) ;
321- const spacesStart = plugin . start ( coreStart ) ;
322-
323- expect ( spacesSetup . isSolutionViewEnabled ) . toBe ( true ) ;
324- expect ( spacesStart . isSolutionViewEnabled ) . toBe ( true ) ;
325- }
326274 } ) ;
327275
328- it ( 'when onCloud and serverless ' , ( ) => {
276+ it ( 'when allowSolutionVisibility is "undefined" ' , ( ) => {
329277 const coreSetup = coreMock . createSetup ( ) ;
330- const coreStart = coreMock . createStart ( ) ;
331- const cloud = cloudMock . createSetup ( ) ;
332- cloud . isCloudEnabled = true ;
333-
334- {
335- const plugin = new SpacesPlugin (
336- coreMock . createPluginInitializerContext (
337- { allowSolutionVisibility : true } ,
338- { buildFlavor : 'serverless' }
339- )
340- ) ;
341- const spacesSetup = plugin . setup ( coreSetup , { cloud } ) ;
342- const spacesStart = plugin . start ( coreStart ) ;
343278
344- expect ( spacesSetup . isSolutionViewEnabled ) . toBe ( false ) ;
345- expect ( spacesStart . isSolutionViewEnabled ) . toBe ( false ) ;
346- }
347-
348- {
349- // unless the forceSolutionVisibility flag is set
350- const plugin = new SpacesPlugin (
351- coreMock . createPluginInitializerContext (
352- { allowSolutionVisibility : true , experimental : { forceSolutionVisibility : true } } ,
353- { buildFlavor : 'serverless' }
354- )
355- ) ;
356- const spacesSetup = plugin . setup ( coreSetup , { cloud } ) ;
357- const spacesStart = plugin . start ( coreStart ) ;
358-
359- expect ( spacesSetup . isSolutionViewEnabled ) . toBe ( true ) ;
360- expect ( spacesStart . isSolutionViewEnabled ) . toBe ( true ) ;
361- }
279+ const plugin = new SpacesPlugin (
280+ coreMock . createPluginInitializerContext ( { allowSolutionVisibility : undefined } )
281+ ) ;
282+ expect ( ( ) => plugin . setup ( coreSetup , { } ) ) . toThrowErrorMatchingInlineSnapshot (
283+ `"allowSolutionVisibility has not been set in the Spaces plugin config."`
284+ ) ;
362285 } ) ;
363286 } ) ;
364287} ) ;
0 commit comments