@@ -83,7 +83,7 @@ async function readGmailThreads(input: { accessToken: string; signal: AbortSigna
8383 const { threads } = await readGmailThreadsPage ( {
8484 ...input ,
8585 credentialId : `credential-${ credentialCount } ` ,
86- accountId : 'account ' ,
86+ providerSubjectId : 'google-sub ' ,
8787 count : HOME_EMAIL_THREAD_LIMIT ,
8888 } )
8989 return threads
@@ -296,7 +296,13 @@ describe('sharing a Gmail read across accounts', () => {
296296 : respond ( gmailThread ( 't' , [ metadataMessage ( 'Ada' , 'S' , 'P' ) ] ) )
297297 )
298298 const read = ( accessToken : string , credentialId : string ) =>
299- readGmailThreadsPage ( { accessToken, signal, credentialId, accountId : 'account' , count : 1 } )
299+ readGmailThreadsPage ( {
300+ accessToken,
301+ signal,
302+ credentialId,
303+ providerSubjectId : 'google-sub' ,
304+ count : 1 ,
305+ } )
300306 await read ( 'token-a' , 'mailbox-cached' )
301307 const rotated = await read ( 'token-b' , 'mailbox-cached' )
302308 expect ( mailboxEmail ) . toHaveBeenCalledTimes ( 1 )
@@ -305,23 +311,23 @@ describe('sharing a Gmail read across accounts', () => {
305311 expect ( mailboxEmail ) . toHaveBeenCalledTimes ( 2 )
306312 } )
307313
308- it ( 'reads the mailbox again when a reconnect moves the credential to another account ' , async ( ) => {
314+ it ( 'reads the mailbox again when a reconnect binds a credential that had no subject ' , async ( ) => {
309315 providerFetch . mockImplementation ( async ( url : string ) =>
310316 url . includes ( '/threads?' )
311317 ? respond ( { threads : [ { id : 't' } ] } )
312318 : respond ( gmailThread ( 't' , [ metadataMessage ( 'Ada' , 'S' , 'P' ) ] ) )
313319 )
314- const read = ( accountId : string ) =>
320+ const read = ( providerSubjectId : string | null ) =>
315321 readGmailThreadsPage ( {
316322 accessToken : 'token' ,
317323 signal,
318324 credentialId : 'mailbox-reconnected' ,
319- accountId ,
325+ providerSubjectId ,
320326 count : 1 ,
321327 } )
322- await read ( 'account-old' )
328+ await read ( null )
323329 mailboxEmail . mockResolvedValue ( 'new@example.com' )
324- const reconnected = await read ( 'account -new' )
330+ const reconnected = await read ( 'google-sub -new' )
325331 expect ( reconnected . threads [ 0 ] . url ) . toBe ( gmailThreadUrl ( 't' , 'new@example.com' ) )
326332 } )
327333
@@ -338,7 +344,7 @@ describe('sharing a Gmail read across accounts', () => {
338344 accessToken : 'token' ,
339345 signal,
340346 credentialId : 'mailbox-parallel' ,
341- accountId : 'account ' ,
347+ providerSubjectId : 'google-sub ' ,
342348 count : 1 ,
343349 } )
344350 await vi . waitFor ( ( ) => expect ( mailboxEmail ) . toHaveBeenCalledOnce ( ) )
@@ -358,7 +364,7 @@ describe('sharing a Gmail read across accounts', () => {
358364 accessToken : 't' ,
359365 signal,
360366 credentialId : 'mailbox-failed' ,
361- accountId : 'account ' ,
367+ providerSubjectId : 'google-sub ' ,
362368 count : 1 ,
363369 } )
364370 await expect ( read ( ) ) . rejects . toMatchObject ( { failure : 'unavailable' } )
0 commit comments