fix: garden container plant count

This commit is contained in:
ginnoir
2026-07-04 18:15:54 -05:00
parent 7eeb2f15bc
commit 700ee29f83
3 changed files with 80 additions and 33 deletions
+33 -8
View File
@@ -138,31 +138,56 @@ test("garden integrations - push overdue to task list", async ({ page }) => {
});
test("garden containers happy path", async ({ page }) => {
const suffix = Date.now().toString();
const containerName = `Living Room Shelf ${suffix}`;
const plantName = `Shelf Plant ${suffix}`;
await page.goto("/garden");
await expect(page.getByRole("heading", { name: "Garden" })).toBeVisible();
// Create a container
await page.getByRole("button", { name: /new container/i }).click();
await page.getByLabel("Name").fill("Living Room Shelf");
await page.getByLabel("Name").fill(containerName);
await page.getByLabel("Type").selectOption("shelf");
await page.getByRole("button", { name: /save|create/i }).click();
// Verify it appears in the list
await expect(page.getByText("Living Room Shelf")).toBeVisible();
// Verify it appears in the list with zero plants
await expect(page.getByText(containerName)).toBeVisible();
const containerCard = page.locator("a.card", { hasText: containerName });
await expect(containerCard.getByText("0 plants")).toBeVisible();
// Open the container detail
await page.getByText("Living Room Shelf").click();
await expect(page.getByRole("heading", { name: "Living Room Shelf" })).toBeVisible();
await page.getByText(containerName).click();
await expect(page.getByRole("heading", { name: containerName })).toBeVisible();
// Add a plant assigned to this container
await page.getByRole("link", { name: /add plant/i }).click();
await expect(page).toHaveURL(/containerId=/);
await page.getByLabel("Name").fill(plantName);
await page.getByRole("button", { name: /create/i }).click();
await expect(page).toHaveURL(/\/garden\/plants\//);
// Container detail should show the plant count
await page.goto("/garden");
await page.getByText(containerName).click();
await expect(page.getByRole("heading", { name: new RegExp(`Plants \\(1\\)`) })).toBeVisible();
await expect(page.getByText(plantName)).toBeVisible();
// Container list should show the updated count
await page.goto("/garden");
await expect(containerCard.getByText("1 plant")).toBeVisible();
// Edit the container
await page.getByText(containerName).click();
await page.getByRole("button", { name: /edit/i }).click();
await page.getByLabel("Name").fill("Living Room Shelf (Updated)");
const updatedName = `${containerName} (Updated)`;
await page.getByLabel("Name").fill(updatedName);
await page.getByRole("button", { name: /save/i }).click();
await expect(page.getByRole("heading", { name: "Living Room Shelf (Updated)" })).toBeVisible();
await expect(page.getByRole("heading", { name: updatedName })).toBeVisible();
// Delete the container
await page.getByRole("button", { name: /delete/i }).click();
await page.getByRole("button", { name: /confirm|yes/i }).click();
await expect(page).toHaveURL(/\/garden/);
await expect(page.getByText("Living Room Shelf")).toBeHidden();
await expect(page.getByText(updatedName)).toBeHidden();
});