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:
@@ -32,6 +32,19 @@ vi.mock("@/lib/db/schema", () => ({
|
|||||||
gamePlatformSupport: { gameId: "gameId", hardwareSlug: "hardwareSlug", protonStatus: "protonStatus" },
|
gamePlatformSupport: { gameId: "gameId", hardwareSlug: "hardwareSlug", protonStatus: "protonStatus" },
|
||||||
user: { id: "id", name: "name", image: "image", role: "role" },
|
user: { id: "id", name: "name", image: "image", role: "role" },
|
||||||
entryScreenshots: { id: "id", entryId: "entryId", storageKey: "storageKey", orderIndex: "orderIndex" },
|
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", () => ({
|
vi.mock("drizzle-orm", () => ({
|
||||||
@@ -43,18 +56,21 @@ vi.mock("drizzle-orm", () => ({
|
|||||||
isNull: vi.fn((col: unknown) => col),
|
isNull: vi.fn((col: unknown) => col),
|
||||||
inArray: vi.fn((col: unknown, vals: unknown) => ({ col, vals })),
|
inArray: vi.fn((col: unknown, vals: unknown) => ({ col, vals })),
|
||||||
sql: vi.fn((strings: TemplateStringsArray, ...values: unknown[]) => ({ raw: strings, vals: values })),
|
sql: vi.fn((strings: TemplateStringsArray, ...values: unknown[]) => ({ raw: strings, vals: values })),
|
||||||
}))
|
avg: vi.fn((col: unknown) => col),
|
||||||
|
count: vi.fn((col: unknown) => col),
|
||||||
vi.mock("@/lib/steam/sync", () => ({
|
|
||||||
isSyncStale: vi.fn(() => false),
|
|
||||||
syncSteamGame: vi.fn(() => Promise.resolve()),
|
|
||||||
}))
|
}))
|
||||||
|
|
||||||
vi.mock("@/lib/storage", () => ({
|
vi.mock("@/lib/storage", () => ({
|
||||||
getR2PublicUrl: vi.fn(() => "https://r2.example.com"),
|
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/auth-client", () => ({}))
|
||||||
|
|
||||||
vi.mock("@/lib/updates", () => ({
|
vi.mock("@/lib/updates", () => ({
|
||||||
|
|||||||
@@ -32,13 +32,61 @@ vi.mock("@/lib/db/schema", () => ({
|
|||||||
capsuleImage: "capsuleImage",
|
capsuleImage: "capsuleImage",
|
||||||
syncStatus: "syncStatus",
|
syncStatus: "syncStatus",
|
||||||
},
|
},
|
||||||
|
gameVersions: {
|
||||||
|
id: "id",
|
||||||
|
gameId: "gameId",
|
||||||
|
versionString: "versionString",
|
||||||
|
buildId: "buildId",
|
||||||
|
},
|
||||||
|
performanceEntries: {
|
||||||
|
id: "id",
|
||||||
|
versionId: "versionId",
|
||||||
|
isRemoved: "isRemoved",
|
||||||
|
hardwareSlug: "hardwareSlug",
|
||||||
|
fpsAvg: "fpsAvg",
|
||||||
|
fpsLow: "fpsLow",
|
||||||
|
fpsHigh: "fpsHigh",
|
||||||
|
},
|
||||||
hardware: { slug: "slug", createdAt: "createdAt" },
|
hardware: { slug: "slug", createdAt: "createdAt" },
|
||||||
|
gameComments: { gameId: "gameId", id: "id" },
|
||||||
|
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", () => ({
|
vi.mock("drizzle-orm", () => ({
|
||||||
|
eq: vi.fn((col: unknown, val: unknown) => ({ col, val })),
|
||||||
|
and: vi.fn((...args: unknown[]) => args),
|
||||||
|
desc: vi.fn((col: unknown) => col),
|
||||||
or: vi.fn((...args: unknown[]) => args[0]),
|
or: vi.fn((...args: unknown[]) => args[0]),
|
||||||
ne: vi.fn((col: unknown) => col),
|
ne: vi.fn((col: unknown) => col),
|
||||||
isNull: vi.fn((col: unknown) => col),
|
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 })),
|
||||||
|
avg: vi.fn((col: unknown) => col),
|
||||||
|
count: vi.fn((col: unknown) => col),
|
||||||
}))
|
}))
|
||||||
|
|
||||||
const mockGetAllUpdates = vi.fn(() => [])
|
const mockGetAllUpdates = vi.fn(() => [])
|
||||||
|
|||||||
Reference in New Issue
Block a user