Skip to content

Commit 99997e9

Browse files
committed
test(plugin-sharing): the equivalence double refuses logical operators
Claude-Session: https://claude.ai/code/session_01KqkTQNLcxVc588eZpJmp1r Co-authored-by: Claude <noreply@anthropic.com>
1 parent cf4bd9a commit 99997e9

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

‎packages/plugins/plugin-sharing/src/position-graph.test.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,14 @@ describe('PositionGraphService.holdsPosition — the user-scoped twin of the exp
119119
async find(object: string, options: any) {
120120
const f = options?.filter ?? options?.where ?? {};
121121
const rows: any[] = object === 'sys_user_position' ? ASSIGN : object === 'sys_member' ? MEMBER : [];
122-
return rows.filter((r) => Object.entries(f).every(([k, v]) => r[k] === v)).slice(0, options?.limit ?? rows.length);
122+
const matches = (row: any, where: any): boolean => {
123+
for (const [k, v] of Object.entries(where)) {
124+
if (k.startsWith('$')) throw new Error('test double: unsupported logical operator ' + k);
125+
if (row[k] !== v) return false;
126+
}
127+
return true;
128+
};
129+
return rows.filter((r) => matches(r, f)).slice(0, options?.limit ?? rows.length);
123130
},
124131
} as any;
125132
const USERS = ['u_a', 'u_b', 'u_global', 'u_expired', 'u_pending', 'u_mixed', 'u_role_a', 'u_role_b', 'u_none'];

0 commit comments

Comments
 (0)