@@ -560,36 +560,20 @@ describe('CrudToolbar Component', function () {
560560 expect ( onExpandAllClicked ) . to . have . been . calledOnce ;
561561 } ) ;
562562
563- it ( 'should show collapse all documents if all documents were previously expanded' , function ( ) {
564- renderCrudToolbar ( ) ;
563+ it ( 'should call onCollapseAllClicked when "Collapse all documents" is clicked' , function ( ) {
564+ const onCollapseAllClicked = sinon . spy ( ) ;
565+ renderCrudToolbar ( { onCollapseAllClicked } ) ;
565566
566- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
567- const toolbar = screen . getByTestId ( 'query-bar' ) . closest ( 'div' ) ! ;
568- userEvent . click ( toolbar , { button : 2 } ) ;
567+ const toolbar = screen . getByTestId ( 'query-bar' ) . closest ( 'div' ) ;
568+ userEvent . click ( toolbar ! , { button : 2 } ) ;
569569
570570 const contextMenu = screen . getByTestId ( 'context-menu' ) ;
571-
572- // No Collapse all documents should be shown
573- expect ( within ( contextMenu ) . queryByText ( 'Collapse all documents' ) ) . to . not
574- . exist ;
575-
576- // Click expand all documents
577- const expandMenuItem = within ( contextMenu ) . getByText (
578- 'Expand all documents'
579- ) ;
580- userEvent . click ( expandMenuItem ) ;
581-
582- // Right click again to open the context menu
583- userEvent . click ( toolbar , { button : 2 } ) ;
584-
585- // Now it should show collapse all documents
586571 const collapseMenuItem = within ( contextMenu ) . getByText (
587572 'Collapse all documents'
588573 ) ;
589574 userEvent . click ( collapseMenuItem ) ;
590575
591- expect ( within ( contextMenu ) . getByText ( 'Collapse all documents' ) ) . to . be
592- . visible ;
576+ expect ( onCollapseAllClicked ) . to . have . been . called ;
593577 } ) ;
594578
595579 it ( 'should call insertDataHandler with "import-file" when "Import JSON or CSV file" is clicked' , function ( ) {
0 commit comments