test: add E2E tests for threads, auth, and error handling

Also fix CandidateListItem to not use Reorder.Item when isActive=false,
which caused a framer-motion crash on resolved thread detail pages.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-03 16:23:26 +02:00
parent 60db8bd9de
commit c4ce96ce4f
4 changed files with 241 additions and 8 deletions

47
e2e/auth.spec.ts Normal file
View File

@@ -0,0 +1,47 @@
import { expect, test } from "@playwright/test";
test.describe("Authentication", () => {
test("login page renders at /login", async ({ page }) => {
await page.goto("/login");
await page.waitForLoadState("networkidle");
// Should show the Sign In heading
await expect(page.getByRole("heading", { name: "Sign In" })).toBeVisible({
timeout: 5000,
});
// Should have username and password inputs
await expect(page.locator("#username")).toBeVisible({ timeout: 5000 });
await expect(page.locator("#password")).toBeVisible({ timeout: 5000 });
});
test("login with valid credentials succeeds and redirects away from /login", async ({
page,
}) => {
await page.goto("/login");
await page.waitForLoadState("networkidle");
await page.locator("#username").fill("admin");
await page.locator("#password").fill("password123");
await page.getByRole("button", { name: "Sign In" }).click();
// After successful login, should redirect to / (dashboard)
await page.waitForURL("/", { timeout: 5000 });
await expect(page).not.toHaveURL(/\/login/);
await expect(page.getByText("GearBox")).toBeVisible({ timeout: 5000 });
});
test("login with wrong password shows error", async ({ page }) => {
await page.goto("/login");
await page.waitForLoadState("networkidle");
await page.locator("#username").fill("admin");
await page.locator("#password").fill("wrongpassword");
await page.getByRole("button", { name: "Sign In" }).click();
// Should stay on the login page and show an error message
await expect(page).toHaveURL(/\/login/, { timeout: 5000 });
// The error paragraph should be visible (login.tsx renders <p className="text-sm text-red-600">{error}</p>)
await expect(page.locator(".text-red-600")).toBeVisible({ timeout: 5000 });
});
});