Skip to content

Commit a6cd60a

Browse files
committed
test(mothership): find the attempt cap inside the typed re-run conjunction
1 parent e333fdb commit a6cd60a

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

‎apps/sim/lib/mothership/async-runs/repository.test.ts‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,21 @@ describe('run admission and early Stop', () => {
191191
})
192192
})
193193

194+
/** Finds a condition anywhere in a mocked expression, including inside `sql` and `sql.join` fragments. */
195+
function someNestedCondition(
196+
node: unknown,
197+
predicate: (condition: Record<string, unknown>) => boolean
198+
): boolean {
199+
if (!node || typeof node !== 'object') return false
200+
const record = node as Record<string, unknown>
201+
if (predicate(record)) return true
202+
return ['conditions', 'values', 'fragments'].some(
203+
(key) =>
204+
Array.isArray(record[key]) &&
205+
(record[key] as unknown[]).some((child) => someNestedCondition(child, predicate))
206+
)
207+
}
208+
194209
describe('durable Sim tool ownership', () => {
195210
beforeEach(() => {
196211
resetDbChainMock()
@@ -260,7 +275,7 @@ describe('durable Sim tool ownership', () => {
260275
)
261276
).toBe(true)
262277
expect(
263-
hasMockCondition(
278+
someNestedCondition(
264279
interruptedExecution,
265280
(condition) =>
266281
condition.type === 'lt' && condition.left === copilotAsyncToolCalls.executionAttempts

0 commit comments

Comments
 (0)