diff --git a/src/test/plugins/api/pokerogue-api.test.ts b/src/test/plugins/api/pokerogue-api.test.ts index 0c85e039b9a..527361005dd 100644 --- a/src/test/plugins/api/pokerogue-api.test.ts +++ b/src/test/plugins/api/pokerogue-api.test.ts @@ -1,10 +1,11 @@ import type { TitleStatsResponse } from "#app/@types/PokerogueApi"; import { pokerogueApi } from "#app/plugins/api/pokerogue-api"; +import { getApiBaseUrl } from "#app/test/utils/testUtils"; import { http, HttpResponse } from "msw"; import { setupServer } from "msw/node"; import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; -const apiBase = import.meta.env.VITE_API_BASE_URL ?? "http://localhost:8001"; +const apiBase = getApiBaseUrl(); const server = setupServer(); beforeAll(() => { @@ -84,7 +85,6 @@ describe("Pokerogue API", () => { expect(success).toBe(true); }); - it("should return false and report a warning on FAILURE", async () => { server.use(http.post(`${apiBase}/auth/google/logout`, () => new HttpResponse("", { status: 401 }))); diff --git a/src/test/utils/testUtils.ts b/src/test/utils/testUtils.ts index b922fc9c61c..a8410f8ba40 100644 --- a/src/test/utils/testUtils.ts +++ b/src/test/utils/testUtils.ts @@ -21,3 +21,11 @@ export function mockI18next() { export function arrayOfRange(start: integer, end: integer) { return Array.from({ length: end - start }, (_v, k) => k + start); } + +/** + * Utility to get the API base URL from the environment variable (or the default/fallback). + * @returns the API base URL + */ +export function getApiBaseUrl() { + return import.meta.env.VITE_SERVER_URL ?? "http://localhost:8001"; +}