@@ -179,19 +179,22 @@ async function waitForRunnerCatalog(baseUrl: string, timeoutMs = 5_000) {
|
179 | 179 | throw new Error("runner catalog stayed loading"); |
180 | 180 | } |
181 | 181 | |
182 | | -async function waitForFile(filePath: string, timeoutMs = 5_000) { |
| 182 | +async function waitForFileContent(filePath: string, expected: string, timeoutMs = 5_000) { |
183 | 183 | const startedAt = Date.now(); |
184 | 184 | while (Date.now() - startedAt < timeoutMs) { |
185 | 185 | try { |
186 | | -return await readFile(filePath, "utf8"); |
| 186 | +const content = await readFile(filePath, "utf8"); |
| 187 | +if (content === expected) { |
| 188 | +return content; |
| 189 | +} |
187 | 190 | } catch (error) { |
188 | 191 | if ((error as NodeJS.ErrnoException).code !== "ENOENT") { |
189 | 192 | throw error; |
190 | 193 | } |
191 | | -await sleep(10); |
192 | 194 | } |
| 195 | +await sleep(10); |
193 | 196 | } |
194 | | -throw new Error(`file did not appear: ${filePath}`); |
| 197 | +throw new Error(`file did not reach expected content: ${filePath}`); |
195 | 198 | } |
196 | 199 | |
197 | 200 | async function createQaLabRepoRootFixture(params?: { |
@@ -584,11 +587,11 @@ describe("qa-lab server", () => {
|
584 | 587 | |
585 | 588 | const bootstrapResponse = await fetchWithRetry(`${lab.baseUrl}/api/bootstrap`); |
586 | 589 | expect(bootstrapResponse.status).toBe(200); |
587 | | -expect(await waitForFile(markerPath)).toBe("0"); |
| 590 | +expect(await waitForFileContent(markerPath, "0")).toBe("0"); |
588 | 591 | |
589 | 592 | await lab.stop(); |
590 | 593 | stopped = true; |
591 | | -expect(await waitForFile(stoppedPath)).toBe("terminated"); |
| 594 | +expect(await waitForFileContent(stoppedPath, "terminated")).toBe("terminated"); |
592 | 595 | }); |
593 | 596 | |
594 | 597 | it("can disable the embedded echo gateway for real-suite runs", async () => { |
|