Files
fristy 864b9226fc
Build & Push / Lint & Build (pull_request) Failing after 52s
Build & Push / Build & Push Image (pull_request) Skipped
Build & Push / Trigger Deploy (pull_request) Skipped
desloppify: code health overhaul plus abuse hardening (140 green, strict 87.2)
Honest baseline after removing 45 gaming suppressions. Structural: lib/game plus root hooks extraction, CORS origin echo, DEV_ORIGINS layering. Fixes: error-cause binding, discord 5xx split, null-cache guard, co-located tests, rejecting-fetch coverage, naming and typing cleanup, socket controller, cache bound, cascade helpers, latch resets. Hardening: per-IP rate limit on API routes, deterministic-miss UX, retry cooldown plus cap. Suite 140 green, build plus lint clean.
2026-09-11 23:54:59 +03:00

52 lines
1.9 KiB
TypeScript

import { afterEach, describe, expect, it, vi } from "vitest";
import { render, screen } from "@testing-library/react";
import Home from "@/app/page";
vi.mock("@/lib/i18n/get-locale", () => ({
getLocale: async () => "en" as const,
}));
afterEach(() => {
vi.unstubAllGlobals();
});
describe("Home page", () => {
it("renders hero, sections, and footer", async () => {
vi.stubGlobal(
"fetch",
vi.fn(async (url: string) => {
if (String(url).includes("git.fristy.net")) {
return { ok: true, json: async () => [] } as Response;
}
return {
ok: true,
json: async () => ({
success: true,
data: {
discord_user: {
id: "1",
username: "testuser",
global_name: "Test User",
display_name: "Test User",
discriminator: "0",
avatar: null,
bot: false,
},
activities: [],
discord_status: "offline",
active_on_discord_desktop: false,
active_on_discord_mobile: false,
active_on_discord_web: false,
listening_to_spotify: false,
spotify: null,
},
}),
} as Response;
}),
);
render(await Home());
expect(screen.getByRole("heading", { level: 1 }).textContent).toBe("fristy");
expect(screen.getByText("@testuser")).toBeDefined();
});
});