Skip to content

Commit 139abc4

Browse files
committed
test(dogfood): pin that a failed Default Organization lookup never reaches better-auth's first write (#24948)
The recorder now also watches the session's active-organization write, the vendor handler's first, so the pin goes red when the lookup falls through (ablated). Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016gmigttoA9DyRNtz6SepWf
1 parent e40aea8 commit 139abc4

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎packages/qa/dogfood/test/organization-delete-federated-fixture.dogfood.test.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,14 @@ describe('[#21910] an organization delete with the showcase federated fixture pr
250250
const loneId = String(lone.id);
251251
const [admin] = await findRows(ql, 'sys_user', { email: 'admin@objectos.ai' }, 1);
252252
await ql.insert('sys_member', { user_id: String(admin?.id), organization_id: loneId, role: 'owner' }, { context: SYSTEM_CTX });
253+
// Active, so better-auth's handler would write first to the session
254+
// (clearing it) if the request reached it: the write recorded below.
255+
const active = await stack.apiAs(token, 'POST', '/auth/organization/set-active', { organizationId: loneId });
256+
expect(active.status, await active.clone().text()).toBe(200);
253257

254258
const attempted: string[] = [];
255259
const RECORDER = 'dogfood.24948.lookup-fails';
260+
ql.registerHook('beforeUpdate', async () => { attempted.push('sys_session'); }, { object: 'sys_session', packageId: RECORDER });
256261
// `count` runs the middleware chain only (no hook), and a middleware has
257262
// no unregister, so this one is switched by a flag.
258263
lookupFails = true;
@@ -275,6 +280,8 @@ describe('[#21910] an organization delete with the showcase federated fixture pr
275280
}
276281

277282
expect(res.status, await res.clone().text()).toBeGreaterThanOrEqual(400);
283+
// better-auth's handler never ran: not even its first write, the session's
284+
// active organization, was attempted.
278285
expect(attempted).toEqual([]);
279286
expect(await findRows(ql, 'sys_organization', { id: loneId }, 1)).toHaveLength(1);
280287
expect(await findRows(ql, 'sys_member', { organization_id: loneId }, 5)).toHaveLength(1);

0 commit comments

Comments
 (0)