add meal e2e test
This commit is contained in:
@@ -21,6 +21,7 @@ export async function createMeal(page: Page, name: string, description: string)
|
||||
|
||||
/** Creates a list and lands on its page. */
|
||||
export async function createList(page: Page, name: string) {
|
||||
await page.goto("/lists");
|
||||
await page.fill("#list-name", name);
|
||||
await page.click('button:has-text("Create list")');
|
||||
await expect(page).toHaveURL(/\/lists\/\d+/);
|
||||
@@ -45,3 +46,15 @@ export async function addIngredient(page: Page, name: string, quantity = "") {
|
||||
await page.click("#add-ingredient-button");
|
||||
await expect(page.locator(".ingredient-list").filter({ hasText: name })).toBeVisible();
|
||||
}
|
||||
|
||||
/** Creates a meal and adds the given ingredients to it. */
|
||||
export async function createMealWithIngredients(
|
||||
page: Page,
|
||||
name: string,
|
||||
ingredients: Array<{ name: string; quantity?: string }>,
|
||||
) {
|
||||
await createMeal(page, name, "");
|
||||
for (const ingredient of ingredients) {
|
||||
await addIngredient(page, ingredient.name, ingredient.quantity ?? "");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user