test: add comprehensive automated test coverage

- Vitest multi-project setup (unit / integration / component)
- Real-Postgres integration harness via in-process PGlite (TEST_DATABASE_URL
  override), migrations applied per worker; production code untouched
- Unit: routing, locale, validation/Zod schemas, metadata, mail, site-theme,
  marquee, media, portfolio helpers, plus architecture-rule tests
- Integration: Prisma data layer, API routes, and all server actions
- Component: UI primitives and form components (jsdom + Testing Library)
- 371 tests passing
This commit is contained in:
Moh
2026-08-06 02:27:20 +02:00
parent 0f48381894
commit e2e06be86e
50 changed files with 4975 additions and 26 deletions
+36
View File
@@ -0,0 +1,36 @@
import { render, screen } from "@testing-library/react";
import { describe, expect, it } from "vitest";
import { AdminFlash } from "@/components/admin/admin-flash";
describe("AdminFlash", () => {
it("renders nothing when there are no messages", () => {
const { container } = render(<AdminFlash />);
expect(container.firstChild).toBeNull();
});
it("renders a success message with a status role", () => {
render(<AdminFlash success="Saved." />);
const status = screen.getByRole("status");
expect(status).toHaveTextContent("Saved.");
expect(screen.queryByRole("alert")).toBeNull();
});
it("renders an error message with an alert role", () => {
render(<AdminFlash error="Failed." />);
const alert = screen.getByRole("alert");
expect(alert).toHaveTextContent("Failed.");
expect(screen.queryByRole("status")).toBeNull();
});
it("renders both a success and error message together", () => {
render(<AdminFlash success="Yes" error="No" />);
expect(screen.getByRole("status")).toHaveTextContent("Yes");
expect(screen.getByRole("alert")).toHaveTextContent("No");
});
it("applies a custom className to the wrapper", () => {
const { container } = render(<AdminFlash success="Yes" className="mb-4" />);
expect(container.firstChild).toHaveClass("mb-4");
});
});