@@ -280,6 +280,161 @@ describe('subscriptions page', () => {
280280 expect ( pageWithLoadingOrg . find ( 'PermissionDenied' ) ) . toHaveLength ( 0 ) ;
281281 } ) ;
282282
283+ it ( 'should render loading state when subscriptions are loading' , ( ) => {
284+ const loadingSubscriptionsState = {
285+ ...successState ,
286+ loading : true ,
287+ results : [ ] ,
288+ } ;
289+
290+ const loadingPage = mount ( < SubscriptionsPage
291+ setModalOpen = { noop }
292+ setModalClosed = { noop }
293+ organization = { organization }
294+ subscriptions = { loadingSubscriptionsState }
295+ subscriptionTableSettings = { settingsSuccessState }
296+ loadTables = { loadTables }
297+ loadTableColumns = { mockLoadTableColumns }
298+ createColumns = { createColumns }
299+ updateColumns = { updateColumns }
300+ loadSubscriptions = { mockLoadSubscriptions }
301+ loadAvailableQuantities = { loadAvailableQuantities }
302+ pingUpstreamSubscriptions = { pingUpstreamSubscriptions }
303+ checkSimpleContentAccessEligible = { checkSimpleContentAccessEligible }
304+ updateQuantity = { updateQuantity }
305+ handleStartTask = { handleStartTask }
306+ handleFinishedTask = { handleFinishedTask }
307+ pollTaskUntilDone = { noop }
308+ pollBulkSearch = { noop }
309+ pollTasks = { pollTasks }
310+ cancelPollTasks = { noop }
311+ deleteSubscriptions = { ( ) => { } }
312+ resetTasks = { noop }
313+ uploadManifest = { noop }
314+ deleteManifest = { noop }
315+ refreshManifest = { noop }
316+ updateSearchQuery = { noop }
317+ openManageManifestModal = { noop }
318+ closeManageManifestModal = { noop }
319+ openDeleteModal = { noop }
320+ closeDeleteModal = { noop }
321+ disableDeleteButton = { noop }
322+ enableDeleteButton = { noop }
323+ /> ) ;
324+
325+ expect ( loadingPage . find ( 'SubscriptionsTable' ) ) . toHaveLength ( 1 ) ;
326+ loadingPage . unmount ( ) ;
327+ } ) ;
328+
329+ it ( 'should render empty state when manifest is imported but no subscriptions' , ( ) => {
330+ const emptySubscriptionsState = {
331+ ...successState ,
332+ loading : false ,
333+ results : [ ] ,
334+ } ;
335+
336+ const emptyPage = mount ( < SubscriptionsPage
337+ setModalOpen = { noop }
338+ setModalClosed = { noop }
339+ organization = { organization }
340+ subscriptions = { emptySubscriptionsState }
341+ subscriptionTableSettings = { settingsSuccessState }
342+ loadTables = { loadTables }
343+ loadTableColumns = { mockLoadTableColumns }
344+ createColumns = { createColumns }
345+ updateColumns = { updateColumns }
346+ loadSubscriptions = { mockLoadSubscriptions }
347+ loadAvailableQuantities = { loadAvailableQuantities }
348+ pingUpstreamSubscriptions = { pingUpstreamSubscriptions }
349+ checkSimpleContentAccessEligible = { checkSimpleContentAccessEligible }
350+ updateQuantity = { updateQuantity }
351+ handleStartTask = { handleStartTask }
352+ handleFinishedTask = { handleFinishedTask }
353+ pollTaskUntilDone = { noop }
354+ pollBulkSearch = { noop }
355+ pollTasks = { pollTasks }
356+ cancelPollTasks = { noop }
357+ deleteSubscriptions = { ( ) => { } }
358+ resetTasks = { noop }
359+ uploadManifest = { noop }
360+ deleteManifest = { noop }
361+ refreshManifest = { noop }
362+ updateSearchQuery = { noop }
363+ openManageManifestModal = { noop }
364+ closeManageManifestModal = { noop }
365+ openDeleteModal = { noop }
366+ closeDeleteModal = { noop }
367+ disableDeleteButton = { noop }
368+ enableDeleteButton = { noop }
369+ isManifestImported
370+ /> ) ;
371+
372+ // SubscriptionsTable should receive empty state props
373+ const subscriptionsTable = emptyPage . find ( 'SubscriptionsTable' ) ;
374+ expect ( subscriptionsTable ) . toHaveLength ( 1 ) ;
375+ expect ( subscriptionsTable . prop ( 'emptyState' ) ) . toMatchObject ( {
376+ header : 'There are no Subscriptions to display' ,
377+ description : 'Add subscriptions using the Add Subscriptions button.' ,
378+ } ) ;
379+ emptyPage . unmount ( ) ;
380+ } ) ;
381+
382+ it ( 'should render empty state prompting manifest import when no manifest' , ( ) => {
383+ const emptySubscriptionsState = {
384+ ...successState ,
385+ loading : false ,
386+ results : [ ] ,
387+ } ;
388+
389+ const emptyPage = mount ( < SubscriptionsPage
390+ setModalOpen = { noop }
391+ setModalClosed = { noop }
392+ organization = { organization }
393+ subscriptions = { emptySubscriptionsState }
394+ subscriptionTableSettings = { settingsSuccessState }
395+ loadTables = { loadTables }
396+ loadTableColumns = { mockLoadTableColumns }
397+ createColumns = { createColumns }
398+ updateColumns = { updateColumns }
399+ loadSubscriptions = { mockLoadSubscriptions }
400+ loadAvailableQuantities = { loadAvailableQuantities }
401+ pingUpstreamSubscriptions = { pingUpstreamSubscriptions }
402+ checkSimpleContentAccessEligible = { checkSimpleContentAccessEligible }
403+ updateQuantity = { updateQuantity }
404+ handleStartTask = { handleStartTask }
405+ handleFinishedTask = { handleFinishedTask }
406+ pollTaskUntilDone = { noop }
407+ pollBulkSearch = { noop }
408+ pollTasks = { pollTasks }
409+ cancelPollTasks = { noop }
410+ deleteSubscriptions = { ( ) => { } }
411+ resetTasks = { noop }
412+ uploadManifest = { noop }
413+ deleteManifest = { noop }
414+ refreshManifest = { noop }
415+ updateSearchQuery = { noop }
416+ openManageManifestModal = { noop }
417+ closeManageManifestModal = { noop }
418+ openDeleteModal = { noop }
419+ closeDeleteModal = { noop }
420+ disableDeleteButton = { noop }
421+ enableDeleteButton = { noop }
422+ isManifestImported = { false }
423+ /> ) ;
424+
425+ // SubscriptionsTable should receive empty state with manifest import prompt
426+ const subscriptionsTable = emptyPage . find ( 'SubscriptionsTable' ) ;
427+ expect ( subscriptionsTable ) . toHaveLength ( 1 ) ;
428+ expect ( subscriptionsTable . prop ( 'emptyState' ) ) . toMatchObject ( {
429+ header : 'There are no Subscriptions to display' ,
430+ description : 'Import a subscription manifest to give hosts access to Red Hat content.' ,
431+ action : expect . objectContaining ( {
432+ title : 'Import a Manifest' ,
433+ } ) ,
434+ } ) ;
435+ emptyPage . unmount ( ) ;
436+ } ) ;
437+
283438 it ( 'should poll tasks when org changes' , async ( ) => {
284439 await act ( async ( ) => {
285440 page . setProps ( { organization : { id : 1 } } ) ;
0 commit comments