@@ -23,13 +23,15 @@ const fullNode: TimeslotNode = {
2323 quantity : 1 ,
2424 status : "ACTIVE" ,
2525 resourcePool : {
26+ id : "rp-1" ,
2627 name : "Ada" ,
2728 category : "guide" ,
2829 capacity : 5 ,
2930 accountUser : { id : "u1" } ,
3031 } ,
3132 } ,
3233 ] ,
34+ resourceAllocations : null ,
3335} ;
3436
3537describe ( "fromTimeslotNode" , ( ) => {
@@ -116,6 +118,74 @@ describe("fromTimeslotNode", () => {
116118 expect ( fromTimeslotNode ( node , "act-1" ) . assignedResources ) . toEqual ( [ ] ) ;
117119 } ) ;
118120
121+ it ( "falls back to resourceAllocations when inherited is null" , ( ) => {
122+ const node = {
123+ ...fullNode ,
124+ inheritedResourceAllocations : null ,
125+ resourceAllocations : [
126+ {
127+ quantity : 2 ,
128+ status : "ACTIVE" ,
129+ resourcePool : {
130+ id : "rp-2" ,
131+ name : "Bob" ,
132+ category : "guide" ,
133+ capacity : 3 ,
134+ accountUser : { id : "u2" } ,
135+ } ,
136+ } ,
137+ ] ,
138+ } as unknown as TimeslotNode ;
139+ const { assignedResources } = fromTimeslotNode ( node , "act-1" ) ;
140+ expect ( assignedResources ) . toEqual ( [
141+ { name : "Bob" , capacity : 3 , category : "guide" , quantity : 2 , accountUserId : "u2" } ,
142+ ] ) ;
143+ } ) ;
144+
145+ it ( "falls back to resourceAllocations when inherited is an empty array" , ( ) => {
146+ const node = {
147+ ...fullNode ,
148+ inheritedResourceAllocations : [ ] ,
149+ resourceAllocations : [
150+ {
151+ quantity : 1 ,
152+ status : "ACTIVE" ,
153+ resourcePool : {
154+ id : "rp-2" ,
155+ name : "Bob" ,
156+ category : "guide" ,
157+ capacity : 3 ,
158+ accountUser : { id : "u2" } ,
159+ } ,
160+ } ,
161+ ] ,
162+ } as unknown as TimeslotNode ;
163+ expect ( fromTimeslotNode ( node , "act-1" ) . assignedResources ) . toHaveLength ( 1 ) ;
164+ expect ( fromTimeslotNode ( node , "act-1" ) . assignedResources [ 0 ] . name ) . toBe ( "Bob" ) ;
165+ } ) ;
166+
167+ it ( "prefers inherited over regular resourceAllocations when both are present" , ( ) => {
168+ const node = {
169+ ...fullNode ,
170+ resourceAllocations : [
171+ {
172+ quantity : 9 ,
173+ status : "ACTIVE" ,
174+ resourcePool : {
175+ id : "rp-2" ,
176+ name : "Bob" ,
177+ category : "guide" ,
178+ capacity : 3 ,
179+ accountUser : { id : "u2" } ,
180+ } ,
181+ } ,
182+ ] ,
183+ } as unknown as TimeslotNode ;
184+ const { assignedResources } = fromTimeslotNode ( node , "act-1" ) ;
185+ expect ( assignedResources ) . toHaveLength ( 1 ) ;
186+ expect ( assignedResources [ 0 ] . name ) . toBe ( "Ada" ) ;
187+ } ) ;
188+
119189 it ( "filters out allocations whose status is not ACTIVE" , ( ) => {
120190 const node = {
121191 ...fullNode ,
0 commit comments