65 lines
2.7 KiB
TypeScript
65 lines
2.7 KiB
TypeScript
import { expect, test } from "@playwright/test";
|
||
|
||
test.describe("Timeline", () => {
|
||
test.beforeEach(async ({ page }) => {
|
||
await page.goto("/auth/signin");
|
||
await page.fill('input[type="email"]', "admin@planarchy.dev");
|
||
await page.fill('input[type="password"]', "admin123");
|
||
await page.click('button[type="submit"]');
|
||
await expect(page).toHaveURL(/\/resources/);
|
||
await page.goto("/timeline");
|
||
});
|
||
|
||
test("loads and displays the timeline", async ({ page }) => {
|
||
await expect(page.locator("text=Resource view")).toBeVisible();
|
||
await expect(page.locator("text=Project view")).toBeVisible();
|
||
// Timeline canvas should be visible
|
||
await expect(page.locator(".overflow-auto")).toBeVisible();
|
||
});
|
||
|
||
test("can switch between resource and project view", async ({ page }) => {
|
||
await page.click("text=Project view");
|
||
await expect(page.locator("text=0 projects").or(page.locator("text=/\\d+ projects/"))).toBeVisible();
|
||
await page.click("text=Resource view");
|
||
await expect(page.locator("text=/\\d+ resources/")).toBeVisible();
|
||
});
|
||
|
||
test("can navigate forward and back", async ({ page }) => {
|
||
const todayBtn = page.locator("button", { hasText: "Today" });
|
||
await expect(todayBtn).toBeVisible();
|
||
await page.locator("button", { hasText: "›" }).click();
|
||
await page.locator("button", { hasText: "‹" }).click();
|
||
await todayBtn.click();
|
||
});
|
||
|
||
test("filter panel opens and closes", async ({ page }) => {
|
||
await page.locator("button", { hasText: "Filter" }).click();
|
||
await expect(page.locator("text=Chapters")).toBeVisible();
|
||
await page.keyboard.press("Escape");
|
||
});
|
||
|
||
test("shows placeholder bars for unassigned allocations", async ({ page }) => {
|
||
// Filter to show placeholders (enabled by default)
|
||
// The timeline should have at least one dashed placeholder bar from seed data
|
||
await page.waitForSelector(".overflow-auto", { state: "visible" });
|
||
// Check that the timeline loaded (resource rows or empty state visible)
|
||
await expect(
|
||
page.locator("text=resources").or(page.locator("text=No allocations"))
|
||
).toBeVisible();
|
||
});
|
||
|
||
test("clicking a placeholder opens the fill placeholder modal", async ({ page }) => {
|
||
// Wait for timeline to load
|
||
await page.waitForSelector(".overflow-auto");
|
||
await page.waitForTimeout(1000); // let tRPC queries settle
|
||
|
||
// Try to find and click a placeholder bar (dashed border style)
|
||
const placeholderBar = page.locator("[style*='dashed']").first();
|
||
if (await placeholderBar.count() > 0) {
|
||
await placeholderBar.click();
|
||
await expect(page.locator("text=Fill Placeholder").or(page.locator("text=Assign Resource"))).toBeVisible();
|
||
await page.keyboard.press("Escape");
|
||
}
|
||
});
|
||
});
|