import { expect, test } from "@playwright/test";

test.describe("Resources", () => {
  test.beforeEach(async ({ page }) => {
    await page.goto("/auth/signin");
    await page.fill('input[type="email"]', "manager@capakraken.dev");
    await page.fill('input[type="password"]', "manager123");
    await page.click('button[type="submit"]');
    await expect(page).toHaveURL(/\/resources/);
  });

  test("shows resources list", async ({ page }) => {
    await expect(page.locator("h1")).toContainText("Resources");
    await expect(page.locator("table")).toBeVisible();
  });

  test("can search resources", async ({ page }) => {
    const searchInput = page.locator('input[type="search"]');
    await searchInput.fill("EMP-001");
    await page.waitForTimeout(500);
    // Should show filtered results
    await expect(page.locator("tbody tr")).toHaveCount(1);
  });
});
