@@ -10,31 +10,28 @@ describe("sidebar thread groups", () => {
1010 const threads = [
1111 { id : "thread-a" , projectKey : "project-a" } ,
1212 { id : "thread-b" , projectKey : "project-a" } ,
13- { id : "thread-c" , projectKey : "project-a " } ,
13+ { id : "thread-c" , projectKey : "project-b " } ,
1414 ] ;
1515
16- it ( "renders each visible group once at its first member" , ( ) => {
16+ it ( "renders each visible group once at its first member, across projects " , ( ) => {
1717 expect (
1818 buildSidebarThreadGroupLayout ( {
1919 threads,
20- groupsByProject : {
21- "project-a" : [
22- {
23- id : "group-1" ,
24- title : "Related work" ,
25- threadIds : [ "thread-b" , "thread-c" ] ,
26- collapsed : false ,
27- } ,
28- ] ,
29- } ,
20+ groups : [
21+ {
22+ id : "group-1" ,
23+ title : "Related work" ,
24+ threadIds : [ "thread-b" , "thread-c" ] ,
25+ collapsed : false ,
26+ } ,
27+ ] ,
3028 getId : ( thread ) => thread . id ,
31- getProjectKey : ( thread ) => thread . projectKey ,
3229 } ) ,
3330 ) . toEqual ( [
3431 { kind : "thread" , thread : threads [ 0 ] } ,
3532 {
3633 kind : "group" ,
37- projectKey : "project-a" ,
34+ hasParent : false ,
3835 group : {
3936 id : "group-1" ,
4037 title : "Related work" ,
@@ -52,23 +49,20 @@ describe("sidebar thread groups", () => {
5249 expect (
5350 buildSidebarThreadGroupLayout ( {
5451 threads : automaticThreads ,
55- groupsByProject : {
56- "project-a" : [
57- {
58- id : "group-1" ,
59- title : "Related work" ,
60- threadIds : [ "thread-b" , "thread-c" ] ,
61- collapsed : false ,
62- } ,
63- ] ,
64- } ,
52+ groups : [
53+ {
54+ id : "group-1" ,
55+ title : "Related work" ,
56+ threadIds : [ "thread-b" , "thread-c" ] ,
57+ collapsed : false ,
58+ } ,
59+ ] ,
6560 getId : ( thread ) => thread . id ,
66- getProjectKey : ( thread ) => thread . projectKey ,
6761 } ) ,
6862 ) . toEqual ( [
6963 {
7064 kind : "group" ,
71- projectKey : "project-a" ,
65+ hasParent : false ,
7266 group : {
7367 id : "group-1" ,
7468 title : "Related work" ,
@@ -81,6 +75,31 @@ describe("sidebar thread groups", () => {
8175 ] ) ;
8276 } ) ;
8377
78+ it ( "leads a group with its parent wherever the parent sorts" , ( ) => {
79+ const groups = [
80+ {
81+ id : "group-1" ,
82+ title : "Related work" ,
83+ threadIds : [ "thread-a" , "thread-b" , "thread-c" ] ,
84+ collapsed : false ,
85+ parentThreadId : "thread-c" ,
86+ } ,
87+ ] ;
88+ const layout = buildSidebarThreadGroupLayout ( { threads, groups, getId : ( thread ) => thread . id } ) ;
89+ expect ( layout ) . toHaveLength ( 1 ) ;
90+ expect ( layout [ 0 ] ) . toMatchObject ( {
91+ hasParent : true ,
92+ threads : [ threads [ 2 ] , threads [ 0 ] , threads [ 1 ] ] ,
93+ } ) ;
94+ // A filtered-out parent leads nothing, so no row indents as its child.
95+ const filtered = buildSidebarThreadGroupLayout ( {
96+ threads : threads . slice ( 0 , 2 ) ,
97+ groups,
98+ getId : ( thread ) => thread . id ,
99+ } ) ;
100+ expect ( filtered [ 0 ] ) . toMatchObject ( { hasParent : false } ) ;
101+ } ) ;
102+
84103 it ( "offers group creation only for an eligible multi-selection" , ( ) => {
85104 expect ( buildCreateThreadGroupContextMenuItem ( { count : 2 , eligible : true } ) ) . toMatchObject ( {
86105 id : "create-thread-group" ,
@@ -99,6 +118,7 @@ describe("sidebar thread groups", () => {
99118 { id : "group-2" , title : "Destination" } ,
100119 ] ,
101120 currentGroupId : "group-1" ,
121+ isGroupParent : false ,
102122 } ) ,
103123 ) . toEqual ( [
104124 {
@@ -114,6 +134,7 @@ describe("sidebar thread groups", () => {
114134 icon : "folder" ,
115135 separatorBefore : false ,
116136 } ,
137+ { id : "set-group-parent" , label : "Set as group parent" } ,
117138 ] ) ;
118139 } ) ;
119140} ) ;
@@ -140,18 +161,15 @@ describe("buildSidebarListItems", () => {
140161 it ( "emits only a collapsed group's anchor as an active row" , ( ) => {
141162 const layout = buildSidebarThreadGroupLayout ( {
142163 threads : groupThreads ,
143- groupsByProject : {
144- "project-a" : [
145- {
146- id : "group-1" ,
147- title : "Related work" ,
148- threadIds : [ "thread-b" , "thread-c" ] ,
149- collapsed : true ,
150- } ,
151- ] ,
152- } ,
164+ groups : [
165+ {
166+ id : "group-1" ,
167+ title : "Related work" ,
168+ threadIds : [ "thread-b" , "thread-c" ] ,
169+ collapsed : true ,
170+ } ,
171+ ] ,
153172 getId : ( thread ) => thread . id ,
154- getProjectKey : ( thread ) => thread . projectKey ,
155173 } ) ;
156174 const keys = visibleKeys ( layout ) ;
157175 expect ( keys ) . toEqual ( [ "thread-a" , "thread-b" ] ) ;
@@ -180,18 +198,15 @@ describe("buildSidebarListItems", () => {
180198 it ( "keeps an expanded group's rows contiguous in layout order" , ( ) => {
181199 const layout = buildSidebarThreadGroupLayout ( {
182200 threads : groupThreads ,
183- groupsByProject : {
184- "project-a" : [
185- {
186- id : "group-1" ,
187- title : "Related work" ,
188- threadIds : [ "thread-b" , "thread-c" ] ,
189- collapsed : false ,
190- } ,
191- ] ,
192- } ,
201+ groups : [
202+ {
203+ id : "group-1" ,
204+ title : "Related work" ,
205+ threadIds : [ "thread-b" , "thread-c" ] ,
206+ collapsed : false ,
207+ } ,
208+ ] ,
193209 getId : ( thread ) => thread . id ,
194- getProjectKey : ( thread ) => thread . projectKey ,
195210 } ) ;
196211
197212 expect (
0 commit comments