test(sync): pin the account filter of the archived-inbox redirection

A task sent to the caller's archived inbox must land in the caller's
active inbox, never in a more recent inbox of another account.

Refs #145

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
le king fu 2026-10-24 14:01:26 -04:00
commit 7b4331176d

View file

@ -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();