mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-11 13:52:20 +00:00
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:
1 parent
999206767f
commit
5aa03674a5
1 file changed
+5
-8
@@ -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();
|
||||
|
||||
|
||||
Reference in new issue
Block a user