Initial commit: AetherForge Linux (forge-mesh) v0.1.0-dev
Some checks failed
Test / test (push) Has been cancelled
Some checks failed
Test / test (push) Has been cancelled
This commit is contained in:
42
web/src/pages/LoginPage.test.tsx
Normal file
42
web/src/pages/LoginPage.test.tsx
Normal file
@@ -0,0 +1,42 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { screen, waitFor } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { LoginPage } from "./LoginPage";
|
||||
import { renderWithProviders } from "@/test/test-utils";
|
||||
|
||||
describe("LoginPage", () => {
|
||||
it("renders login form", () => {
|
||||
renderWithProviders(<LoginPage />, {
|
||||
routerProps: { initialEntries: ["/login"] },
|
||||
authenticated: false,
|
||||
});
|
||||
expect(screen.getByText("AetherForge Command Deck")).toBeInTheDocument();
|
||||
expect(screen.getByLabelText("Username")).toBeInTheDocument();
|
||||
expect(screen.getByLabelText("Password")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("shows validation error for empty submit", async () => {
|
||||
const user = userEvent.setup();
|
||||
renderWithProviders(<LoginPage />, {
|
||||
routerProps: { initialEntries: ["/login"] },
|
||||
authenticated: false,
|
||||
});
|
||||
await user.click(screen.getByRole("button", { name: "Authenticate" }));
|
||||
expect(screen.getByText("Username and password are required.")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("authenticates and navigates to dashboard", async () => {
|
||||
const user = userEvent.setup();
|
||||
renderWithProviders(<LoginPage />, {
|
||||
routerProps: { initialEntries: ["/login"] },
|
||||
authenticated: false,
|
||||
});
|
||||
await user.type(screen.getByLabelText("Username"), "operator");
|
||||
await user.type(screen.getByLabelText("Password"), "secret");
|
||||
await user.click(screen.getByRole("button", { name: "Authenticate" }));
|
||||
|
||||
await waitFor(() => {
|
||||
expect(sessionStorage.getItem("aetherforge_auth")).toContain("operator");
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user