fix: resolve module mock conflicts in metadata and sitemap tests

- Add missing drizzle-orm exports (avg, count) to metadata and sitemap test mocks
- Add missing schema exports (steamReviewSentimentEnum) to metadata and sitemap test mocks
- Add missing schema tables (gameVersions, performanceEntries, gameComments, gamePlatformSupport, user, entryScreenshots) to sitemap test mock
- Remove @/lib/steam/sync mock from metadata test to prevent module mock caching conflicts
- Add auth export to @/lib/auth mock

This fixes 7 pre-existing test failures caused by module mock interference
when test files run in the same process.
This commit is contained in:
2026-05-28 00:03:57 +08:00
parent 02e82f5b90
commit 05ddb8b4cc
2 changed files with 70 additions and 6 deletions
+22 -6
View File
@@ -32,6 +32,19 @@ vi.mock("@/lib/db/schema", () => ({
gamePlatformSupport: { gameId: "gameId", hardwareSlug: "hardwareSlug", protonStatus: "protonStatus" },
user: { id: "id", name: "name", image: "image", role: "role" },
entryScreenshots: { id: "id", entryId: "entryId", storageKey: "storageKey", orderIndex: "orderIndex" },
steamReviewSentimentEnum: {
enumValues: [
"overwhelmingly_positive",
"very_positive",
"positive",
"mostly_positive",
"mixed",
"mostly_negative",
"negative",
"very_negative",
"overwhelmingly_negative",
],
},
}))
vi.mock("drizzle-orm", () => ({
@@ -43,18 +56,21 @@ vi.mock("drizzle-orm", () => ({
isNull: vi.fn((col: unknown) => col),
inArray: vi.fn((col: unknown, vals: unknown) => ({ col, vals })),
sql: vi.fn((strings: TemplateStringsArray, ...values: unknown[]) => ({ raw: strings, vals: values })),
}))
vi.mock("@/lib/steam/sync", () => ({
isSyncStale: vi.fn(() => false),
syncSteamGame: vi.fn(() => Promise.resolve()),
avg: vi.fn((col: unknown) => col),
count: vi.fn((col: unknown) => col),
}))
vi.mock("@/lib/storage", () => ({
getR2PublicUrl: vi.fn(() => "https://r2.example.com"),
}))
vi.mock("@/lib/auth", () => ({}))
vi.mock("@/lib/auth", () => ({
auth: {
$Infer: { Session: { user: {} } },
api: {},
handler: vi.fn(),
},
}))
vi.mock("@/lib/auth-client", () => ({}))
vi.mock("@/lib/updates", () => ({