test: add reproducer for garden dashboard widgets (task 75)
This commit is contained in:
@@ -72,6 +72,57 @@ test("garden care tracking happy path", async ({ page }) => {
|
||||
await expect(page).toHaveURL(/\/garden/);
|
||||
});
|
||||
|
||||
test("garden dashboard widget happy path", async ({ page }) => {
|
||||
const suffix = Date.now().toString();
|
||||
const plantName = `Widget Plant ${suffix}`;
|
||||
|
||||
// Create a plant
|
||||
await page.goto("/garden?tab=plants");
|
||||
await page.getByRole("link", { name: /add plant/i }).click();
|
||||
await page.getByLabel("Name").fill(plantName);
|
||||
await page.getByRole("button", { name: /create/i }).click();
|
||||
await expect(page).toHaveURL(/\/garden\/plants\//);
|
||||
|
||||
// Add watering schedule every 7 days
|
||||
await page.getByRole("button", { name: /care/i }).click();
|
||||
await page.getByRole("button", { name: /add schedule/i }).click();
|
||||
await page.getByLabel(/interval/i).fill("7");
|
||||
await page.getByRole("button", { name: /^add$/i }).click();
|
||||
|
||||
// Log care (watered)
|
||||
await page.getByRole("button", { name: /log care/i }).click();
|
||||
await page.getByRole("button", { name: /^log care$/i }).click();
|
||||
|
||||
// Navigate to dashboard and add garden.care-due widget
|
||||
await page.goto("/d/home?edit=1");
|
||||
const addWidgetButton = page.getByRole("button", { name: /add widget/i });
|
||||
if (await addWidgetButton.isVisible()) {
|
||||
await addWidgetButton.click();
|
||||
const careDueOption = page.getByText(/plants needing care/i);
|
||||
if (await careDueOption.isVisible()) {
|
||||
await careDueOption.click();
|
||||
}
|
||||
}
|
||||
|
||||
// Save layout if dirty
|
||||
const saveButton = page.getByRole("button", { name: /save/i });
|
||||
if (await saveButton.isVisible()) {
|
||||
await saveButton.click();
|
||||
}
|
||||
|
||||
// Navigate back to dashboard — should show the widget
|
||||
await page.goto("/d/home");
|
||||
await expect(page.getByText(/plants needing care|all plants are on schedule/i)).toBeVisible({
|
||||
timeout: 8000,
|
||||
});
|
||||
|
||||
// Cleanup
|
||||
await page.goto("/garden?tab=plants");
|
||||
await page.getByText(plantName).click();
|
||||
await page.getByRole("button", { name: /delete/i }).click();
|
||||
await page.getByRole("button", { name: /confirm/i }).click();
|
||||
});
|
||||
|
||||
test("garden integrations - push overdue to task list", async ({ page }) => {
|
||||
// Navigate to garden page
|
||||
await page.goto("/garden");
|
||||
|
||||
Reference in New Issue
Block a user