Skip to content

Commit 6ad6774

Browse files
committed
test(plugins): fix the second fault wrapping the first spy (WIP)
Claude-Session: https://claude.ai/code/session_01JQwxbXcxCoeCAw1FyTWwwf Co-authored-by: Claude <noreply@anthropic.com>
1 parent 54624ff commit 6ad6774

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

‎packages/plugins/plugin-sharing/src/business-unit-hierarchy-reads-complete.test.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,11 @@ async function boot(extra: number, opts: { omit?: string[] } = {}): Promise<Rig>
112112
if (/^select .* from [`"]sys_business_unit[`"]/i.test(q.sql) && /parent_business_unit_id/.test(q.sql)
113113
&& (q.bindings ?? []).includes(ROOT)) rootChildReads += 1;
114114
});
115+
// The driver's own `find`, taken once: a second fault wraps it again rather
116+
// than wrapping the first fault's spy.
117+
const d = e.getDriverForObject('sys_business_unit');
118+
const real = d.find.bind(d);
115119
const failUnitReads = (which: UnitRead, times = Number.POSITIVE_INFINITY) => {
116-
const d = e.getDriverForObject('sys_business_unit');
117-
const real = d.find.bind(d);
118120
let left = times;
119121
vi.spyOn(d, 'find').mockImplementation(((obj: string, ...rest: unknown[]) => {
120122
const descent = JSON.stringify(rest).includes('parent_business_unit_id');

0 commit comments

Comments
 (0)