test: harden portal hardware contract

This commit is contained in:
2026-09-07 08:12:13 +10:00
parent daf9f207b2
commit 9b070f45f4
6 changed files with 101 additions and 19 deletions
@@ -7,10 +7,18 @@ async function json(response) {
async function waitForScan(request) {
let result;
await expect.poll(async () => {
const response = await request.get('/api/wifi/scan-status');
expect(response.ok()).toBeTruthy();
result = await json(response);
return result.scanning;
try {
const response = await request.get('/api/wifi/scan-status');
if (!response.ok()) return true;
result = await json(response);
return result.scanning;
} catch {
// ESP8266 AP+STA scans briefly leave the AP channel. A client can lose
// its association while the radio scans, then reconnect before the
// asynchronous scan completes. Keep polling; the assertions below still
// require a reachable portal with a complete, valid result.
return true;
}
}, { timeout: 45_000, intervals: [500, 800, 1_000] }).toBe(false);
return result;
}