test: establish frontend gate taxonomy
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
// @vitest-environment jsdom
|
||||
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
function TestShell() {
|
||||
return <main aria-label="application shell">ready</main>;
|
||||
}
|
||||
|
||||
describe("component test level", () => {
|
||||
it("renders an accessible application shell", () => {
|
||||
render(<TestShell />);
|
||||
expect(screen.getByRole("main", { name: "application shell" })).toHaveTextContent(
|
||||
"ready",
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,8 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
test("boots the public app shell", async ({ page }) => {
|
||||
await page.goto("/");
|
||||
await expect(page.getByRole("heading", { level: 1 })).toHaveText(
|
||||
"Clean Architecture Frontend",
|
||||
);
|
||||
});
|
||||
@@ -0,0 +1,23 @@
|
||||
import { HttpResponse, http } from "msw";
|
||||
import { setupServer } from "msw/node";
|
||||
import { afterAll, afterEach, beforeAll, describe, expect, it } from "vitest";
|
||||
|
||||
const server = setupServer(
|
||||
http.get("https://example.test/health", () =>
|
||||
HttpResponse.json({ success: true, data: { status: "ok" } }),
|
||||
),
|
||||
);
|
||||
|
||||
beforeAll(() => server.listen({ onUnhandledRequest: "error" }));
|
||||
afterEach(() => server.resetHandlers());
|
||||
afterAll(() => server.close());
|
||||
|
||||
describe("integration test level", () => {
|
||||
it("uses MSW to isolate the HTTP boundary", async () => {
|
||||
const response = await fetch("https://example.test/health");
|
||||
await expect(response.json()).resolves.toEqual({
|
||||
success: true,
|
||||
data: { status: "ok" },
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,7 @@
|
||||
import "@testing-library/jest-dom/vitest";
|
||||
import { cleanup } from "@testing-library/react";
|
||||
import { afterEach } from "vitest";
|
||||
|
||||
afterEach(() => {
|
||||
cleanup();
|
||||
});
|
||||
@@ -0,0 +1,13 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { systemClock } from "../../src/application/ports/clock-port.js";
|
||||
|
||||
describe("systemClock", () => {
|
||||
it("resolves after the requested duration", async () => {
|
||||
vi.useFakeTimers();
|
||||
const sleeper = systemClock.sleep(250);
|
||||
await vi.advanceTimersByTimeAsync(250);
|
||||
await expect(sleeper).resolves.toBeUndefined();
|
||||
vi.useRealTimers();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user