add e2e tests for lists and meals
This commit is contained in:
@@ -18,3 +18,30 @@ export async function createMeal(page: Page, name: string, description: string)
|
||||
await page.click('button:has-text("Save meal")');
|
||||
await expect(page).toHaveURL(/\/meals\/\d+/);
|
||||
}
|
||||
|
||||
/** Creates a list and lands on its page. */
|
||||
export async function createList(page: Page, name: string) {
|
||||
await page.fill("#list-name", name);
|
||||
await page.click('button:has-text("Create list")');
|
||||
await expect(page).toHaveURL(/\/lists\/\d+/);
|
||||
}
|
||||
|
||||
/** Adds an item to the current list page. */
|
||||
export async function addItem(page: Page, name: string, quantity = "") {
|
||||
await page.fill("#item-name", name);
|
||||
if (quantity) {
|
||||
await page.fill("#item-quantity", quantity);
|
||||
}
|
||||
await page.click("#add-item-button");
|
||||
await expect(page.locator(".item-row").filter({ hasText: name })).toBeVisible();
|
||||
}
|
||||
|
||||
/** Adds an ingredient to the current meal page. */
|
||||
export async function addIngredient(page: Page, name: string, quantity = "") {
|
||||
await page.fill("#ingredient-name", name);
|
||||
if (quantity) {
|
||||
await page.fill("#ingredient-quantity", quantity);
|
||||
}
|
||||
await page.click("#add-ingredient-button");
|
||||
await expect(page.locator(".ingredient-list").filter({ hasText: name })).toBeVisible();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user