Fix inconsistent line endings across all project files for cross-environment consistency. Add complete unit test suite covering core utilities, API routes, and server services. Add Playwright E2E test setup with smoke, auth, and agent API tests. Update all project configuration files to match standardized formatting. Fix MCP API error handling to properly propagate HTTP status codes and use correct JSON-RPC error codes. Add VSCode workspace configuration, extensions, and example MCP config files. Update .gitignore to exclude new test and build artifacts.
33 lines
1.5 KiB
TypeScript
33 lines
1.5 KiB
TypeScript
import { test, expect, HAS_AUTH_FIXTURE } from "./_helpers";
|
|
|
|
/**
|
|
* Auth flow specs require a seeded PocketBase user (E2E_TEST_EMAIL /
|
|
* E2E_TEST_PASSWORD). When those are missing we skip cleanly so the rest of
|
|
* the suite still runs.
|
|
*/
|
|
test.describe("login flow", () => {
|
|
test.skip(!HAS_AUTH_FIXTURE, "E2E_TEST_EMAIL / E2E_TEST_PASSWORD not set — skipping auth specs");
|
|
|
|
test("signs in and lands on a protected page", async ({ page }) => {
|
|
await page.goto("/login");
|
|
await page.getByLabel(/email/i).fill(process.env.E2E_TEST_EMAIL!);
|
|
await page.getByLabel(/password/i).fill(process.env.E2E_TEST_PASSWORD!);
|
|
await page.getByRole("button", { name: /sign in|log in|login/i }).click();
|
|
|
|
// After auth the layout sends the user into the (app) group — typically
|
|
// /dashboard. We only assert we left /login.
|
|
await page.waitForURL((u) => !u.pathname.startsWith("/login"), { timeout: 10_000 });
|
|
expect(page.url()).not.toContain("/login");
|
|
});
|
|
|
|
test("rejects a bad password and stays on /login", async ({ page }) => {
|
|
await page.goto("/login");
|
|
await page.getByLabel(/email/i).fill(process.env.E2E_TEST_EMAIL!);
|
|
await page.getByLabel(/password/i).fill("definitely-wrong-password");
|
|
await page.getByRole("button", { name: /sign in|log in|login/i }).click();
|
|
|
|
// We should still be on the login page. PocketBase typically surfaces a
|
|
// toast on failure; we just check the URL didn't change.
|
|
await expect(page).toHaveURL(/\/login/);
|
|
});
|
|
});
|