@@ -197,4 +197,56 @@ describe('MessageInput in Thread', () => {
197197 } ) ;
198198 expect ( screen . getByLabelText ( 'Also send in channel' ) ) . toBeInTheDocument ( ) ;
199199 } ) ;
200+
201+ describe ( 'draft' , ( ) => {
202+ it ( 'is queried when drafts are enabled' , async ( ) => {
203+ const { customChannel, customClient, getDraftSpy } = await setup ( ) ;
204+ await act ( ( ) => {
205+ customClient . setMessageComposerSetupFunction ( ( { composer } ) => {
206+ composer . updateConfig ( { drafts : { enabled : true } } ) ;
207+ } ) ;
208+ } ) ;
209+ await renderComponent ( {
210+ customChannel,
211+ customClient,
212+ } ) ;
213+ expect ( getDraftSpy ) . toHaveBeenCalledTimes ( 1 ) ;
214+ } ) ;
215+ it ( 'prevents querying if composition is not empty' , async ( ) => {
216+ const { customChannel, customClient, getDraftSpy } = await setup ( ) ;
217+ await act ( ( ) => {
218+ customClient . setMessageComposerSetupFunction ( ( { composer } ) => {
219+ composer . updateConfig ( { drafts : { enabled : true } } ) ;
220+ composer . textComposer . setText ( 'abc' ) ;
221+ } ) ;
222+ } ) ;
223+ await renderComponent ( {
224+ customChannel,
225+ customClient,
226+ } ) ;
227+ expect ( getDraftSpy ) . not . toHaveBeenCalled ( ) ;
228+ } ) ;
229+ it ( 'prevents querying if not rendered inside a thread' , async ( ) => {
230+ const { customChannel, customClient, getDraftSpy } = await setup ( ) ;
231+ await act ( ( ) => {
232+ customClient . setMessageComposerSetupFunction ( ( { composer } ) => {
233+ composer . updateConfig ( { drafts : { enabled : true } } ) ;
234+ composer . compositionContext = customChannel ;
235+ } ) ;
236+ } ) ;
237+ await renderComponent ( {
238+ customChannel,
239+ customClient,
240+ } ) ;
241+ expect ( getDraftSpy ) . not . toHaveBeenCalled ( ) ;
242+ } ) ;
243+ it ( 'prevents querying if drafts are disabled (default)' , async ( ) => {
244+ const { customChannel, customClient, getDraftSpy } = await setup ( ) ;
245+ await renderComponent ( {
246+ customChannel,
247+ customClient,
248+ } ) ;
249+ expect ( getDraftSpy ) . not . toHaveBeenCalled ( ) ;
250+ } ) ;
251+ } ) ;
200252} ) ;
0 commit comments