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.
This commit is contained in:
78 files changed
+4908
-1430
No files matched your search
@@ -0,0 +1,51 @@
|
||||
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();
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user