@@ -34,6 +34,9 @@ async function makeWrapper({ channel, publishedData, latestSubmission }) {
3434 const isLoading = ref ( true ) ;
3535 const isFinished = ref ( false ) ;
3636
37+ store . state . currentChannel . currentChannelId = channel . id ;
38+ store . commit ( 'channel/ADD_CHANNEL' , channel ) ;
39+
3740 usePublishedData . mockReturnValue ( {
3841 isLoading,
3942 isFinished,
@@ -74,9 +77,9 @@ const publishedNonPublicChannel = {
7477} ;
7578
7679const publicChannel = {
77- id : 'published-non- public-channel' ,
80+ id : 'public-channel' ,
7881 version : 2 ,
79- name : 'Published Non- Public Channel' ,
82+ name : 'Public Channel' ,
8083 published : true ,
8184 public : true ,
8285} ;
@@ -105,6 +108,10 @@ const publishedData = {
105108const submittedLatestSubmission = { channel_version : 2 , status : CommunityLibraryStatus . PENDING } ;
106109
107110describe ( 'SubmitToCommunityLibrarySidePanel' , ( ) => {
111+ beforeEach ( ( ) => {
112+ store . state . currentChannel . currentChannelId = null ;
113+ store . state . channel . channelsMap = { } ;
114+ } ) ;
108115 describe ( 'correct warnings are shown' , ( ) => {
109116 it ( 'when channel is published, not public and not submitted' , async ( ) => {
110117 const wrapper = await makeWrapper ( {
@@ -377,7 +384,7 @@ describe('SubmitToCommunityLibrarySidePanel', () => {
377384 } ) ;
378385
379386 const descriptionTextbox = wrapper . findComponent ( '.description-textbox' ) ;
380- expect ( descriptionTextbox . props ( 'disabled' ) ) . toBe ( false ) ;
387+ expect ( descriptionTextbox . props ( 'disabled' ) ) . toBe ( true ) ;
381388 } ) ;
382389 } ) ;
383390
@@ -466,6 +473,7 @@ describe('SubmitToCommunityLibrarySidePanel', () => {
466473 } ) ;
467474
468475 it ( 'the panel closes' , async ( ) => {
476+ jest . useFakeTimers ( ) ;
469477 const wrapper = await makeWrapper ( {
470478 channel : publishedNonPublicChannel ,
471479 publishedData,
@@ -479,9 +487,11 @@ describe('SubmitToCommunityLibrarySidePanel', () => {
479487 await submitButton . trigger ( 'click' ) ;
480488
481489 expect ( wrapper . emitted ( 'close' ) ) . toBeTruthy ( ) ;
490+ jest . useRealTimers ( ) ;
482491 } ) ;
483492
484493 it ( 'a submission snackbar is shown' , async ( ) => {
494+ jest . useFakeTimers ( ) ;
485495 const wrapper = await makeWrapper ( {
486496 channel : publishedNonPublicChannel ,
487497 publishedData,
@@ -493,14 +503,15 @@ describe('SubmitToCommunityLibrarySidePanel', () => {
493503
494504 const submitButton = wrapper . find ( '[data-test="submit-button"]' ) ;
495505 await submitButton . trigger ( 'click' ) ;
496-
497- jest . useFakeTimers ( ) ;
506+ await wrapper . vm . $nextTick ( ) ;
498507
499508 expect ( store . getters [ 'snackbarIsVisible' ] ) . toBe ( true ) ;
500509 expect ( CommunityLibrarySubmission . create ) . not . toHaveBeenCalled ( ) ;
510+ jest . useRealTimers ( ) ;
501511 } ) ;
502512
503513 it ( 'the submission is created after a timeout' , async ( ) => {
514+ jest . useFakeTimers ( ) ;
504515 const wrapper = await makeWrapper ( {
505516 channel : publishedNonPublicChannel ,
506517 publishedData,
@@ -512,20 +523,22 @@ describe('SubmitToCommunityLibrarySidePanel', () => {
512523
513524 const countryField = wrapper . findComponent ( CountryField ) ;
514525 await countryField . vm . $emit ( 'input' , [ 'Czech Republic' ] ) ;
515-
516- jest . useFakeTimers ( ) ;
526+ await wrapper . vm . $nextTick ( ) ;
517527
518528 const submitButton = wrapper . find ( '[data-test="submit-button"]' ) ;
519529 await submitButton . trigger ( 'click' ) ;
530+ await wrapper . vm . $nextTick ( ) ;
520531
521532 jest . runAllTimers ( ) ;
533+ await wrapper . vm . $nextTick ( ) ;
522534
523535 expect ( CommunityLibrarySubmission . create ) . toHaveBeenCalledWith ( {
524536 description : 'Some description' ,
525537 channel : publishedNonPublicChannel . id ,
526538 countries : [ 'CZ' ] ,
527539 categories : [ Categories . SCHOOL ] ,
528540 } ) ;
541+ jest . useRealTimers ( ) ;
529542 } ) ;
530543 } ) ;
531544
0 commit comments