@@ -113,6 +113,22 @@ const root1 = {
113
113
childUIDs : [ ] ,
114
114
} ;
115
115
116
+ const groupMarker = {
117
+ type : TopicTypes . groupMarker ,
118
+ title : 'First Child Group Marker' ,
119
+ uid : 22 ,
120
+ parent : root0 . uid ,
121
+ depth : 1 ,
122
+ index : 4 ,
123
+ childUIDs : [ root0Child0 . uid , root0Child1 . uid ] ,
124
+ deprecatedChildrenCount : 0 ,
125
+ } ;
126
+
127
+ const root0WithGroupMarker = {
128
+ ...root0 ,
129
+ childUIDs : [ groupMarker . uid ] . concat ( root0 . childUIDs ) ,
130
+ } ;
131
+
116
132
const children = [
117
133
root0 ,
118
134
root0Child0 ,
@@ -121,6 +137,15 @@ const children = [
121
137
root1 ,
122
138
] ;
123
139
140
+ const childrenWithGroupMarker = [
141
+ root0WithGroupMarker ,
142
+ groupMarker ,
143
+ root0Child0 ,
144
+ root0Child1 ,
145
+ root0Child1GrandChild0 ,
146
+ root1 ,
147
+ ] ;
148
+
124
149
const activePath = [ root0 . path , root0Child0 . path ] ;
125
150
126
151
const defaultProps = {
@@ -550,6 +575,23 @@ describe('NavigatorCard', () => {
550
575
expect ( all . at ( 1 ) . props ( 'item' ) ) . toEqual ( root0Child1 ) ;
551
576
expect ( all . at ( 2 ) . props ( 'item' ) ) . toEqual ( root0Child1GrandChild0 ) ;
552
577
} ) ;
578
+
579
+ it ( 'keeps groupMarkers in mind, when `@toggle-full` is handled' , async ( ) => {
580
+ const wrapper = createWrapper ( {
581
+ propsData : {
582
+ // make sure no items are open
583
+ activePath : [ ] ,
584
+ children : childrenWithGroupMarker ,
585
+ } ,
586
+ } ) ;
587
+ await flushPromises ( ) ;
588
+ wrapper . find ( NavigatorCardItem ) . vm . $emit ( 'toggle-full' , root0 ) ;
589
+ await flushPromises ( ) ;
590
+ expect ( wrapper . findAll ( NavigatorCardItem ) ) . toHaveLength ( 6 ) ;
591
+ wrapper . find ( NavigatorCardItem ) . vm . $emit ( 'toggle-full' , root0 ) ;
592
+ await flushPromises ( ) ;
593
+ expect ( wrapper . findAll ( NavigatorCardItem ) ) . toHaveLength ( 2 ) ;
594
+ } ) ;
553
595
} ) ;
554
596
555
597
describe ( 'toggles all siblings on @toggle-siblings' , ( ) => {
@@ -818,6 +860,56 @@ describe('NavigatorCard', () => {
818
860
expect ( allItems . at ( 3 ) . props ( 'item' ) ) . toEqual ( root1WithChildren ) ;
819
861
expect ( allItems . at ( 4 ) . props ( 'item' ) ) . toEqual ( root1Child0 ) ;
820
862
} ) ;
863
+
864
+ it ( 'toggles siblings properly, even when there are groupMarkers' , async ( ) => {
865
+ const wrapper = createWrapper ( {
866
+ propsData : {
867
+ children : [
868
+ root0WithGroupMarker ,
869
+ groupMarker ,
870
+ root0Child0WithChildren ,
871
+ root0Child0WithChildrenGrandChild0 ,
872
+ root0Child1 ,
873
+ root0Child1GrandChild0 ,
874
+ root1WithChildren ,
875
+ root1Child0 ,
876
+ ] ,
877
+ activePath : [ root0WithGroupMarker . path ] ,
878
+ } ,
879
+ } ) ;
880
+ await flushPromises ( ) ;
881
+ // assert we have 3 items rendered
882
+ expect ( wrapper . findAll ( NavigatorCardItem ) ) . toHaveLength ( 5 ) ;
883
+ // open the item and it's siblings
884
+ wrapper . find ( NavigatorCardItem ) . vm . $emit ( 'toggle-siblings' , root0Child1 ) ;
885
+ await flushPromises ( ) ;
886
+ // assert we have one extra item visible
887
+ let allItems = wrapper . findAll ( NavigatorCardItem ) ;
888
+ // assert all items are as we expect them to be
889
+ expect ( allItems ) . toHaveLength ( 7 ) ;
890
+ expect ( allItems . at ( 0 ) . props ( 'item' ) ) . toEqual ( root0WithGroupMarker ) ;
891
+ expect ( allItems . at ( 1 ) . props ( 'item' ) ) . toEqual ( groupMarker ) ;
892
+ expect ( allItems . at ( 2 ) . props ( 'item' ) ) . toEqual ( root0Child0WithChildren ) ;
893
+ expect ( allItems . at ( 3 ) . props ( 'item' ) ) . toEqual ( root0Child0WithChildrenGrandChild0 ) ;
894
+ expect ( allItems . at ( 4 ) . props ( 'item' ) ) . toEqual ( root0Child1 ) ;
895
+ expect ( allItems . at ( 5 ) . props ( 'item' ) ) . toEqual ( root0Child1GrandChild0 ) ;
896
+ expect ( allItems . at ( 6 ) . props ( 'item' ) ) . toEqual ( root1WithChildren ) ;
897
+
898
+ // toggle the items
899
+ allItems . at ( 0 ) . vm . $emit ( 'toggle-siblings' , root0Child1 ) ;
900
+ await flushPromises ( ) ;
901
+ allItems = wrapper . findAll ( NavigatorCardItem ) ;
902
+ expect ( allItems ) . toHaveLength ( 5 ) ;
903
+ expect ( allItems . at ( 0 ) . props ( ) ) . toMatchObject ( {
904
+ item : root0WithGroupMarker ,
905
+ expanded : true ,
906
+ } ) ;
907
+ expect ( allItems . at ( 1 ) . props ( 'item' ) ) . toEqual ( groupMarker ) ;
908
+ expect ( allItems . at ( 2 ) . props ( ) )
909
+ . toMatchObject ( { item : root0Child0WithChildren , expanded : false } ) ;
910
+ expect ( allItems . at ( 3 ) . props ( ) ) . toMatchObject ( { item : root0Child1 , expanded : false } ) ;
911
+ expect ( allItems . at ( 4 ) . props ( ) ) . toMatchObject ( { item : root1WithChildren , expanded : false } ) ;
912
+ } ) ;
821
913
} ) ;
822
914
823
915
describe ( 'on @focus-parent' , ( ) => {
@@ -1534,22 +1626,6 @@ describe('NavigatorCard', () => {
1534
1626
} ) ;
1535
1627
1536
1628
describe ( 'with groupMarker' , ( ) => {
1537
- const groupMarker = {
1538
- type : TopicTypes . groupMarker ,
1539
- title : 'First Child Group Marker' ,
1540
- uid : 22 ,
1541
- parent : root0 . uid ,
1542
- depth : 1 ,
1543
- index : 4 ,
1544
- childUIDs : [ root0Child0 . uid , root0Child1 . uid ] ,
1545
- deprecatedChildrenCount : 0 ,
1546
- } ;
1547
-
1548
- const root0Updated = {
1549
- ...root0 ,
1550
- childUIDs : [ groupMarker . uid ] . concat ( root0 . childUIDs ) ,
1551
- } ;
1552
-
1553
1629
it ( 'shows "Hide Deprecated" tag, if there are deprecated items' , async ( ) => {
1554
1630
const updatedChild = {
1555
1631
...root0Child0 ,
@@ -1559,7 +1635,8 @@ describe('NavigatorCard', () => {
1559
1635
const wrapper = createWrapper ( {
1560
1636
propsData : {
1561
1637
children : [
1562
- root0Updated , groupMarker , updatedChild , root0Child1 , root0Child1GrandChild0 , root1 ,
1638
+ root0WithGroupMarker , groupMarker , updatedChild , root0Child1 , root0Child1GrandChild0 ,
1639
+ root1 ,
1563
1640
] ,
1564
1641
activePath : [ root0 . path ] ,
1565
1642
} ,
@@ -1577,7 +1654,7 @@ describe('NavigatorCard', () => {
1577
1654
// assert the deprecated item is filtered out
1578
1655
expect ( allItems ) . toHaveLength ( 4 ) ;
1579
1656
// assert root is rendered
1580
- expect ( allItems . at ( 0 ) . props ( 'item' ) ) . toEqual ( root0Updated ) ;
1657
+ expect ( allItems . at ( 0 ) . props ( 'item' ) ) . toEqual ( root0WithGroupMarker ) ;
1581
1658
// assert the group marker is rendered
1582
1659
expect ( allItems . at ( 1 ) . props ( 'item' ) ) . toEqual ( groupMarker ) ;
1583
1660
// assert the none-deprecated child is rendered, but its not expanded
@@ -1592,7 +1669,7 @@ describe('NavigatorCard', () => {
1592
1669
allItems = wrapper . findAll ( NavigatorCardItem ) ;
1593
1670
// assert that filtering opens everything as usual, showing groupMarkers as well
1594
1671
expect ( allItems ) . toHaveLength ( 4 ) ;
1595
- expect ( allItems . at ( 0 ) . props ( 'item' ) ) . toEqual ( root0Updated ) ;
1672
+ expect ( allItems . at ( 0 ) . props ( 'item' ) ) . toEqual ( root0WithGroupMarker ) ;
1596
1673
expect ( allItems . at ( 1 ) . props ( 'item' ) ) . toEqual ( groupMarker ) ;
1597
1674
expect ( allItems . at ( 2 ) . props ( 'item' ) ) . toEqual ( root0Child1 ) ;
1598
1675
expect ( allItems . at ( 3 ) . props ( 'item' ) ) . toEqual ( root0Child1GrandChild0 ) ;
@@ -1602,7 +1679,8 @@ describe('NavigatorCard', () => {
1602
1679
const wrapper = createWrapper ( {
1603
1680
propsData : {
1604
1681
children : [
1605
- root0Updated , groupMarker , root0Child0 , root0Child1 , root0Child1GrandChild0 , root1 ,
1682
+ root0WithGroupMarker , groupMarker , root0Child0 , root0Child1 , root0Child1GrandChild0 ,
1683
+ root1 ,
1606
1684
] ,
1607
1685
activePath : [ root0 . path ] ,
1608
1686
} ,
@@ -1614,7 +1692,7 @@ describe('NavigatorCard', () => {
1614
1692
let items = wrapper . findAll ( NavigatorCardItem ) ;
1615
1693
// parent + group and 2 siblings
1616
1694
expect ( items ) . toHaveLength ( 4 ) ;
1617
- expect ( items . at ( 0 ) . props ( 'item' ) ) . toEqual ( root0Updated ) ;
1695
+ expect ( items . at ( 0 ) . props ( 'item' ) ) . toEqual ( root0WithGroupMarker ) ;
1618
1696
expect ( items . at ( 1 ) . props ( 'item' ) ) . toEqual ( groupMarker ) ;
1619
1697
expect ( items . at ( 2 ) . props ( 'item' ) ) . toEqual ( root0Child0 ) ;
1620
1698
expect ( items . at ( 3 ) . props ( 'item' ) ) . toEqual ( root0Child1 ) ;
@@ -1629,7 +1707,7 @@ describe('NavigatorCard', () => {
1629
1707
await flushPromises ( ) ;
1630
1708
items = wrapper . findAll ( NavigatorCardItem ) ;
1631
1709
expect ( items ) . toHaveLength ( 5 ) ;
1632
- expect ( items . at ( 0 ) . props ( 'item' ) ) . toEqual ( root0Updated ) ;
1710
+ expect ( items . at ( 0 ) . props ( 'item' ) ) . toEqual ( root0WithGroupMarker ) ;
1633
1711
expect ( items . at ( 1 ) . props ( 'item' ) ) . toEqual ( groupMarker ) ;
1634
1712
expect ( items . at ( 2 ) . props ( 'item' ) ) . toEqual ( root0Child0 ) ;
1635
1713
expect ( items . at ( 3 ) . props ( 'item' ) ) . toEqual ( root0Child1 ) ;
@@ -1642,7 +1720,7 @@ describe('NavigatorCard', () => {
1642
1720
const wrapper = createWrapper ( {
1643
1721
propsData : {
1644
1722
children : [
1645
- root0Updated , groupMarker , root0Child0Clone ,
1723
+ root0WithGroupMarker , groupMarker , root0Child0Clone ,
1646
1724
root0Child1Clone , root0Child1GrandChild0 , root1 ,
1647
1725
] ,
1648
1726
activePath : [ root0 . path ] ,
@@ -1656,7 +1734,7 @@ describe('NavigatorCard', () => {
1656
1734
const items = wrapper . findAll ( NavigatorCardItem ) ;
1657
1735
// parent + group and 1 item
1658
1736
expect ( items ) . toHaveLength ( 3 ) ;
1659
- expect ( items . at ( 0 ) . props ( 'item' ) ) . toEqual ( root0Updated ) ;
1737
+ expect ( items . at ( 0 ) . props ( 'item' ) ) . toEqual ( root0WithGroupMarker ) ;
1660
1738
expect ( items . at ( 1 ) . props ( 'item' ) ) . toEqual ( groupMarker ) ;
1661
1739
expect ( items . at ( 2 ) . props ( 'item' ) ) . toEqual ( root0Child1Clone ) ;
1662
1740
} ) ;
@@ -1674,7 +1752,7 @@ describe('NavigatorCard', () => {
1674
1752
childUIDs : [ ] ,
1675
1753
} ;
1676
1754
const groupMarkerClone = { ...groupMarker , deprecatedChildrenCount : 2 } ;
1677
- const root0Clone = { ...root0Updated , deprecated : true } ;
1755
+ const root0Clone = { ...root0WithGroupMarker , deprecated : true } ;
1678
1756
const wrapper = createWrapper ( {
1679
1757
propsData : {
1680
1758
children : [
@@ -1713,15 +1791,6 @@ describe('NavigatorCard', () => {
1713
1791
...root0Child0 ,
1714
1792
deprecated : true ,
1715
1793
} ;
1716
- const groupMarker = {
1717
- type : TopicTypes . groupMarker ,
1718
- title : 'First Child Group Marker' ,
1719
- uid : 22 ,
1720
- parent : root0 . uid ,
1721
- depth : 1 ,
1722
- index : 4 ,
1723
- childUIDs : [ ] ,
1724
- } ;
1725
1794
const root0Updated = {
1726
1795
...root0 ,
1727
1796
childUIDs : root0 . childUIDs . concat ( groupMarker . uid ) ,
0 commit comments