test(e2e): click the always-present vaccination add button

The capture helper branched on an instant isVisible() read to pick between the
header add and the empty-state add. Right after a navigation that read races the
client render and loses, so it fell through to the empty-state button, which is
gone once a record exists, and the click timed out. The header add renders in
both states; clicking it directly lets click() auto-wait for hydration.
This commit is contained in:
Marc-André Bombeck committed 2026-08-08 23:23:15 +02:00
1 parent 999206767f
commit 5aa03674a5
1 file changed
+5 -8
+5 -8
View File
@@ -84,14 +84,11 @@ async function captureDose(
booster: "confirm" | "decline" | "none";
},
): Promise<void> {
const add = page.locator('[data-slot="vaccination-add"]').first();
const addEmpty = page.locator('[data-slot="vaccination-add-empty"]').first();
// The list uses a header Add; the empty state uses its own.
if (await add.isVisible().catch(() => false)) {
await add.click();
} else {
await addEmpty.click();
}
// The header Add renders whether or not the list is empty, so clicking it
// works in both states. click() auto-waits for the button to be actionable,
// which avoids racing an instant visibility read against the client render
// (an empty-state-only branch times out once a record already exists).
await page.locator('[data-slot="vaccination-add"]').first().click();
await expect(page.locator('[data-slot="vaccination-form"]')).toBeVisible();