try to make e2e test less flaky

This commit is contained in:
2026-08-08 15:04:56 -04:00
parent 3f7414707a
commit ab46e63bf0
2 changed files with 13 additions and 4 deletions
+12 -1
View File
@@ -46,12 +46,23 @@ export async function addItem(page: Page, name: string, quantity = "") {
}
/** Adds an ingredient to the current meal page. */
export async function addIngredient(page: Page, name: string, quantity = "") {
export async function addIngredient(
page: Page,
name: string,
quantity = "",
category?: string,
) {
await page.fill("#ingredient-name", name);
if (category) {
await page.selectOption("#ingredient-category", { label: category });
}
if (quantity) {
await page.fill("#ingredient-quantity", quantity);
}
await page.click("#add-ingredient-button");
// The form submit is hx-boosted (full body swap to the same URL), so wait for
// the new row to appear. This also acts as a settle point so the next action
// doesn't race the async body replacement and target a stale form.
await expect(page.locator(".ingredient-list").filter({ hasText: name })).toBeVisible();
}