Files
sustenance/e2e/tests/meals.spec.ts
T
2026-08-01 21:24:48 -04:00

22 lines
893 B
TypeScript

import { expect } from "@playwright/test";
import { test } from "../fixtures";
import { registerAndLogin } from "../helpers";
test("a user can create a meal", async ({ page }) => {
await registerAndLogin(page, "alice@example.com");
await page.goto("/meals/new");
await page.fill("#meal-name", "Spaghetti Bolognese");
await page.fill("#meal-description", "## Ingredients\n\nA classic weeknight dinner.");
await page.click('button:has-text("Save meal")');
// Lands on the meal detail page and renders the markdown description.
await expect(page).toHaveURL(/\/meals\/\d+/);
await expect(page.locator("h1")).toContainText("Spaghetti Bolognese");
await expect(page.locator(".markdown h2")).toContainText("Ingredients");
// The meal appears on the meals index.
await page.goto("/meals");
await expect(page.locator(".list-card")).toContainText("Spaghetti Bolognese");
});