@@ -145,26 +145,26 @@ describe("getOrganizationSessionCap", () => {
145145 async ( { prisma } ) => {
146146 const user = await createUser ( prisma , "multi-org@test.com" ) ;
147147 await createOrgWithMember ( prisma , "loose-org" , user . id , oneDay ) ;
148- await createOrgWithMember ( prisma , "tight-org" , user . id , oneHour ) ;
148+ const tight = await createOrgWithMember ( prisma , "tight-org" , user . id , oneHour ) ;
149149 await createOrgWithMember ( prisma , "uncapped-org" , user . id , null ) ;
150150
151151 const cap = await getOrganizationSessionCap ( user . id , prisma ) ;
152- expect ( cap ) . toBe ( oneHour ) ;
152+ expect ( cap ) . toEqual ( { orgCapSeconds : oneHour , cappingOrgId : tight . id } ) ;
153153 }
154154 ) ;
155155
156156 containerTest ( "ignores soft-deleted organizations" , async ( { prisma } ) => {
157157 const user = await createUser ( prisma , "deleted-org-user@test.com" ) ;
158158 const tight = await createOrgWithMember ( prisma , "deleted-tight" , user . id , oneHour ) ;
159- await createOrgWithMember ( prisma , "active-loose" , user . id , oneDay ) ;
159+ const loose = await createOrgWithMember ( prisma , "active-loose" , user . id , oneDay ) ;
160160
161161 await prisma . organization . update ( {
162162 where : { id : tight . id } ,
163163 data : { deletedAt : new Date ( ) } ,
164164 } ) ;
165165
166166 const cap = await getOrganizationSessionCap ( user . id , prisma ) ;
167- expect ( cap ) . toBe ( oneDay ) ;
167+ expect ( cap ) . toEqual ( { orgCapSeconds : oneDay , cappingOrgId : loose . id } ) ;
168168 } ) ;
169169} ) ;
170170
@@ -178,17 +178,19 @@ describe("getEffectiveSessionDuration", () => {
178178 const result = await getEffectiveSessionDuration ( user . id , prisma ) ;
179179 expect ( result . userSettingSeconds ) . toBe ( oneDay ) ;
180180 expect ( result . orgCapSeconds ) . toBeNull ( ) ;
181+ expect ( result . cappingOrgId ) . toBeNull ( ) ;
181182 expect ( result . durationSeconds ) . toBe ( oneDay ) ;
182183 }
183184 ) ;
184185
185186 containerTest ( "caps the user setting at the most restrictive org cap" , async ( { prisma } ) => {
186187 const user = await createUser ( prisma , "effective-capped@test.com" , oneYear ) ;
187- await createOrgWithMember ( prisma , "effective-capped-org" , user . id , oneHour ) ;
188+ const org = await createOrgWithMember ( prisma , "effective-capped-org" , user . id , oneHour ) ;
188189
189190 const result = await getEffectiveSessionDuration ( user . id , prisma ) ;
190191 expect ( result . userSettingSeconds ) . toBe ( oneYear ) ;
191192 expect ( result . orgCapSeconds ) . toBe ( oneHour ) ;
193+ expect ( result . cappingOrgId ) . toBe ( org . id ) ;
192194 expect ( result . durationSeconds ) . toBe ( oneHour ) ;
193195 } ) ;
194196
@@ -209,6 +211,7 @@ describe("getEffectiveSessionDuration", () => {
209211 const result = await getEffectiveSessionDuration ( "nonexistent-user-id" , prisma ) ;
210212 expect ( result . userSettingSeconds ) . toBe ( DEFAULT_SESSION_DURATION_SECONDS ) ;
211213 expect ( result . orgCapSeconds ) . toBeNull ( ) ;
214+ expect ( result . cappingOrgId ) . toBeNull ( ) ;
212215 expect ( result . durationSeconds ) . toBe ( DEFAULT_SESSION_DURATION_SECONDS ) ;
213216 }
214217 ) ;
0 commit comments