fix(tests): widen harness transient import retry window

This commit is contained in:
rookiestar28
2026-04-09 19:22:44 +08:00
parent b39b7204dd
commit f4ddb22233
2 changed files with 33 additions and 5 deletions
+27
View File
@@ -64,4 +64,31 @@ test.describe('OpenClaw Sidebar', () => {
.poll(() => page.evaluate(() => window.__openclawTestLoadAttempts))
.toBe(2);
});
test('harness recovers from two transient openclaw entry fetch failures', async ({ page }) => {
let remainingFailures = 2;
await page.route('**/web/openclaw.js?openclaw_harness_attempt=*', async (route) => {
const url = new URL(route.request().url());
if (url.pathname !== '/web/openclaw.js') {
await route.fallback();
return;
}
if (remainingFailures > 0) {
remainingFailures -= 1;
await route.abort('failed');
return;
}
await route.fallback();
});
await page.reload();
await waitForOpenClawReady(page);
await expect(page.locator('.openclaw-title')).toHaveText('OpenClaw');
await expect
.poll(() => page.evaluate(() => window.__openclawTestLoadAttempts))
.toBe(3);
});
});
+6 -5
View File
@@ -76,7 +76,7 @@
}
async function loadOpenClawWithRetry() {
const maxAttempts = 2;
const maxAttempts = 3;
let lastError = null;
for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
@@ -93,10 +93,11 @@
throw error;
}
// IMPORTANT: retry exactly once for transient module-fetch failures.
// Windows CI can occasionally drop the first module-graph fetch under
// parallel Playwright load; do not broaden this to mask real import bugs.
await new Promise(r => setTimeout(r, 250));
// IMPORTANT: keep this retry window small and transient-fetch-specific.
// Windows CI can occasionally drop more than one early module-graph
// fetch under parallel Playwright load, but broad retries here would
// risk masking real import/runtime regressions.
await new Promise(r => setTimeout(r, 250 * attempt));
}
}