diff --git a/web/src/app/api/sync/route.test.ts b/web/src/app/api/sync/route.test.ts index 014f0c4..e7704b2 100644 --- a/web/src/app/api/sync/route.test.ts +++ b/web/src/app/api/sync/route.test.ts @@ -363,6 +363,20 @@ describe('POST /api/sync: inbox merge', () => { expect(await row('select count(*)::int c from sl_tasks where id=$1', [id])).toEqual({ c: 0 }); }); + it('redirects to the caller\'s active inbox, never to a newer inbox of another account', async () => { + const { A, B, N } = await merged(); + const otherInbox = u(); + expect(await push(A.userId, [inboxOp(otherInbox)])).toEqual(['applied']); + const id = u(); + expect(await push(B.userId, [ + ['task', 'create', id, { title: 'late', listId: B.inbox }], + ['task', 'update', B.sub, { listId: B.inbox }], + ])).toEqual(['applied', 'applied']); + expect(await listOf(id)).toBe(N); + expect(await listOf(B.sub)).toBe(N); + expect(await row('select count(*)::int c from sl_tasks where list_id=$1', [otherInbox])).toEqual({ c: 0 }); + }); + it('(g) creates only one new inbox per request', async () => { const { B } = await seed(); const N1 = u();