@@ -774,7 +774,7 @@ describe('App', () => {
774774
775775 for ( const segment of entireColumn ) {
776776 fireEvent . contextMenu ( segment , { bubbles : true } )
777- jest . advanceTimersByTime ( 100 )
777+ advanceTimersByTime ( 100 )
778778 const menuitems = screen
779779 . getAllByRole ( 'menuitem' )
780780 . filter ( item => ! item . className . includes ( 'disabled' ) )
@@ -801,7 +801,7 @@ describe('App', () => {
801801
802802 for ( const segment of entireColumn ) {
803803 fireEvent . contextMenu ( segment , { bubbles : true } )
804- jest . advanceTimersByTime ( 100 )
804+ advanceTimersByTime ( 100 )
805805 const menuitems = screen
806806 . getAllByRole ( 'menuitem' )
807807 . filter ( item => ! item . className . includes ( 'disabled' ) )
@@ -821,7 +821,7 @@ describe('App', () => {
821821 )
822822 const placeholder = placeholders [ 0 ]
823823 fireEvent . contextMenu ( placeholder , { bubbles : true } )
824- jest . advanceTimersByTime ( 100 )
824+ advanceTimersByTime ( 100 )
825825
826826 const hideOption = screen . getByText ( 'Hide Column' )
827827
@@ -1486,19 +1486,18 @@ describe('App', () => {
14861486 renderTable ( {
14871487 ...tableDataFixture
14881488 } )
1489+ jest . useFakeTimers ( )
14891490 const selectedForPlotsIndicator =
14901491 screen . getByLabelText ( 'selected for plots' )
14911492 expect ( selectedForPlotsIndicator ) . toHaveTextContent ( '2' )
14921493
14931494 expect ( screen . queryByRole ( 'tooltip' ) ) . not . toBeInTheDocument ( )
14941495
14951496 fireEvent . mouseEnter ( selectedForPlotsIndicator )
1496-
1497+ advanceTimersByTime ( 1000 )
14971498 const tooltip = screen . getByRole ( 'tooltip' )
14981499
1499- expect ( tooltip ) . toHaveTextContent (
1500- '2 Experiments Selected for Plotting (Max 7)'
1501- )
1500+ expect ( tooltip ) . toHaveTextContent ( 'Show Plots' )
15021501
15031502 setTableData ( {
15041503 ...tableDataFixture ,
@@ -1510,9 +1509,6 @@ describe('App', () => {
15101509 } )
15111510
15121511 expect ( selectedForPlotsIndicator ) . toHaveTextContent ( '' )
1513- expect ( tooltip ) . toHaveTextContent (
1514- 'No Experiments Selected for Plotting (Max 7)'
1515- )
15161512
15171513 setTableData ( {
15181514 ...tableDataFixture ,
@@ -1533,12 +1529,10 @@ describe('App', () => {
15331529 } )
15341530
15351531 expect ( selectedForPlotsIndicator ) . toHaveTextContent ( '1' )
1536- expect ( tooltip ) . toHaveTextContent (
1537- '1 Experiment Selected for Plotting (Max 7)'
1538- )
1532+ jest . useRealTimers ( )
15391533 } )
15401534
1541- it ( 'should show not change the plotted indicator when plotted experiments are hidden' , ( ) => {
1535+ it ( 'should not change the plotted indicator when plotted experiments are hidden' , ( ) => {
15421536 const plottedExperiment = '4fb124a'
15431537
15441538 renderTable ( {
@@ -1547,49 +1541,30 @@ describe('App', () => {
15471541
15481542 expect ( screen . getByText ( plottedExperiment ) ) . toBeInTheDocument ( )
15491543
1550- const selectedForPlotsIndicator =
1551- screen . getByLabelText ( 'selected for plots' )
1552- expect ( selectedForPlotsIndicator ) . toHaveTextContent ( '2' )
1553-
1554- expect ( screen . queryByRole ( 'tooltip' ) ) . not . toBeInTheDocument ( )
1555-
1556- fireEvent . mouseEnter ( selectedForPlotsIndicator )
1557-
1558- const expandedTooltip = screen . getByRole ( 'tooltip' )
1559-
1560- expect ( expandedTooltip ) . toHaveTextContent (
1561- '2 Experiments Selected for Plotting (Max 7)'
1562- )
1563-
1564- fireEvent . mouseLeave ( selectedForPlotsIndicator )
1544+ expect ( screen . getByLabelText ( 'selected for plots' ) ) . toHaveTextContent ( '2' )
15651545
15661546 contractRow ( 'main' )
15671547
1568- expect ( screen . queryByText ( plottedExperiment ) ) . not . toBeInTheDocument ( )
1569- fireEvent . mouseEnter ( selectedForPlotsIndicator )
1570-
1571- const contractedTooltip = screen . getByRole ( 'tooltip' )
1572-
1573- expect ( contractedTooltip ) . toHaveTextContent (
1574- '2 Experiments Selected for Plotting (Max 7)'
1575- )
1548+ expect ( screen . getByLabelText ( 'selected for plots' ) ) . toHaveTextContent ( '2' )
15761549 } )
15771550
15781551 it ( 'should show an indicator with the amount of applied sorts' , ( ) => {
15791552 renderTable ( {
15801553 ...tableDataFixture ,
15811554 sorts : [ ]
15821555 } )
1556+ jest . useFakeTimers ( )
15831557 const sortIndicator = screen . getByLabelText ( 'sorts' )
15841558 expect ( sortIndicator ) . toHaveTextContent ( '' )
15851559
15861560 expect ( screen . queryByRole ( 'tooltip' ) ) . not . toBeInTheDocument ( )
15871561
15881562 fireEvent . mouseEnter ( sortIndicator )
1563+ advanceTimersByTime ( 1000 )
15891564
15901565 const tooltip = screen . getByRole ( 'tooltip' )
15911566
1592- expect ( tooltip ) . toHaveTextContent ( 'No Sorts Applied ' )
1567+ expect ( tooltip ) . toHaveTextContent ( 'Show Sorts' )
15931568
15941569 const { columns } = tableDataFixture
15951570 const firstSortPath = columns [ columns . length - 1 ] . path
@@ -1599,7 +1574,6 @@ describe('App', () => {
15991574 sorts : [ { descending : true , path : firstSortPath } ]
16001575 } )
16011576 expect ( sortIndicator ) . toHaveTextContent ( '1' )
1602- expect ( tooltip ) . toHaveTextContent ( '1 Sort Applied' )
16031577 setTableData ( {
16041578 ...tableDataFixture ,
16051579 sorts : [
@@ -1608,7 +1582,7 @@ describe('App', () => {
16081582 ]
16091583 } )
16101584 expect ( sortIndicator ) . toHaveTextContent ( '2' )
1611- expect ( tooltip ) . toHaveTextContent ( '2 Sorts Applied' )
1585+ jest . useRealTimers ( )
16121586 } )
16131587 } )
16141588
@@ -1617,16 +1591,18 @@ describe('App', () => {
16171591 ...tableDataFixture ,
16181592 filters : [ ]
16191593 } )
1594+ jest . useFakeTimers ( )
16201595 const filterIndicator = screen . getByLabelText ( 'filters' )
16211596 expect ( filterIndicator ) . toHaveTextContent ( '' )
16221597
16231598 expect ( screen . queryByRole ( 'tooltip' ) ) . not . toBeInTheDocument ( )
16241599
16251600 fireEvent . mouseEnter ( filterIndicator )
1601+ advanceTimersByTime ( 1000 )
16261602
16271603 const tooltip = screen . getByRole ( 'tooltip' )
16281604
1629- expect ( tooltip ) . toHaveTextContent ( 'No Filters Applied ' )
1605+ expect ( tooltip ) . toHaveTextContent ( 'Show Filters' )
16301606
16311607 const { columns } = tableDataFixture
16321608 const firstFilterPath = columns [ columns . length - 1 ] . path
@@ -1636,33 +1612,89 @@ describe('App', () => {
16361612 filters : [ firstFilterPath ]
16371613 } )
16381614 expect ( filterIndicator ) . toHaveTextContent ( '1' )
1639- expect ( tooltip ) . toHaveTextContent ( '1 Filter Applied' )
1640- expect ( tooltip ) . toHaveTextContent ( 'No Experiments Filtered' )
16411615
16421616 setTableData ( {
16431617 ...tableDataFixture ,
1644- filteredCount : 1 ,
16451618 filters : [ firstFilterPath , secondFilterPath ]
16461619 } )
16471620 expect ( filterIndicator ) . toHaveTextContent ( '2' )
1648- expect ( tooltip ) . toHaveTextContent ( '2 Filters Applied' )
1649- expect ( tooltip ) . toHaveTextContent ( '1 Experiment Filtered' )
16501621
16511622 setTableData ( {
16521623 ...tableDataFixture ,
1653- filteredCount : 10000 ,
16541624 filters : [ firstFilterPath , secondFilterPath ]
16551625 } )
16561626 expect ( filterIndicator ) . toHaveTextContent ( '2' )
1657- expect ( tooltip ) . toHaveTextContent ( '10000 Experiments Filtered' )
16581627
16591628 setTableData ( {
16601629 ...tableDataFixture ,
1661- filteredCount : 10000 ,
16621630 filters : [ ]
16631631 } )
16641632 expect ( filterIndicator ) . toHaveTextContent ( '' )
16651633 expect ( tooltip ) . not . toHaveTextContent ( 'Experiment' )
1634+ jest . useRealTimers ( )
1635+ } )
1636+
1637+ it ( 'should show a tooltip for the branches indicator' , ( ) => {
1638+ renderTable ( {
1639+ ...tableDataFixture
1640+ } )
1641+ jest . useFakeTimers ( )
1642+ const branchesIndicator = screen . getByLabelText ( 'branches' )
1643+ expect ( branchesIndicator ) . toHaveTextContent ( '' )
1644+
1645+ expect ( screen . queryByRole ( 'tooltip' ) ) . not . toBeInTheDocument ( )
1646+
1647+ fireEvent . mouseEnter ( branchesIndicator )
1648+ advanceTimersByTime ( 1000 )
1649+
1650+ const tooltip = screen . getByRole ( 'tooltip' )
1651+
1652+ expect ( tooltip ) . toHaveTextContent ( 'Select Branches' )
1653+ jest . useRealTimers ( )
1654+ } )
1655+
1656+ it ( 'should show an indicator for the number of branches selected' , ( ) => {
1657+ const branches = [ 'main' , 'other' , 'third' ]
1658+
1659+ let workspace
1660+ const rowsWithoutWorkspace = [ ]
1661+ for ( const row of tableDataFixture . rows ) {
1662+ if ( row . id !== EXPERIMENT_WORKSPACE_ID ) {
1663+ rowsWithoutWorkspace . push ( row )
1664+ continue
1665+ }
1666+ workspace = row
1667+ }
1668+
1669+ const multipleBranches = {
1670+ ...tableDataFixture ,
1671+ branches,
1672+ hasData : true ,
1673+ rows : [
1674+ workspace as Commit ,
1675+ ...rowsWithoutWorkspace . map ( row => ( {
1676+ ...row ,
1677+ branch : branches [ 0 ] ,
1678+ subRows : undefined
1679+ } ) ) ,
1680+ ...rowsWithoutWorkspace . map ( row => ( {
1681+ ...row ,
1682+ branch : branches [ 1 ] ,
1683+ subRows : undefined
1684+ } ) ) ,
1685+ ...rowsWithoutWorkspace . map ( row => ( {
1686+ ...row ,
1687+ branch : branches [ 2 ] ,
1688+ subRows : undefined
1689+ } ) )
1690+ ]
1691+ }
1692+
1693+ renderTable ( multipleBranches )
1694+
1695+ const [ indicator ] = screen . getAllByLabelText ( 'branches' )
1696+
1697+ expect ( indicator ) . toHaveTextContent ( `${ branches . length - 1 } ` )
16661698 } )
16671699
16681700 it ( 'should send a message to focus the relevant tree when clicked' , ( ) => {
0 commit comments