MCPcopy Index your code
hub / github.com/TanStack/ai / waitForTestComplete

Function waitForTestComplete

testing/e2e/tests/tools-test/helpers.ts:168–195  ·  view source on GitHub ↗
(
  page: Page,
  timeout = 15000,
  expectedToolCount = 1,
)

Source from the content-addressed store, hash-verified

166 * 2. data-is-loading === "false" AND data-complete-tool-count >= expectedToolCount
167 */
168export async function waitForTestComplete(
169 page: Page,
170 timeout = 15000,
171 expectedToolCount = 1,
172): Promise<void> {
173 await page.waitForFunction(
174 ({ minTools }) => {
175 const metadata = document.getElementById('test-metadata')
176 const testComplete =
177 metadata?.getAttribute('data-test-complete') === 'true'
178 const isLoading = metadata?.getAttribute('data-is-loading') === 'true'
179 const completeToolCount = parseInt(
180 metadata?.getAttribute('data-complete-tool-count') || '0',
181 10,
182 )
183
184 // Consider complete if:
185 // 1. testComplete flag is true, OR
186 // 2. Not loading and we have at least the expected number of complete tools
187 return testComplete || (!isLoading && completeToolCount >= minTools)
188 },
189 { minTools: expectedToolCount },
190 { timeout },
191 )
192
193 // Give a little extra time for final state updates
194 await page.waitForTimeout(200)
195}
196
197/**
198 * Wait for client-side execution events to be reflected in the event log.

Calls 1

getAttributeMethod · 0.80

Tested by

no test coverage detected