From a79f18370a2691dae71e58d91d22358fd9bc6dc6 Mon Sep 17 00:00:00 2001 From: Harted Date: Sun, 30 Aug 2026 20:17:59 +0200 Subject: [PATCH] test: stop guessing how far a scan gets before you stop it The spec started a scan over the whole range one register at a time, checked five fields were disabled, stopped it, and then asserted that address 26 had not been reached. That last part is a guess about how fast the machine is: 26 registers with a 5ms pause each is a few hundred milliseconds, about what those five assertions cost. macOS Intel got there first and the test failed for being right. What stopping means is that no more rows arrive, so that is what it waits to see now: the count when it stopped, again a second later. --- e2e/specs/01-main/11-scan-registers.spec.ts | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/e2e/specs/01-main/11-scan-registers.spec.ts b/e2e/specs/01-main/11-scan-registers.spec.ts index 8ad21da..2569e3a 100644 --- a/e2e/specs/01-main/11-scan-registers.spec.ts +++ b/e2e/specs/01-main/11-scan-registers.spec.ts @@ -345,13 +345,24 @@ test.describe.serial('Scan Registers', () => { await mainPage.getByTestId('scan-registers-close-btn').click() await expect(mainPage.getByTestId('scan-start-stop-btn')).toHaveCount(0) - // The scan was stopped early — results are in the main DataGrid. - // Address 0 should have been reached, but the last holding register - // (address 26, unix timestamp) should NOT have been reached. + // The scan reached something, and stopping stopped it. + // + // This used to assert that address 26, the last holding register on the + // server, had not been reached yet. That was a guess about how fast the + // machine is: the scan walks one register at a time with a 5ms pause, so + // 26 of them take a few hundred milliseconds, which is about what the five + // assertions above cost. The fastest runner got there first and the test + // failed for being right. + // + // What stopping means is that no more rows arrive, so that is what this + // waits to see. const rows = mainPage.locator('.MuiDataGrid-row') await expect(rows.first()).toBeVisible({ timeout: 5000 }) await expect(mainPage.locator('.MuiDataGrid-row[data-id="0"]')).toBeVisible() - await expect(mainPage.locator('.MuiDataGrid-row[data-id="26"]')).not.toBeVisible() + + const whenStopped = await rows.count() + await mainPage.waitForTimeout(1000) + expect(await rows.count()).toBe(whenStopped) }) // ─── Cleanup ───────────────────────────────────────────────────────