Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Upgrade fetch mock to v12 (#61857)

Fraserd7653edd9dde
diff --git a/.github/workflows/frontend.yml b/.github/workflows/frontend.yml
index 0ef5c68103c..396d61f3092 100644
--- a/.github/workflows/frontend.yml
+++ b/.github/workflows/frontend.yml
@@ -9,6 +9,16 @@ on:
skip-lint:
type: boolean
default: false
+ workflow_dispatch:
+ inputs:
+ skip:
+ description: "Skip main frontend jobs (type-check, unit tests, timezone tests)"
+ type: boolean
+ default: false
+ skip-lint:
+ description: "Skip linting jobs (prettier, eslint, css variables check)"
+ type: boolean
+ default: false
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref && github.ref || github.run_id }}-frontend
@@ -67,7 +77,7 @@ jobs:
strategy:
fail-fast: false
matrix:
- shard: [1, 2]
+ shard: [1, 2] # 2 shards for parallel execution
env:
SHARDS: 2 # should match matrix above
JEST_JUNIT_OUTPUT_DIR: ./target/junit
@@ -84,7 +94,7 @@ jobs:
run: yarn run test-unit --silent --shard=${{ matrix.shard }}/${{ env.SHARDS }}
- name: Upload Test Results
uses: ./.github/actions/upload-test-results
- if: always()
+ if: always() && github.event_name != 'workflow_dispatch'
with:
input-path: ./target/junit
output-name: frontend-unit
diff --git a/enterprise/frontend/src/embedding-sdk/components/public/CollectionBrowser/CollectionBrowser.unit.spec.tsx b/enterprise/frontend/src/embedding-sdk/components/public/CollectionBrowser/CollectionBrowser.unit.spec.tsx
index dda5fbaa5fb..bb95ecd1ba4 100644
--- a/enterprise/frontend/src/embedding-sdk/components/public/CollectionBrowser/CollectionBrowser.unit.spec.tsx
+++ b/enterprise/frontend/src/embedding-sdk/components/public/CollectionBrowser/CollectionBrowser.unit.spec.tsx
@@ -131,7 +131,9 @@ async function setup({
await waitFor(() => {
expect(
- fetchMock.calls(`path:/api/collection/${ROOT_TEST_COLLECTION.id}/items`),
+ fetchMock.callHistory.calls(
+ `path:/api/collection/${ROOT_TEST_COLLECTION.id}/items`,
+ ),
).toHaveLength(1);
});
}
diff --git a/enterprise/frontend/src/embedding-sdk/components/public/CreateDashboardModal/CreateDashboardModal.unit.spec.tsx b/enterprise/frontend/src/embedding-sdk/components/public/CreateDashboardModal/CreateDashboardModal.unit.spec.tsx
index c230bedc083..2edcd2f3135 100644
--- a/enterprise/frontend/src/embedding-sdk/components/public/CreateDashboardModal/CreateDashboardModal.unit.spec.tsx
+++ b/enterprise/frontend/src/embedding-sdk/components/public/CreateDashboardModal/CreateDashboardModal.unit.spec.tsx
@@ -89,7 +89,9 @@ describe("CreateDashboardModal", () => {
await waitFor(() => {
return expect(
- fetchMock.called(`path:/api/collection/${PERSONAL_COLLECTION.id}`),
+ fetchMock.callHistory.called(
+ `path:/api/collection/${PERSONAL_COLLECTION.id}`,
+ ),
).toBe(true);
});
@@ -100,15 +102,14 @@ describe("CreateDashboardModal", () => {
await userEvent.click(screen.getByText("Create"));
expect(
- fetchMock.calls(`path:/api/dashboard`, { method: "POST" }),
+ fetchMock.callHistory.calls(`path:/api/dashboard`, { method: "POST" }),
).toHaveLength(1);
// api called with typed form input
- expect(
- await fetchMock
- .lastCall(`path:/api/dashboard`, { method: "POST" })
- ?.request?.json(),
- ).toMatchObject({
+ const lastCall = fetchMock.callHistory.lastCall(`path:/api/dashboard`, {
+ method: "POST",
+ });
+ expect(await lastCall?.request?.json()).toMatchObject({
name: "My awesome dashboard title",
collection_id: PERSONAL_COLLECTION.id,
});
diff --git a/enterprise/frontend/src/embedding-sdk/components/public/CreateDashboardModal/use-create-dashboard-api.unit.spec.tsx b/enterprise/frontend/src/embedding-sdk/components/public/CreateDashboardModal/use-create-dashboard-api.unit.spec.tsx
index 372a6f12ca4..cabe23e5313 100644
--- a/enterprise/frontend/src/embedding-sdk/components/public/CreateDashboardModal/use-create-dashboard-api.unit.spec.tsx
+++ b/enterprise/frontend/src/embedding-sdk/components/public/CreateDashboardModal/use-create-dashboard-api.unit.spec.tsx
@@ -24,7 +24,7 @@ describe("useCreateDashboardApi", () => {
await userEvent.click(screen.getByText("Create dashboard"));
expect(
- fetchMock.calls(`path:/api/dashboard`, { method: "POST" }),
+ fetchMock.callHistory.calls(`path:/api/dashboard`, { method: "POST" }),
).toHaveLength(1);
});
@@ -47,12 +47,14 @@ describe("useCreateDashboardApi", () => {
await userEvent.click(screen.getByText("Create dashboard"));
- const calls = fetchMock.calls(`path:/api/dashboard`, { method: "POST" });
+ const calls = fetchMock.callHistory.calls(`path:/api/dashboard`, {
+ method: "POST",
+ });
expect(calls).toHaveLength(1);
- const [_url, options] = calls[0];
+ const call = calls[0];
- const requestBody = (await options?.body) as string;
+ const requestBody = call.options?.body as string;
expect(JSON.parse(requestBody)).toMatchObject({
collection_id: TEST_PERSONAL_COLLECTION_ID,
});
diff --git a/enterprise/frontend/src/embedding-sdk/components/public/SdkQuestion/SdkQuestion.unit.spec.tsx b/enterprise/frontend/src/embedding-sdk/components/public/SdkQuestion/SdkQuestion.unit.spec.tsx
index 3edf72f1e3c..4ca80d73ada 100644
--- a/enterprise/frontend/src/embedding-sdk/components/public/SdkQuestion/SdkQuestion.unit.spec.tsx
+++ b/enterprise/frontend/src/embedding-sdk/components/public/SdkQuestion/SdkQuestion.unit.spec.tsx
@@ -338,7 +338,7 @@ describe("InteractiveQuestion", () => {
await waitForLoaderToBeRemoved();
- const lastQuery = fetchMock.lastCall(
+ const lastQuery = fetchMock.callHistory.lastCall(
`path:/api/card/${TEST_CARD.id}/query`,
);
const queryRequest = await lastQuery?.request?.json();
diff --git a/enterprise/frontend/src/embedding-sdk/components/public/dashboard/EditableDashboard/EditableDashboard.unit.spec.tsx b/enterprise/frontend/src/embedding-sdk/components/public/dashboard/EditableDashboard/EditableDashboard.unit.spec.tsx
index 0fe77dbcaaf..42e82e67b67 100644
--- a/enterprise/frontend/src/embedding-sdk/components/public/dashboard/EditableDashboard/EditableDashboard.unit.spec.tsx
+++ b/enterprise/frontend/src/embedding-sdk/components/public/dashboard/EditableDashboard/EditableDashboard.unit.spec.tsx
@@ -120,9 +120,11 @@ describe("EditableDashboard", () => {
).toBeInTheDocument();
// Default `entityTypes` should be `["model", "table"]`
- const dataPickerDataCalls = fetchMock.calls("path:/api/search");
- expect(dataPickerDataCalls).toHaveLength(1);
- const [[dataPickerDataCallUrl]] = dataPickerDataCalls;
+ // EmbeddingDataPicker makes a call to `/api/search` with limit=0 to decide if SimpleDataPicker should be used
+ // then SimpleDataPicker makes a call to `/api/search` to fetch the data
+ const dataPickerDataCalls = fetchMock.callHistory.calls("path:/api/search");
+ expect(dataPickerDataCalls).toHaveLength(2);
+ const dataPickerDataCallUrl = dataPickerDataCalls[1].url;
expect(dataPickerDataCallUrl).toContain("models=dataset");
expect(dataPickerDataCallUrl).toContain("models=table");
});
@@ -185,9 +187,12 @@ describe("EditableDashboard", () => {
await screen.findByRole("button", { name: "Pick your starting data" }),
).toBeInTheDocument();
- const dataPickerDataCalls = fetchMock.calls("path:/api/search");
- expect(dataPickerDataCalls).toHaveLength(1);
- const [[dataPickerDataCallUrl]] = dataPickerDataCalls;
+ // Default `entityTypes` should be `["model", "table"]`
+ // EmbeddingDataPicker makes a call to `/api/search` with limit=0 to decide if SimpleDataPicker should be used
+ // then SimpleDataPicker makes a call to `/api/search` to fetch the data
+ const dataPickerDataCalls = fetchMock.callHistory.calls("path:/api/search");
+ expect(dataPickerDataCalls).toHaveLength(2);
+ const dataPickerDataCallUrl = dataPickerDataCalls[1].url;
expect(dataPickerDataCallUrl).toContain("models=dataset");
expect(dataPickerDataCallUrl).not.toContain("models=table");
});
diff --git a/enterprise/frontend/src/embedding-sdk/components/public/dashboard/tests/SdkDashboard.unit.spec.tsx b/enterprise/frontend/src/embedding-sdk/components/public/dashboard/tests/SdkDashboard.unit.spec.tsx
index 0b7887109f1..ccbabb13953 100644
--- a/enterprise/frontend/src/embedding-sdk/components/public/dashboard/tests/SdkDashboard.unit.spec.tsx
+++ b/enterprise/frontend/src/embedding-sdk/components/public/dashboard/tests/SdkDashboard.unit.spec.tsx
@@ -64,7 +64,7 @@ describe("SdkDashboard", () => {
// do not reload dashboard data on navigate back
expect(
- fetchMock.calls(`path:/api/dashboard/${TEST_DASHBOARD_ID}`),
+ fetchMock.callHistory.calls(`path:/api/dashboard/${TEST_DASHBOARD_ID}`),
).toHaveLength(1);
});
@@ -85,7 +85,7 @@ describe("SdkDashboard", () => {
// do not reload dashboard data on navigate back
expect(
- fetchMock.calls(`path:/api/dashboard/${TEST_DASHBOARD_ID}`),
+ fetchMock.callHistory.calls(`path:/api/dashboard/${TEST_DASHBOARD_ID}`),
).toHaveLength(1);
});
@@ -100,7 +100,7 @@ describe("SdkDashboard", () => {
expect(onLoadWithoutCards).toHaveBeenLastCalledWith(dashboard);
await waitFor(() => {
- return fetchMock.called(
+ return fetchMock.callHistory.called(
`path:/api/card/${dashboard.dashcards[0].card_id}/query`,
);
});
@@ -125,7 +125,7 @@ describe("SdkDashboard", () => {
expect(onLoadWithoutCards).toHaveBeenLastCalledWith(dashboard);
await waitFor(() => {
- return fetchMock.called(
+ return fetchMock.callHistory.called(
`path:/api/card/${dashboard.dashcards[0].card_id}/query`,
);
});
diff --git a/enterprise/frontend/src/embedding-sdk/hooks/private/use-init-data/test/common.unit.spec.tsx b/enterprise/frontend/src/embedding-sdk/hooks/private/use-init-data/test/common.unit.spec.tsx
index 7e1c079896f..db7446e8b8c 100644
--- a/enterprise/frontend/src/embedding-sdk/hooks/private/use-init-data/test/common.unit.spec.tsx
+++ b/enterprise/frontend/src/embedding-sdk/hooks/private/use-init-data/test/common.unit.spec.tsx
@@ -1,5 +1,3 @@
-import fetchMock from "fetch-mock";
-
import { screen } from "__support__/ui";
import {
setupMockJwtEndpoints,
@@ -18,11 +16,6 @@ const setupCommon = (method: "jwt" | "saml", config?: MetabaseConfigProps) => {
};
describe.each(["jwt"] as const)("useInitData - %s authentication", (method) => {
- afterEach(() => {
- jest.restoreAllMocks();
- fetchMock.restore();
- });
-
it("should set isLoggedIn to true if login is successful", async () => {
setupCommon(method);
diff --git a/enterprise/frontend/src/embedding-sdk/hooks/private/use-init-data/test/jwt.unit.spec.tsx b/enterprise/frontend/src/embedding-sdk/hooks/private/use-init-data/test/jwt.unit.spec.tsx
index cd16a0a1dd6..d6317446cb1 100644
--- a/enterprise/frontend/src/embedding-sdk/hooks/private/use-init-data/test/jwt.unit.spec.tsx
+++ b/enterprise/frontend/src/embedding-sdk/hooks/private/use-init-data/test/jwt.unit.spec.tsx
@@ -27,7 +27,6 @@ const setupJwt = ({
describe("useInitData - JWT authentication", () => {
afterEach(() => {
jest.restoreAllMocks();
- fetchMock.restore();
});
it("should provide a helpful error if the user can't connect to their server for JWT", async () => {
@@ -73,7 +72,7 @@ describe("useInitData - JWT authentication", () => {
setupJwt();
expect(await screen.findByTestId("test-component")).toBeInTheDocument();
- const lastCallRequest = fetchMock.lastCall(
+ const lastCallRequest = fetchMock.callHistory.lastCall(
"path:/api/user/current",
)?.request;
diff --git a/enterprise/frontend/src/embedding-sdk/hooks/private/use-init-data/test/saml.unit.spec.tsx b/enterprise/frontend/src/embedding-sdk/hooks/private/use-init-data/test/saml.unit.spec.tsx
index b59977d4fdc..bb434850ddc 100644
--- a/enterprise/frontend/src/embedding-sdk/hooks/private/use-init-data/test/saml.unit.spec.tsx
+++ b/enterprise/frontend/src/embedding-sdk/hooks/private/use-init-data/test/saml.unit.spec.tsx
@@ -11,17 +11,12 @@ const setupSaml = (config: MetabaseConfigProps = {}) => {
};
describe("useInitData - SAML authentication", () => {
- afterEach(() => {
- jest.restoreAllMocks();
- fetchMock.restore();
- });
-
it("should send API requests with session token if initialization and login are successful", async () => {
const { popupMock } = setupSaml();
expect(await screen.findByTestId("test-component")).toBeInTheDocument();
- const lastCallRequest = fetchMock.lastCall(
+ const lastCallRequest = fetchMock.callHistory.lastCall(
"path:/api/user/current",
)?.request;
diff --git a/enterprise/frontend/src/embedding-sdk/test/auth-flow/api-key.unit.spec.tsx b/enterprise/frontend/src/embedding-sdk/test/auth-flow/api-key.unit.spec.tsx
index 9da79876cb1..60f6cf731d4 100644
--- a/enterprise/frontend/src/embedding-sdk/test/auth-flow/api-key.unit.spec.tsx
+++ b/enterprise/frontend/src/embedding-sdk/test/auth-flow/api-key.unit.spec.tsx
@@ -17,18 +17,21 @@ describe("Auth Flow - API Key", () => {
});
await waitForRequest(() => getLastUserApiCall());
- expect(getLastUserApiCall()![1]).toMatchObject({
- headers: { "X-Api-Key": [MOCK_API_KEY] },
- });
+ expect(getLastUserApiCall()?.options.headers).toHaveProperty(
+ "x-api-key",
+ MOCK_API_KEY,
+ );
await waitForRequest(() => getLastCardQueryApiCall());
- expect(getLastCardQueryApiCall()![1]).toMatchObject({
- headers: { "X-Api-Key": [MOCK_API_KEY] },
- });
+ expect(getLastCardQueryApiCall()?.options.headers).toHaveProperty(
+ "x-api-key",
+ MOCK_API_KEY,
+ );
await waitForRequest(() => getLastCardQueryApiCall());
- expect(getLastCardQueryApiCall()![1]).toMatchObject({
- headers: { "X-Api-Key": [MOCK_API_KEY] },
- });
+ expect(getLastCardQueryApiCall()?.options.headers).toHaveProperty(
+ "x-api-key",
+ MOCK_API_KEY,
+ );
});
});
diff --git a/enterprise/frontend/src/embedding-sdk/test/auth-flow/jwt.unit.spec.tsx b/enterprise/frontend/src/embedding-sdk/test/auth-flow/jwt.unit.spec.tsx
index dc5de87ad0c..770a9a38e7d 100644
--- a/enterprise/frontend/src/embedding-sdk/test/auth-flow/jwt.unit.spec.tsx
+++ b/enterprise/frontend/src/embedding-sdk/test/auth-flow/jwt.unit.spec.tsx
@@ -28,7 +28,7 @@ const setup = ({
return {
...baseSetup({ authConfig, locale }),
getLastAuthProviderApiCall: () =>
- fetchMock.lastCall(`${MOCK_JWT_PROVIDER_URI}?response=json`),
+ fetchMock.callHistory.lastCall(`${MOCK_JWT_PROVIDER_URI}?response=json`),
};
};
@@ -42,7 +42,7 @@ describe("Auth Flow - JWT", () => {
await waitForLoaderToBeRemoved();
expect(
- fetchMock.calls(`${MOCK_JWT_PROVIDER_URI}?response=json`),
+ fetchMock.callHistory.calls(`${MOCK_JWT_PROVIDER_URI}?response=json`),
).toHaveLength(1);
rerender(
@@ -54,7 +54,7 @@ describe("Auth Flow - JWT", () => {
await waitForLoaderToBeRemoved();
expect(
- fetchMock.calls(`${MOCK_JWT_PROVIDER_URI}?response=json`),
+ fetchMock.callHistory.calls(`${MOCK_JWT_PROVIDER_URI}?response=json`),
).toHaveLength(1);
const loader = screen.queryByTestId("loading-indicator");
@@ -78,21 +78,22 @@ describe("Auth Flow - JWT", () => {
} = setup({ authConfig });
await waitForRequest(() => getLastCardQueryApiCall());
-
- expect(getLastAuthProviderApiCall()![1]).toMatchObject({
+ expect(getLastAuthProviderApiCall()?.options).toMatchObject({
credentials: "include",
- method: "GET",
+ method: /GET/i,
});
await waitForRequest(() => getLastUserApiCall());
- expect(getLastUserApiCall()![1]).toMatchObject({
- headers: { "X-Metabase-Session": [MOCK_SESSION_TOKEN_ID] },
- });
+ expect(getLastUserApiCall()?.options.headers).toHaveProperty(
+ "x-metabase-session",
+ MOCK_SESSION_TOKEN_ID,
+ );
await waitForRequest(() => getLastCardQueryApiCall());
- expect(getLastCardQueryApiCall()![1]).toMatchObject({
- headers: { "X-Metabase-Session": [MOCK_SESSION_TOKEN_ID] },
- });
+ expect(getLastCardQueryApiCall()?.options.headers).toHaveProperty(
+ "x-metabase-session",
+ MOCK_SESSION_TOKEN_ID,
+ );
});
it("should use `fetchRequestToken` if provided", async () => {
@@ -114,37 +115,35 @@ describe("Auth Flow - JWT", () => {
expect(customFetchFunction).toHaveBeenCalled();
- expect(getLastUserApiCall()![1]).toMatchObject({
- headers: {
- "X-Metabase-Session": [MOCK_SESSION_TOKEN_ID],
- },
- });
+ expect(getLastUserApiCall()?.options.headers).toHaveProperty(
+ "x-metabase-session",
+ MOCK_SESSION_TOKEN_ID,
+ );
await waitForRequest(() => getLastCardQueryApiCall());
- expect(getLastCardQueryApiCall()![1]).toMatchObject({
- headers: {
- "X-Metabase-Session": [MOCK_SESSION_TOKEN_ID],
- },
- });
+ expect(getLastCardQueryApiCall()?.options.headers).toHaveProperty(
+ "x-metabase-session",
+ MOCK_SESSION_TOKEN_ID,
+ );
});
it("should include the subpath when requesting the SSO endpoint", async () => {
// we can't use the usual mocks here as they use mocks that don't expect the subpath
const instanceUrlWithSubpath = `${MOCK_INSTANCE_URL}/subpath`;
- fetchMock.mock(`${instanceUrlWithSubpath}/auth/sso`, {
+ fetchMock.get(`${instanceUrlWithSubpath}/auth/sso`, {
status: 200,
body: { url: MOCK_JWT_PROVIDER_URI, method: "jwt" },
});
- fetchMock.mock(`${MOCK_JWT_PROVIDER_URI}?response=json`, {
+ fetchMock.get(`${MOCK_JWT_PROVIDER_URI}?response=json`, {
status: 200,
body: {
jwt: MOCK_VALID_JWT_RESPONSE,
},
});
- fetchMock.mock(
+ fetchMock.get(
`${instanceUrlWithSubpath}/auth/sso?jwt=${MOCK_VALID_JWT_RESPONSE}`,
{
status: 200,
@@ -167,12 +166,10 @@ describe("Auth Flow - JWT", () => {
await waitForLoaderToBeRemoved();
- const expectedSsoUrl = `${instanceUrlWithSubpath}/auth/sso`;
-
// One call is for the initial "configuration", to know which sso method to use
// The second call is the actual "login"
expect(
- fetchMock.calls((url) => url.startsWith(expectedSsoUrl)),
+ fetchMock.callHistory.calls(`begin:${instanceUrlWithSubpath}/auth/sso`),
).toHaveLength(2);
});
});
diff --git a/enterprise/frontend/src/embedding-sdk/test/auth-flow/saml.unit.spec.tsx b/enterprise/frontend/src/embedding-sdk/test/auth-flow/saml.unit.spec.tsx
index af5629b9e1c..a4d5096ee26 100644
--- a/enterprise/frontend/src/embedding-sdk/test/auth-flow/saml.unit.spec.tsx
+++ b/enterprise/frontend/src/embedding-sdk/test/auth-flow/saml.unit.spec.tsx
@@ -40,9 +40,9 @@ describe("Auth Flow - SAML", () => {
const { rerender, popup } = setup({ authConfig });
await waitForLoaderToBeRemoved();
- expect(fetchMock.calls(`begin:${MOCK_INSTANCE_URL}/auth/sso`)).toHaveLength(
- 1,
- );
+ expect(
+ fetchMock.callHistory.calls(`begin:${MOCK_INSTANCE_URL}/auth/sso`),
+ ).toHaveLength(1);
expect(popup.close).toHaveBeenCalled();
rerender(
@@ -53,9 +53,9 @@ describe("Auth Flow - SAML", () => {
await waitForLoaderToBeRemoved();
- expect(fetchMock.calls(`begin:${MOCK_INSTANCE_URL}/auth/sso`)).toHaveLength(
- 1,
- );
+ expect(
+ fetchMock.callHistory.calls(`begin:${MOCK_INSTANCE_URL}/auth/sso`),
+ ).toHaveLength(1);
const loader = screen.queryByTestId("loading-indicator");
expect(loader).not.toBeInTheDocument();
@@ -76,13 +76,15 @@ describe("Auth Flow - SAML", () => {
});
await waitForRequest(() => getLastUserApiCall());
- expect(getLastUserApiCall()![1]).toMatchObject({
- headers: { "X-Metabase-Session": [MOCK_SESSION_TOKEN_ID] },
- });
+ expect(getLastUserApiCall()?.options.headers).toHaveProperty(
+ "x-metabase-session",
+ MOCK_SESSION_TOKEN_ID,
+ );
await waitForRequest(() => getLastCardQueryApiCall());
- expect(getLastCardQueryApiCall()![1]).toMatchObject({
- headers: { "X-Metabase-Session": [MOCK_SESSION_TOKEN_ID] },
- });
+ expect(getLastCardQueryApiCall()?.options.headers).toHaveProperty(
+ "x-metabase-session",
+ MOCK_SESSION_TOKEN_ID,
+ );
});
});
diff --git a/enterprise/frontend/src/embedding-sdk/test/auth-flow/setup.tsx b/enterprise/frontend/src/embedding-sdk/test/auth-flow/setup.tsx
index 200a88f3422..8bc196d1903 100644
--- a/enterprise/frontend/src/embedding-sdk/test/auth-flow/setup.tsx
+++ b/enterprise/frontend/src/embedding-sdk/test/auth-flow/setup.tsx
@@ -52,9 +52,11 @@ export const setup = ({
});
const getLastUserApiCall = () =>
- fetchMock.lastCall(`${MOCK_INSTANCE_URL}/api/user/current`);
+ fetchMock.callHistory.lastCall(`${MOCK_INSTANCE_URL}/api/user/current`);
const getLastCardQueryApiCall = () =>
- fetchMock.lastCall(`${MOCK_INSTANCE_URL}/api/card/${MOCK_CARD.id}/query`);
+ fetchMock.callHistory.lastCall(
+ `${MOCK_INSTANCE_URL}/api/card/${MOCK_CARD.id}/query`,
+ );
return {
...renderWithProviders(
diff --git a/enterprise/frontend/src/embedding-sdk/test/mocks/sso.ts b/enterprise/frontend/src/embedding-sdk/test/mocks/sso.ts
index 9c89228707e..888eb1bff4a 100644
--- a/enterprise/frontend/src/embedding-sdk/test/mocks/sso.ts
+++ b/enterprise/frontend/src/embedding-sdk/test/mocks/sso.ts
@@ -1,7 +1,4 @@
-import fetchMock, {
- type MockResponse,
- type MockResponseFunction,
-} from "fetch-mock";
+import fetchMock from "fetch-mock";
// ===== MOCK CONSTANTS =====
@@ -34,7 +31,7 @@ interface BaseMockConfig {
export interface SamlMockConfig extends BaseMockConfig {}
export interface JwtMockConfig extends BaseMockConfig {
- providerResponse?: MockResponse | MockResponseFunction;
+ providerResponse?: number | Record<string, any>;
}
// ===== MOCK SETUP FUNCTIONS =====
@@ -67,8 +64,8 @@ export const setupMockSamlEndpoints = ({
}: SamlMockConfig = {}) => {
const ssoUrl = new URL("/auth/sso", instanceUrl);
- const ssoInitMock = fetchMock.get(`begin:${ssoUrl.toString()}`, (url) => {
- const urlObj = new URL(url);
+ const ssoInitMock = fetchMock.get(`begin:${ssoUrl.toString()}`, (call) => {
+ const urlObj = new URL(call.url);
const preferredMethod = urlObj.searchParams.get("preferred_method");
if (preferredMethod === "jwt") {
@@ -177,11 +174,11 @@ export const setupMockJwtEndpoints = ({
const ssoUrl = new URL("/auth/sso", instanceUrl);
const ssoInitMock = fetchMock.get(
- (url) =>
- url.startsWith(ssoUrl.toString()) &&
- (url.includes("preferred_method=") || !url.includes("?")),
- (url) => {
- const urlObj = new URL(url);
+ (call) =>
+ call.url.startsWith(ssoUrl.toString()) &&
+ (call.url.includes("preferred_method=") || !call.url.includes("?")),
+ (call) => {
+ const urlObj = new URL(call.url);
const preferredMethod = urlObj.searchParams.get("preferred_method");
if (preferredMethod === "saml") {
@@ -198,20 +195,17 @@ export const setupMockJwtEndpoints = ({
},
);
- const jwtProviderMock = fetchMock.get(
- (url) => url.startsWith(providerUri),
- (url) => {
- const urlObj = new URL(url);
- const responseParam = urlObj.searchParams.get("response");
+ const jwtProviderMock = fetchMock.get(`begin:${providerUri}`, (call) => {
+ const urlObj = new URL(call.url);
+ const responseParam = urlObj.searchParams.get("response");
- if (responseParam === "json") {
- return providerResponse;
- }
+ if (responseParam === "json") {
+ return providerResponse;
+ }
- // Return a default response or error for other cases
- return { status: 400, body: { error: "Invalid request" } };
- },
- );
+ // Return a default response or error for other cases
+ return { status: 400, body: { error: "Invalid request" } };
+ });
const jwtValidationMock = fetchMock.get(
`${instanceUrl}/auth/sso?jwt=${MOCK_VALID_JWT_RESPONSE}`,
diff --git a/enterprise/frontend/src/embedding-sdk/test/sdk-compatibility-warning.unit.spec.tsx b/enterprise/frontend/src/embedding-sdk/test/sdk-compatibility-warning.unit.spec.tsx
index c6daec5e719..22945ef5f5a 100644
--- a/enterprise/frontend/src/embedding-sdk/test/sdk-compatibility-warning.unit.spec.tsx
+++ b/enterprise/frontend/src/embedding-sdk/test/sdk-compatibility-warning.unit.spec.tsx
@@ -1,5 +1,4 @@
import { render } from "@testing-library/react";
-import fetchMock from "fetch-mock";
import {
setupCurrentUserEndpoint,
@@ -60,8 +59,6 @@ const getWarnMessages = (): string[] =>
describe("SDK auth errors", () => {
beforeEach(() => {
- fetchMock.reset();
-
consoleWarnSpy = jest.spyOn(console, "warn").mockImplementation(() => {});
(getEmbeddingSdkVersion as jest.Mock).mockClear();
});
diff --git a/enterprise/frontend/src/embedding-sdk/test/sdk-config-errors/sdk-config-errors.unit.spec.tsx b/enterprise/frontend/src/embedding-sdk/test/sdk-config-errors/sdk-config-errors.unit.spec.tsx
index 93748c178de..9d8d3a105de 100644
--- a/enterprise/frontend/src/embedding-sdk/test/sdk-config-errors/sdk-config-errors.unit.spec.tsx
+++ b/enterprise/frontend/src/embedding-sdk/test/sdk-config-errors/sdk-config-errors.unit.spec.tsx
@@ -1,5 +1,4 @@
import { render, screen, waitFor } from "@testing-library/react";
-import fetchMock from "fetch-mock";
import {
setupCardEndpoints,
@@ -32,8 +31,6 @@ const setup = async (
config: MetabaseAuthConfig,
jwtProviderResponse?: JwtMockConfig["providerResponse"],
) => {
- fetchMock.reset();
-
const { jwtProviderMock } = setupMockJwtEndpoints({
providerResponse: jwtProviderResponse,
});
@@ -57,7 +54,8 @@ const setup = async (
await waitForLoaderToBeRemoved();
- const getLastAuthProviderApiCall = () => jwtProviderMock.lastCall();
+ const getLastAuthProviderApiCall = () =>
+ jwtProviderMock.callHistory.lastCall();
return { getLastAuthProviderApiCall };
};
@@ -86,10 +84,6 @@ const expectErrorMessage = async (message: string) => {
};
describe("SDK auth errors for JWT authentication", () => {
- afterEach(() => {
- jest.resetAllMocks();
- });
-
it("should show a message when the user's JWT server endpoint doesn't return a json object", async () => {
const { getLastAuthProviderApiCall } = await setup(defaultAuthConfig, {
body: "not a json object",
diff --git a/enterprise/frontend/src/embedding/data-picker/DataSelector/tests/DataSourceSelector.unit.spec.tsx b/enterprise/frontend/src/embedding/data-picker/DataSelector/tests/DataSourceSelector.unit.spec.tsx
index 8340f7fb4b1..829a2966abd 100644
--- a/enterprise/frontend/src/embedding/data-picker/DataSelector/tests/DataSourceSelector.unit.spec.tsx
+++ b/enterprise/frontend/src/embedding/data-picker/DataSelector/tests/DataSourceSelector.unit.spec.tsx
@@ -57,16 +57,14 @@ function setup({
selectedTable,
entityTypes,
}: SetupOpts = {}) {
- fetchMock.get(
- {
- url: "path:/api/search",
- query: {
- calculate_available_models: true,
- limit: 0,
- models: ["dataset"],
- },
+ fetchMock.get({
+ url: "path:/api/search",
+ query: {
+ calculate_available_models: true,
+ limit: 0,
+ models: ["dataset"],
},
- {
+ response: {
data: [],
limit: 0,
models: ["dataset"],
@@ -76,7 +74,7 @@ function setup({
total: 1,
available_models: AVAILABLE_MODELS[availableModels],
},
- );
+ });
setupDatabasesEndpoints(
databases,
diff --git a/enterprise/frontend/src/metabase-enterprise/advanced_permissions/components/ImpersonationModal/ImpersonationModal.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/advanced_permissions/components/ImpersonationModal/ImpersonationModal.unit.spec.tsx
index b1720defc0d..f6894b9ade1 100644
--- a/enterprise/frontend/src/metabase-enterprise/advanced_permissions/components/ImpersonationModal/ImpersonationModal.unit.spec.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/advanced_permissions/components/ImpersonationModal/ImpersonationModal.unit.spec.tsx
@@ -42,13 +42,11 @@ const setup = async ({
...databaseDetails,
});
setupDatabaseEndpoints(database);
- fetchMock.get(
- {
- url: `path:/api/database/${databaseId}/metadata`,
- query: { include_hidden: true },
- },
- database,
- );
+ fetchMock.get({
+ url: `path:/api/database/${databaseId}/metadata`,
+ query: { include_hidden: true },
+ response: database,
+ });
setupUserAttributesEndpoint(userAttributes);
if (hasImpersonation) {
diff --git a/enterprise/frontend/src/metabase-enterprise/ai-entity-analysis/components/AIQuestionAnalysisSidebar/AIQuestionAnalysisSidebar.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/ai-entity-analysis/components/AIQuestionAnalysisSidebar/AIQuestionAnalysisSidebar.unit.spec.tsx
index 3951dc8e357..75af8b3e423 100644
--- a/enterprise/frontend/src/metabase-enterprise/ai-entity-analysis/components/AIQuestionAnalysisSidebar/AIQuestionAnalysisSidebar.unit.spec.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/ai-entity-analysis/components/AIQuestionAnalysisSidebar/AIQuestionAnalysisSidebar.unit.spec.tsx
@@ -134,7 +134,7 @@ describe("AIQuestionAnalysisSidebar", () => {
expect(screen.getByText("Filtered analysis")).toBeInTheDocument();
});
- const lastCallRequest = fetchMock.lastCall(
+ const lastCallRequest = fetchMock.callHistory.lastCall(
"path:/api/ee/ai-entity-analysis/analyze-chart",
)?.request;
const body = await lastCallRequest?.json();
diff --git a/enterprise/frontend/src/metabase-enterprise/ai-sql-generation/components/GenerateSqlQueryButton/GenerateSqlQueryButton.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/ai-sql-generation/components/GenerateSqlQueryButton/GenerateSqlQueryButton.unit.spec.tsx
index d2044308be0..038000faca8 100644
--- a/enterprise/frontend/src/metabase-enterprise/ai-sql-generation/components/GenerateSqlQueryButton/GenerateSqlQueryButton.unit.spec.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/ai-sql-generation/components/GenerateSqlQueryButton/GenerateSqlQueryButton.unit.spec.tsx
@@ -106,9 +106,9 @@ describe("GenerateSqlQueryButton", () => {
});
await userEvent.click(screen.getByRole("button"));
await waitFor(() =>
- expect(fetchMock.called("path:/api/ee/ai-sql-generation/generate")).toBe(
- true,
- ),
+ expect(
+ fetchMock.callHistory.called("path:/api/ee/ai-sql-generation/generate"),
+ ).toBe(true),
);
await waitFor(() => expect(screen.getByRole("button")).toBeEnabled());
expect(onGenerateQuery).not.toHaveBeenCalled();
diff --git a/enterprise/frontend/src/metabase-enterprise/audit_app/containers/UnsubscribeUserModal/UnsubscribeUserModal.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/audit_app/containers/UnsubscribeUserModal/UnsubscribeUserModal.unit.spec.tsx
index 1ab4d615cc2..e6ade726aeb 100644
--- a/enterprise/frontend/src/metabase-enterprise/audit_app/containers/UnsubscribeUserModal/UnsubscribeUserModal.unit.spec.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/audit_app/containers/UnsubscribeUserModal/UnsubscribeUserModal.unit.spec.tsx
@@ -1,5 +1,5 @@
import userEvent from "@testing-library/user-event";
-import type { MockResponse, MockResponseFunction } from "fetch-mock";
+import type { UserRouteConfig } from "fetch-mock";
import {
findRequests,
@@ -13,7 +13,7 @@ import { UnsubscribeUserModal } from "./UnsubscribeUserModal";
function setup({
unsubscribeResponse = undefined,
-}: { unsubscribeResponse?: MockResponse | MockResponseFunction } = {}) {
+}: { unsubscribeResponse?: UserRouteConfig } = {}) {
const user = createMockUser({ id: 1, common_name: "John Doe" });
setupUserEndpoints(user);
@@ -38,8 +38,8 @@ describe("UnsubscribeUserModal", () => {
await userEvent.click(await screen.findByText("Unsubscribe"));
await waitFor(async () => {
- const puts = await findRequests("DELETE");
- expect(puts).toHaveLength(1);
+ const deletes = await findRequests("DELETE");
+ expect(deletes).toHaveLength(1);
});
expect(onClose).toHaveBeenCalled();
});
@@ -51,11 +51,13 @@ describe("UnsubscribeUserModal", () => {
await userEvent.click(await screen.findByText("Unsubscribe"));
- expect(await screen.findByText(error.message)).toBeInTheDocument();
await waitFor(async () => {
- const puts = await findRequests("DELETE");
- expect(puts).toHaveLength(1);
+ const deletes = await findRequests("DELETE");
+ expect(deletes).toHaveLength(1);
});
+
+ expect(await screen.findByText(error.message)).toBeInTheDocument();
+
expect(onClose).not.toHaveBeenCalled();
});
});
diff --git a/enterprise/frontend/src/metabase-enterprise/caching/components/StrategyEditorForDatabases.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/caching/components/StrategyEditorForDatabases.unit.spec.tsx
index 388ac7248da..2bdf79c845a 100644
--- a/enterprise/frontend/src/metabase-enterprise/caching/components/StrategyEditorForDatabases.unit.spec.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/caching/components/StrategyEditorForDatabases.unit.spec.tsx
@@ -1,5 +1,4 @@
import userEvent from "@testing-library/user-event";
-import fetchMock from "fetch-mock";
import { act, screen } from "__support__/ui";
import type { SetupOpts } from "metabase/admin/performance/components/test-utils";
@@ -30,10 +29,6 @@ describe("StrategyEditorForDatabases", () => {
setup();
});
- afterEach(() => {
- fetchMock.restore();
- });
-
it("lets user override root strategy on enterprise instance", async () => {
expect(PLUGIN_CACHING.canOverrideRootStrategy).toBe(true);
});
diff --git a/enterprise/frontend/src/metabase-enterprise/database_replication/DatabaseReplicationButton.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/database_replication/DatabaseReplicationButton.unit.spec.tsx
index b8072a48b7a..8f4257a7aaf 100644
--- a/enterprise/frontend/src/metabase-enterprise/database_replication/DatabaseReplicationButton.unit.spec.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/database_replication/DatabaseReplicationButton.unit.spec.tsx
@@ -20,6 +20,15 @@ const setup = ({ databaseId = 1, settings = {} }) => {
}),
});
+ fetchMock.post(
+ "express:/api/ee/database-replication/connection/:databaseId",
+ 200,
+ );
+ fetchMock.delete(
+ "express:/api/ee/database-replication/connection/:databaseId",
+ 200,
+ );
+
return renderWithProviders(
<DatabaseReplicationButton databaseId={databaseId} />,
{
@@ -29,23 +38,6 @@ const setup = ({ databaseId = 1, settings = {} }) => {
};
describe("DatabaseReplicationButton", () => {
- beforeEach(() => {
- fetchMock.reset();
- // Mock the API endpoints
- fetchMock.post(
- "express:/api/ee/database-replication/connection/:databaseId",
- 200,
- );
- fetchMock.delete(
- "express:/api/ee/database-replication/connection/:databaseId",
- 200,
- );
- });
-
- afterEach(() => {
- fetchMock.restore();
- });
-
describe("when database-replication-enabled is false", () => {
it("should not render button", () => {
setup({ settings: { "database-replication-enabled": false } });
diff --git a/enterprise/frontend/src/metabase-enterprise/google_drive/GdriveConnectionModal.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/google_drive/GdriveConnectionModal.unit.spec.tsx
index 98198086383..4259a65c8ff 100644
--- a/enterprise/frontend/src/metabase-enterprise/google_drive/GdriveConnectionModal.unit.spec.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/google_drive/GdriveConnectionModal.unit.spec.tsx
@@ -74,7 +74,6 @@ describe("Google Drive > Connect / Disconnect modal", () => {
status: "not-connected",
});
expect(await screen.findByText("Import Google Sheets")).toBeInTheDocument();
-
expect(
await screen.findByText("[email protected]"),
).toBeInTheDocument();
diff --git a/enterprise/frontend/src/metabase-enterprise/google_drive/GdriveDbMenu.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/google_drive/GdriveDbMenu.unit.spec.tsx
index 60bd1030013..cfa58b94dcb 100644
--- a/enterprise/frontend/src/metabase-enterprise/google_drive/GdriveDbMenu.unit.spec.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/google_drive/GdriveDbMenu.unit.spec.tsx
@@ -210,7 +210,9 @@ describe("Google Drive > DB Menu", () => {
// sync should cause a refetch
expect(await screen.findByText("Syncing")).toBeInTheDocument();
- const syncCalls = fetchMock.calls("path:/api/ee/gsheets/connection/sync");
+ const syncCalls = fetchMock.callHistory.calls(
+ "path:/api/ee/gsheets/connection/sync",
+ );
expect(syncCalls).toHaveLength(1);
await closeMenu();
diff --git a/enterprise/frontend/src/metabase-enterprise/license/components/LicenseAndBillingSettings/LicenseAndBillingSettings.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/license/components/LicenseAndBillingSettings/LicenseAndBillingSettings.unit.spec.tsx
index b8a180df98f..f01bf9ef779 100644
--- a/enterprise/frontend/src/metabase-enterprise/license/components/LicenseAndBillingSettings/LicenseAndBillingSettings.unit.spec.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/license/components/LicenseAndBillingSettings/LicenseAndBillingSettings.unit.spec.tsx
@@ -55,10 +55,10 @@ const setup = async ({
]);
setupPropertiesEndpoints(settings);
- setupTokenStatusEndpoint(
- !!token && token !== "invalid",
- Object.keys(features),
- );
+ setupTokenStatusEndpoint({
+ valid: !!token && token !== "invalid",
+ features: Object.keys(features),
+ });
setupUpdateSettingEndpoint();
renderWithProviders(<LicenseAndBillingSettings />, {
diff --git a/enterprise/frontend/src/metabase-enterprise/license/use-upsell-flow.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/license/use-upsell-flow.unit.spec.tsx
index 356e960021b..de9d21f08ff 100644
--- a/enterprise/frontend/src/metabase-enterprise/license/use-upsell-flow.unit.spec.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/license/use-upsell-flow.unit.spec.tsx
@@ -163,7 +163,7 @@ describe("useUpsellFlow", () => {
);
});
- setupTokenStatusEndpoint(true);
+ setupTokenStatusEndpoint({ valid: true });
view();
await waitFor(() => {
diff --git a/enterprise/frontend/src/metabase-enterprise/metabot/components/MetabotAdmin/MetabotAdminPage.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/metabot/components/MetabotAdmin/MetabotAdminPage.unit.spec.tsx
index 2eb2e277c98..f66a66d54aa 100644
--- a/enterprise/frontend/src/metabase-enterprise/metabot/components/MetabotAdmin/MetabotAdminPage.unit.spec.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/metabot/components/MetabotAdmin/MetabotAdminPage.unit.spec.tsx
@@ -113,10 +113,14 @@ const setup = async (
setupRecentViewsAndSelectionsEndpoints(seedData.recents as RecentItem[]);
metabots.forEach((mb) =>
- setupMetabotPromptSuggestionsEndpoint(mb.id, [], {
- offset: 0,
- limit: 10,
- total: 0,
+ setupMetabotPromptSuggestionsEndpoint({
+ metabotId: mb.id,
+ prompts: [],
+ paginationContext: {
+ offset: 0,
+ limit: 10,
+ total: 0,
+ },
}),
);
@@ -163,8 +167,9 @@ describe("MetabotAdminPage", () => {
await setup(1);
expect(
- fetchMock.calls(`path:/api/ee/metabot-v3/metabot/1/prompt-suggestions`)
- .length,
+ fetchMock.callHistory.calls(
+ `path:/api/ee/metabot-v3/metabot/1/prompt-suggestions`,
+ ).length,
).toEqual(1); // should have loaded prompt suggestions
expect(await screen.findByText("Collection One")).toBeInTheDocument();
@@ -193,8 +198,9 @@ describe("MetabotAdminPage", () => {
).toBeTruthy();
expect(
- fetchMock.calls(`path:/api/ee/metabot-v3/metabot/1/prompt-suggestions`)
- .length,
+ fetchMock.callHistory.calls(
+ `path:/api/ee/metabot-v3/metabot/1/prompt-suggestions`,
+ ).length,
).toEqual(3); // +1 refetch for DELETE, +1 for PUT
});
@@ -233,12 +239,17 @@ describe("MetabotAdminPage", () => {
});
it("should delete the selected collection", async () => {
- await setup(1);
+ const metabotId = 1;
+ await setup(metabotId);
expect(await screen.findByText("Collection One")).toBeInTheDocument();
expect(await screen.findByText("Prompt suggestions")).toBeInTheDocument();
const [deleteButton] = await screen.findAllByLabelText("trash icon");
- setupMetabotEntitiesEndpoint(1, []);
+
+ // simulte the response after a delete
+ fetchMock.modifyRoute(`metabot-${metabotId}-entities-get`, {
+ response: { items: [] },
+ });
await userEvent.click(deleteButton);
const [{ url: deleteUrl }, ...rest] = await findRequests("DELETE");
diff --git a/enterprise/frontend/src/metabase-enterprise/metabot/components/MetabotAdmin/MetabotAdminSuggestedPrompts.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/metabot/components/MetabotAdmin/MetabotAdminSuggestedPrompts.unit.spec.tsx
index f99804a3a4c..b1d1feab389 100644
--- a/enterprise/frontend/src/metabase-enterprise/metabot/components/MetabotAdmin/MetabotAdminSuggestedPrompts.unit.spec.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/metabot/components/MetabotAdmin/MetabotAdminSuggestedPrompts.unit.spec.tsx
@@ -44,19 +44,19 @@ const setup = async (opts?: SetupOpts) => {
mockInitialPage = true,
} = opts ?? {};
- const paginationCtx = {
+ const paginationContext = {
offset: 0,
limit: pageSize,
total: defaultMetabotMockedPrompts.length,
};
const nextPaginationContext = mockInitialPage
- ? setupMetabotPromptSuggestionsEndpoint(
+ ? setupMetabotPromptSuggestionsEndpoint({
metabotId,
- defaultMetabotMockedPrompts,
- paginationCtx,
- )
- : paginationCtx;
+ prompts: defaultMetabotMockedPrompts,
+ paginationContext,
+ })
+ : paginationContext;
const TestComponent = () => (
<MetabotPromptSuggestionPane metabotId={metabotId} pageSize={pageSize} />
@@ -81,26 +81,30 @@ describe("suggested prompts", () => {
});
it("should show loading state", async () => {
- setupMetabotPromptSuggestionsEndpoint(
- FIXED_METABOT_IDS.DEFAULT,
- defaultMetabotMockedPrompts,
- {
+ setupMetabotPromptSuggestionsEndpoint({
+ metabotId: FIXED_METABOT_IDS.DEFAULT,
+ prompts: defaultMetabotMockedPrompts,
+ paginationContext: {
offset: 0,
limit: 3,
total: defaultMetabotMockedPrompts.length,
},
- { delay: 50 },
- );
+ delay: 50,
+ });
await setup({ mockInitialPage: false });
const [loadingRow] = await screen.findAllByTestId("prompt-loading-row");
expect(loadingRow).toBeInTheDocument();
});
it("should show empty state", async () => {
- setupMetabotPromptSuggestionsEndpoint(FIXED_METABOT_IDS.DEFAULT, [], {
- offset: 0,
- limit: 3,
- total: 0,
+ setupMetabotPromptSuggestionsEndpoint({
+ metabotId: FIXED_METABOT_IDS.DEFAULT,
+ prompts: [],
+ paginationContext: {
+ offset: 0,
+ limit: 3,
+ total: 0,
+ },
});
await setup({ mockInitialPage: false });
expect(await screen.findByText("No prompts found.")).toBeInTheDocument();
@@ -121,20 +125,19 @@ describe("suggested prompts", () => {
await expectVisiblePrompts(defaultMetabotMockedPrompts.slice(0, 3));
expect(await screen.findByText(/1 - 3/)).toBeInTheDocument();
- const nextNextPaginationContext = setupMetabotPromptSuggestionsEndpoint(
+ const nextNextPaginationContext = setupMetabotPromptSuggestionsEndpoint({
metabotId,
- defaultMetabotMockedPrompts,
- nextPaginationContext,
- );
+ prompts: defaultMetabotMockedPrompts,
+ paginationContext: nextPaginationContext,
+ });
await nextPage();
await expectVisiblePrompts(defaultMetabotMockedPrompts.slice(3, 6));
expect(await screen.findByText(/4 - 6/)).toBeInTheDocument();
-
- setupMetabotPromptSuggestionsEndpoint(
+ setupMetabotPromptSuggestionsEndpoint({
metabotId,
- defaultMetabotMockedPrompts,
- nextNextPaginationContext,
- );
+ prompts: defaultMetabotMockedPrompts,
+ paginationContext: nextNextPaginationContext,
+ });
await nextPage();
await expectVisiblePrompts(defaultMetabotMockedPrompts.slice(6, 9));
expect(await screen.findByText(/7 - 8/)).toBeInTheDocument();
@@ -176,17 +179,26 @@ describe("suggested prompts", () => {
const [firstPrompt, secondPrompt] = defaultMetabotMockedPrompts;
setupRemoveMetabotPromptSuggestionEndpoint(metabotId, firstPrompt.id);
- setupMetabotPromptSuggestionsEndpoint(
+ setupMetabotPromptSuggestionsEndpoint({
metabotId,
- defaultMetabotMockedPrompts.slice(1),
- {
+ prompts: defaultMetabotMockedPrompts,
+ paginationContext: {
offset: 0,
limit: 1,
total: defaultMetabotMockedPrompts.length,
},
- );
+ });
expect(await screen.findByText(firstPrompt.prompt)).toBeInTheDocument();
+ setupMetabotPromptSuggestionsEndpoint({
+ metabotId,
+ prompts: defaultMetabotMockedPrompts.slice(1),
+ paginationContext: {
+ offset: 0,
+ limit: 1,
+ total: defaultMetabotMockedPrompts.length,
+ },
+ });
await userEvent.click(await screen.findByTestId("prompt-remove"));
expect(await screen.findByText(secondPrompt.prompt)).toBeInTheDocument();
@@ -198,32 +210,32 @@ describe("suggested prompts", () => {
const [firstPrompt] = defaultMetabotMockedPrompts;
setupRemoveMetabotPromptSuggestionEndpoint(metabotId, firstPrompt.id);
- setupMetabotPromptSuggestionsEndpoint(
+
+ expect(await screen.findByText(firstPrompt.prompt)).toBeInTheDocument();
+ setupMetabotPromptSuggestionsEndpoint({
metabotId,
- defaultMetabotMockedPrompts.slice(1),
- {
+ prompts: defaultMetabotMockedPrompts.slice(1),
+ paginationContext: {
offset: 0,
limit: 1,
total: defaultMetabotMockedPrompts.length,
},
- );
-
+ });
// remove a prompt so when we regenerate we can see it came back
- expect(await screen.findByText(firstPrompt.prompt)).toBeInTheDocument();
await userEvent.click(await screen.findByTestId("prompt-remove"));
await waitFor(() => {
expect(screen.queryByText(firstPrompt.prompt)).not.toBeInTheDocument();
});
- setupMetabotPromptSuggestionsEndpoint(
+ setupMetabotPromptSuggestionsEndpoint({
metabotId,
- defaultMetabotMockedPrompts,
- {
+ prompts: defaultMetabotMockedPrompts,
+ paginationContext: {
offset: 0,
limit: 1,
total: defaultMetabotMockedPrompts.length,
},
- );
+ });
// add a delay to endpoint so that loading state can be triggered consistently w/o test flakes
setupRegenerateMetabotPromptSuggestionsEndpoint(metabotId, { delay: 50 });
diff --git a/enterprise/frontend/src/metabase-enterprise/metabot/metabot.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/metabot/metabot.unit.spec.tsx
index bc1df3cf642..b89149d8ede 100644
--- a/enterprise/frontend/src/metabase-enterprise/metabot/metabot.unit.spec.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/metabot/metabot.unit.spec.tsx
@@ -112,8 +112,9 @@ const showMetabot = (dispatch: any) => act(() => dispatch(setVisible(true)));
const getMetabotState = (store: any) => store.getState().plugins.metabotPlugin;
const lastReqBody = async () => {
- const lastCall = fetchMock.lastCall();
- const bodyStr = String(await lastCall?.[1]?.body) || "";
+ const calls = fetchMock.callHistory.calls();
+ const lastCall = calls[calls.length - 1];
+ const bodyStr = String(await lastCall?.options?.body) || "";
return JSON.parse(bodyStr);
};
@@ -304,7 +305,7 @@ describe("metabot", () => {
await userEvent.click(prompt1);
await waitFor(async () => {
expect(
- fetchMock.calls(`path:/api/ee/metabot-v3/v2/agent`),
+ fetchMock.callHistory.calls(`path:/api/ee/metabot-v3/v2/agent`),
).toHaveLength(1);
});
@@ -320,7 +321,7 @@ describe("metabot", () => {
setup({ promptSuggestions: [] });
await waitFor(async () => {
expect(
- fetchMock.calls(
+ fetchMock.callHistory.calls(
`path:/api/ee/metabot-v3/metabot/1/prompt-suggestions`,
),
).toHaveLength(1);
@@ -330,7 +331,7 @@ describe("metabot", () => {
await waitFor(async () => {
expect(
- fetchMock.calls(
+ fetchMock.callHistory.calls(
`path:/api/ee/metabot-v3/metabot/1/prompt-suggestions`,
),
).toHaveLength(2);
@@ -524,14 +525,14 @@ describe("metabot", () => {
await enterChatMessage("Who is your favorite?");
await waitFor(() =>
expect(
- fetchMock.calls(`path:/api/ee/metabot-v3/v2/agent`),
+ fetchMock.callHistory.calls(`path:/api/ee/metabot-v3/v2/agent`),
).toHaveLength(1),
);
// send another message and check that there is proper history
await enterChatMessage("Hi!");
- const lastCall = fetchMock.lastCall();
- const bodyStr = String(await lastCall?.[1]?.body) || "";
+ const lastCall = fetchMock.callHistory.lastCall();
+ const bodyStr = String(lastCall?.response?.body) || "";
const sentHistory = JSON.parse(bodyStr)?.history;
expect(sentHistory).toEqual(whoIsYourFavoriteResponse.history);
});
@@ -547,7 +548,7 @@ describe("metabot", () => {
await enterChatMessage("Who is your favorite?");
await waitFor(() =>
expect(
- fetchMock.calls(`path:/api/ee/metabot-v3/v2/agent`),
+ fetchMock.callHistory.calls(`path:/api/ee/metabot-v3/v2/agent`),
).toHaveLength(1),
);
@@ -555,8 +556,8 @@ describe("metabot", () => {
hideMetabot(store.dispatch);
showMetabot(store.dispatch);
await enterChatMessage("Hi!");
- const lastCall = fetchMock.lastCall();
- const bodyStr = String(await lastCall?.[1]?.body) || "";
+ const lastCall = fetchMock.callHistory.lastCall();
+ const bodyStr = String(lastCall?.response?.body) || "";
const sentHistory = JSON.parse(bodyStr)?.history;
expect(sentHistory).toEqual(whoIsYourFavoriteResponse.history);
});
@@ -572,7 +573,7 @@ describe("metabot", () => {
await enterChatMessage("Who is your favorite?");
await waitFor(() =>
expect(
- fetchMock.calls(`path:/api/ee/metabot-v3/v2/agent`),
+ fetchMock.callHistory.calls(`path:/api/ee/metabot-v3/v2/agent`),
).toHaveLength(1),
);
diff --git a/enterprise/frontend/src/metabase-enterprise/snippets/components/SnippetCollectionFormModal.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/snippets/components/SnippetCollectionFormModal.unit.spec.tsx
index 2e057ddb905..b0715049394 100644
--- a/enterprise/frontend/src/metabase-enterprise/snippets/components/SnippetCollectionFormModal.unit.spec.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/snippets/components/SnippetCollectionFormModal.unit.spec.tsx
@@ -25,35 +25,31 @@ type SetupOpts = {
async function setup({ folder = {}, onClose = jest.fn() }: SetupOpts = {}) {
if (folder.id) {
- fetchMock.get(
- {
- url: `path:/api/collection/${folder.id}`,
- },
- folder,
- );
+ fetchMock.get(`path:/api/collection/${folder.id}`, folder);
- fetchMock.put(`path:/api/collection/${folder.id}`, async (url) => {
+ fetchMock.put(`path:/api/collection/${folder.id}`, async (call) => {
return createMockCollection(
- await fetchMock.lastCall(url)?.request?.json(),
+ await fetchMock.callHistory.lastCall(call.url)?.request?.json(),
);
});
}
- fetchMock.get(
- { url: "path:/api/collection/root", query: { namespace: "snippets" } },
- TOP_SNIPPETS_FOLDER,
- );
+ fetchMock.get({
+ url: "path:/api/collection/root",
+ query: { namespace: "snippets" },
+ response: TOP_SNIPPETS_FOLDER,
+ });
- fetchMock.get(
- {
- url: "path:/api/collection",
- query: { namespace: "snippets" },
- },
- [TOP_SNIPPETS_FOLDER],
- );
+ fetchMock.get({
+ url: "path:/api/collection",
+ query: { namespace: "snippets" },
+ response: [TOP_SNIPPETS_FOLDER],
+ });
- fetchMock.post("path:/api/collection", async (url) => {
- return createMockCollection(await fetchMock.lastCall(url)?.request?.json());
+ fetchMock.post("path:/api/collection", async (call) => {
+ return createMockCollection(
+ await fetchMock.callHistory.lastCall(call.url)?.request?.json(),
+ );
});
renderWithProviders(
diff --git a/enterprise/frontend/src/metabase-enterprise/upload_management/UploadManagement.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/upload_management/UploadManagement.unit.spec.tsx
index 05d97e5625e..3aa17d7a4a2 100644
--- a/enterprise/frontend/src/metabase-enterprise/upload_management/UploadManagement.unit.spec.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/upload_management/UploadManagement.unit.spec.tsx
@@ -120,10 +120,9 @@ describe("uploadManagementTable", () => {
);
await waitFor(() => {
- const [url, details] = fetchMock.calls()[1]; // next to last call should be the DELETE request
-
- expect(details?.method).toEqual("DELETE");
- return expect(url).toContain("?archive-cards=true");
+ const call = fetchMock.callHistory.calls()[1]; // next to last call should be the DELETE request
+ expect(call.request?.method).toEqual("DELETE");
+ return expect(call.url).toContain("?archive-cards=true");
});
});
@@ -151,10 +150,9 @@ describe("uploadManagementTable", () => {
);
await waitFor(() => {
- const [url, details] = fetchMock.calls()[1]; // next to last call should be the DELETE request
-
- expect(details?.method).toEqual("DELETE");
- return expect(url).toContain("?archive-cards=false");
+ const call = fetchMock.callHistory.calls()[1]; // next to last call should be the DELETE request
+ expect(call.request?.method).toEqual("DELETE");
+ return expect(call.url).toContain("?archive-cards=false");
});
});
@@ -176,13 +174,9 @@ describe("uploadManagementTable", () => {
await waitFor(() =>
expect(screen.queryByText("Delete")).not.toBeInTheDocument(),
);
- expect(fetchMock.calls().map((call) => call?.[1]?.method)).toEqual([
- "GET",
- "DELETE",
- "DELETE",
- "DELETE",
- "GET",
- ]);
+ expect(
+ fetchMock.callHistory.calls().map((call) => call.request?.method),
+ ).toEqual(["GET", "DELETE", "DELETE", "DELETE", "GET"]);
});
it("should show a single-success toast", async () => {
diff --git a/frontend/src/metabase/actions/components/ActionViz/Action.unit.spec.tsx b/frontend/src/metabase/actions/components/ActionViz/Action.unit.spec.tsx
index 0dc7c8d0ff0..b810f1d21a1 100644
--- a/frontend/src/metabase/actions/components/ActionViz/Action.unit.spec.tsx
+++ b/frontend/src/metabase/actions/components/ActionViz/Action.unit.spec.tsx
@@ -303,10 +303,10 @@ describe("Actions > ActionViz > Action", () => {
);
await waitFor(async () => {
- expect(fetchMock.called(ACTION_EXEC_MOCK_PATH)).toBe(true);
+ expect(fetchMock.callHistory.called(ACTION_EXEC_MOCK_PATH)).toBe(true);
});
- const call = fetchMock.lastCall(ACTION_EXEC_MOCK_PATH);
+ const call = fetchMock.callHistory.lastCall(ACTION_EXEC_MOCK_PATH);
expect(await call?.request?.json()).toEqual({
modelId: ACTION_MODEL_ID,
parameters: {
@@ -375,16 +375,12 @@ describe("Actions > ActionViz > Action", () => {
const updatedTitle = "Test action title";
await setup();
- fetchMock.putOnce(
- `path:/api/action/${ACTION.id}`,
- {
+ fetchMock.modifyRoute(`action-${ACTION.id}-put`, {
+ response: {
...ACTION,
name: updatedTitle,
},
- {
- overwriteRoutes: true,
- },
- );
+ });
await userEvent.click(screen.getByText("Click me"));
@@ -401,7 +397,9 @@ describe("Actions > ActionViz > Action", () => {
await userEvent.click(within(editorModal).getByText("Update"));
- expect(fetchMock.called(`path:/api/action/${ACTION.id}`)).toBe(true);
+ expect(
+ fetchMock.callHistory.called(`path:/api/action/${ACTION.id}`),
+ ).toBe(true);
await waitFor(() => {
expect(screen.queryByTestId("action-creator")).not.toBeInTheDocument();
@@ -478,7 +476,7 @@ describe("Actions > ActionViz > Action", () => {
await userEvent.click(screen.getByRole("button", { name: ACTION.name }));
await waitFor(async () => {
- const call = fetchMock.lastCall(ACTION_EXEC_MOCK_PATH);
+ const call = fetchMock.callHistory.lastCall(ACTION_EXEC_MOCK_PATH);
expect(await call?.request?.json()).toEqual(expectedBody);
});
});
@@ -505,7 +503,7 @@ describe("Actions > ActionViz > Action", () => {
await userEvent.click(screen.getByRole("button", { name: ACTION.name }));
await waitFor(async () => {
- const call = fetchMock.lastCall(ACTION_EXEC_MOCK_PATH);
+ const call = fetchMock.callHistory.lastCall(ACTION_EXEC_MOCK_PATH);
expect(await call?.request?.json()).toEqual(expectedBody);
});
});
diff --git a/frontend/src/metabase/actions/containers/ActionCreator/tests/ActionCreator-Sharing.unit.spec.tsx b/frontend/src/metabase/actions/containers/ActionCreator/tests/ActionCreator-Sharing.unit.spec.tsx
index 2e09aab6c1f..692a57f5d1c 100644
--- a/frontend/src/metabase/actions/containers/ActionCreator/tests/ActionCreator-Sharing.unit.spec.tsx
+++ b/frontend/src/metabase/actions/containers/ActionCreator/tests/ActionCreator-Sharing.unit.spec.tsx
@@ -81,11 +81,10 @@ describe("ActionCreator > Sharing", () => {
screen.queryByRole("textbox", { name: "Public action form URL" }),
).not.toBeInTheDocument();
- fetchMock.getOnce(
- `path:/api/action/${privateAction.id}`,
- { ...privateAction, public_uuid: mockUuid },
- { overwriteRoutes: true },
- );
+ fetchMock.modifyRoute(`action-${privateAction.id}-get`, {
+ response: () => ({ ...privateAction, public_uuid: mockUuid }),
+ });
+
await userEvent.click(
screen.getByRole("switch", { name: "Make public" }),
);
@@ -110,11 +109,6 @@ describe("ActionCreator > Sharing", () => {
screen.getByRole("button", { name: "Action settings" }),
);
- await waitFor(() => {
- expect(
- screen.getByTestId("sidebar-header-title"),
- ).toBeInTheDocument();
- });
const headerTitle = await screen.findByTestId("sidebar-header-title");
expect(headerTitle).toBeInTheDocument();
expect(headerTitle).toHaveTextContent("Action settings");
@@ -132,11 +126,9 @@ describe("ActionCreator > Sharing", () => {
screen.getByRole("heading", { name: "Disable this public link?" }),
).toBeInTheDocument();
- fetchMock.getOnce(
- `path:/api/action/${publicAction.id}`,
- { ...publicAction, public_uuid: null },
- { overwriteRoutes: true },
- );
+ fetchMock.modifyRoute(`action-${publicAction.id}-get`, {
+ response: () => ({ ...publicAction, public_uuid: null }),
+ });
await userEvent.click(screen.getByRole("button", { name: "Yes" }));
await waitFor(() => {
diff --git a/frontend/src/metabase/actions/containers/ActionCreator/tests/common.tsx b/frontend/src/metabase/actions/containers/ActionCreator/tests/common.tsx
index 4c59fc4b211..34ca97f721b 100644
--- a/frontend/src/metabase/actions/containers/ActionCreator/tests/common.tsx
+++ b/frontend/src/metabase/actions/containers/ActionCreator/tests/common.tsx
@@ -57,11 +57,19 @@ export async function setup({
setupCardsEndpoints(model ? [model] : []);
if (action) {
- fetchMock.get(`path:/api/action/${action.id}`, action);
- fetchMock.delete(`path:/api/action/${action.id}/public_link`, 204);
- fetchMock.post(`path:/api/action/${action.id}/public_link`, {
- uuid: "mock-uuid",
+ fetchMock.get(`path:/api/action/${action.id}`, action, {
+ name: `action-${action.id}-get`,
});
+ fetchMock.delete(`path:/api/action/${action.id}/public_link`, 204, {
+ name: `public-link-${action.id}-delete`,
+ });
+ fetchMock.post(
+ `path:/api/action/${action.id}/public_link`,
+ {
+ uuid: "mock-uuid",
+ },
+ { name: `public-link-${action.id}-post` },
+ );
}
renderWithProviders(
@@ -86,7 +94,9 @@ export async function setup({
if (action) {
await waitFor(() => {
expect(
- fetchMock.calls(`path:/api/action/${action.id}`, { method: "GET" }),
+ fetchMock.callHistory.calls(`path:/api/action/${action.id}`, {
+ method: "GET",
+ }),
).toHaveLength(1);
});
}
diff --git a/frontend/src/metabase/actions/containers/ActionCreatorModal/ActionCreatorModal.unit.spec.tsx b/frontend/src/metabase/actions/containers/ActionCreatorModal/ActionCreatorModal.unit.spec.tsx
index 11df0674ca7..9d0e657e4a5 100644
--- a/frontend/src/metabase/actions/containers/ActionCreatorModal/ActionCreatorModal.unit.spec.tsx
+++ b/frontend/src/metabase/actions/containers/ActionCreatorModal/ActionCreatorModal.unit.spec.tsx
@@ -80,10 +80,6 @@ async function setup({
}
describe("actions > containers > ActionCreatorModal", () => {
- afterEach(() => {
- fetchMock.reset();
- });
-
it("renders correctly", async () => {
const initialRoute = `/model/${MODEL.id}/detail/actions/${ACTION.id}`;
await setup({ initialRoute });
@@ -289,14 +285,12 @@ describe("actions > containers > ActionCreatorModal", () => {
await userEvent.type(screen.getByDisplayValue(action.name), "a change");
await userEvent.tab(); // need to click away from the input to re-compute the isDirty flag
- fetchMock.put(
- `path:/api/action/${action.id}`,
- {
+ fetchMock.modifyRoute(`action-${action.id}-put`, {
+ response: {
...action,
name: `${action.name}a change`,
},
- { overwriteRoutes: true },
- );
+ });
await userEvent.click(screen.getByRole("button", { name: "Update" }));
diff --git a/frontend/src/metabase/admin/databases/components/DatabaseConnectionInfoSection/DatabaseConnectionInfoSection.unit.spec.tsx b/frontend/src/metabase/admin/databases/components/DatabaseConnectionInfoSection/DatabaseConnectionInfoSection.unit.spec.tsx
index d0c8e2e58dc..4a38aab9cda 100644
--- a/frontend/src/metabase/admin/databases/components/DatabaseConnectionInfoSection/DatabaseConnectionInfoSection.unit.spec.tsx
+++ b/frontend/src/metabase/admin/databases/components/DatabaseConnectionInfoSection/DatabaseConnectionInfoSection.unit.spec.tsx
@@ -66,11 +66,9 @@ describe("DatabaseConnectionInfoSection", () => {
it("should show error message if healthcheck returns errors", async () => {
setup({
mockEndpointsCb: (database) => {
- fetchMock.get(
- `path:/api/database/${database.id}/healthcheck`,
- { body: { status: "error", message: "Test failure" } },
- { overwriteRoutes: true },
- );
+ fetchMock.modifyRoute(`database-${database.id}-healthcheck`, {
+ response: { body: { status: "error", message: "Test failure" } },
+ });
},
});
expect(await screen.findByText("Test failure")).toBeInTheDocument();
@@ -79,11 +77,9 @@ describe("DatabaseConnectionInfoSection", () => {
it("should show error message if healthcheck HTTP request fails", async () => {
setup({
mockEndpointsCb: (database) => {
- fetchMock.get(
- `path:/api/database/${database.id}/healthcheck`,
- { status: 500 },
- { overwriteRoutes: true },
- );
+ fetchMock.modifyRoute(`database-${database.id}-healthcheck`, {
+ response: { status: 500 },
+ });
},
});
expect(
@@ -98,7 +94,9 @@ describe("DatabaseConnectionInfoSection", () => {
await userEvent.click(screen.getByText(/Sync database schema/i));
await waitFor(() => {
expect(
- fetchMock.called(`path:/api/database/${database.id}/sync_schema`),
+ fetchMock.callHistory.called(
+ `path:/api/database/${database.id}/sync_schema`,
+ ),
).toBe(true);
});
});
@@ -108,7 +106,9 @@ describe("DatabaseConnectionInfoSection", () => {
await userEvent.click(screen.getByText(/Re-scan field values/i));
await waitFor(() => {
expect(
- fetchMock.called(`path:/api/database/${database.id}/rescan_values`),
+ fetchMock.callHistory.called(
+ `path:/api/database/${database.id}/rescan_values`,
+ ),
).toBe(true);
});
});
@@ -146,8 +146,9 @@ describe("DatabaseConnectionInfoSection", () => {
);
expect(
- fetchMock.calls(`path:/api/database/${database.id}/dismiss_spinner`)
- .length,
+ fetchMock.callHistory.calls(
+ `path:/api/database/${database.id}/dismiss_spinner`,
+ ).length,
).toBe(1);
});
});
diff --git a/frontend/src/metabase/admin/databases/components/DatabaseDangerZoneSection/DatabaseDangerZoneSection.unit.spec.tsx b/frontend/src/metabase/admin/databases/components/DatabaseDangerZoneSection/DatabaseDangerZoneSection.unit.spec.tsx
index e7e8f279d81..a72ce3e9f9c 100644
--- a/frontend/src/metabase/admin/databases/components/DatabaseDangerZoneSection/DatabaseDangerZoneSection.unit.spec.tsx
+++ b/frontend/src/metabase/admin/databases/components/DatabaseDangerZoneSection/DatabaseDangerZoneSection.unit.spec.tsx
@@ -81,7 +81,9 @@ describe("DatabaseDangerZoneSection", () => {
await waitFor(() => {
expect(
- fetchMock.called(`path:/api/database/${database.id}/discard_values`),
+ fetchMock.callHistory.called(
+ `path:/api/database/${database.id}/discard_values`,
+ ),
).toBe(true);
});
});
@@ -98,7 +100,9 @@ describe("DatabaseDangerZoneSection", () => {
expect(getDiscardFieldValuesConfirmModal()).not.toBeInTheDocument();
expect(
- fetchMock.called(`path:/api/database/${database.id}/discard_values`),
+ fetchMock.callHistory.called(
+ `path:/api/database/${database.id}/discard_values`,
+ ),
).toBe(false);
});
diff --git a/frontend/src/metabase/admin/databases/containers/DatabaseConnectionModal.unit.spec.tsx b/frontend/src/metabase/admin/databases/containers/DatabaseConnectionModal.unit.spec.tsx
index 70e8465a0c0..3249bb481b6 100644
--- a/frontend/src/metabase/admin/databases/containers/DatabaseConnectionModal.unit.spec.tsx
+++ b/frontend/src/metabase/admin/databases/containers/DatabaseConnectionModal.unit.spec.tsx
@@ -201,14 +201,12 @@ describe("DatabaseConnectionModal", () => {
);
// need to add an id to the mocked db result so redirect can go the the correct location
- fetchMock.post(
- "path:/api/database",
- async (url) => {
- const lastCall = fetchMock.lastCall(url);
+ fetchMock.modifyRoute("database-post", {
+ response: async (call) => {
+ const lastCall = fetchMock.callHistory.lastCall(call.url);
return { ...(await lastCall?.request?.json()), id: 1 };
},
- { overwriteRoutes: true },
- );
+ });
await userEvent.click(await screen.findByText("Save"));
diff --git a/frontend/src/metabase/admin/people/containers/EditUserModal/test/common.unit.spec.tsx b/frontend/src/metabase/admin/people/containers/EditUserModal/test/common.unit.spec.tsx
index 9b415e62cd0..bd6251b2ea7 100644
--- a/frontend/src/metabase/admin/people/containers/EditUserModal/test/common.unit.spec.tsx
+++ b/frontend/src/metabase/admin/people/containers/EditUserModal/test/common.unit.spec.tsx
@@ -34,7 +34,9 @@ describe("Edit user modal", () => {
await userEvent.click(submitButton);
- const call = fetchMock.lastCall("path:/api/user/97", { method: "PUT" });
+ const call = fetchMock.callHistory.lastCall("path:/api/user/97", {
+ method: "PUT",
+ });
const req = await call?.request?.json();
@@ -65,7 +67,9 @@ describe("Edit user modal", () => {
await userEvent.type(firstNameField, "Madonna");
await userEvent.click(submitButton);
- const call = fetchMock.lastCall("path:/api/user/11", { method: "PUT" });
+ const call = fetchMock.callHistory.lastCall("path:/api/user/11", {
+ method: "PUT",
+ });
const req = await call?.request?.json();
expect(req).toEqual({
@@ -94,7 +98,9 @@ describe("Edit user modal", () => {
await userEvent.type(emailField, "[email protected]");
await userEvent.click(submitButton);
- const call = fetchMock.lastCall("path:/api/user/11", { method: "PUT" });
+ const call = fetchMock.callHistory.lastCall("path:/api/user/11", {
+ method: "PUT",
+ });
const req = await call?.request?.json();
expect(req).toEqual({
@@ -124,7 +130,9 @@ describe("Edit user modal", () => {
await userEvent.clear(lastNameField);
await userEvent.click(submitButton);
- const call = fetchMock.lastCall("path:/api/user/11", { method: "PUT" });
+ const call = fetchMock.callHistory.lastCall("path:/api/user/11", {
+ method: "PUT",
+ });
const req = await call?.request?.json();
expect(req).toEqual({
diff --git a/frontend/src/metabase/admin/people/containers/EditUserModal/test/enterprise.unit.spec.tsx b/frontend/src/metabase/admin/people/containers/EditUserModal/test/enterprise.unit.spec.tsx
index 6260964e5ce..2a87a71652b 100644
--- a/frontend/src/metabase/admin/people/containers/EditUserModal/test/enterprise.unit.spec.tsx
+++ b/frontend/src/metabase/admin/people/containers/EditUserModal/test/enterprise.unit.spec.tsx
@@ -25,7 +25,9 @@ describe("EditUserModal - enterprise", () => {
await userEvent.click(submitButton);
- const call = fetchMock.lastCall("path:/api/user/97", { method: "PUT" });
+ const call = fetchMock.callHistory.lastCall("path:/api/user/97", {
+ method: "PUT",
+ });
const req = await call?.request?.json();
expect(req).toEqual({
@@ -65,7 +67,9 @@ describe("EditUserModal - enterprise", () => {
await userEvent.click(submitButton);
- const call = fetchMock.lastCall("path:/api/user/97", { method: "PUT" });
+ const call = fetchMock.callHistory.lastCall("path:/api/user/97", {
+ method: "PUT",
+ });
const req = await call?.request?.json();
expect(req).toEqual({
diff --git a/frontend/src/metabase/admin/performance/components/test-utils.tsx b/frontend/src/metabase/admin/performance/components/test-utils.tsx
index 195fbeb736a..80376b94429 100644
--- a/frontend/src/metabase/admin/performance/components/test-utils.tsx
+++ b/frontend/src/metabase/admin/performance/components/test-utils.tsx
@@ -43,7 +43,7 @@ export const setupStrategyEditorForDatabases = ({
if (hasEnterprisePlugins) {
setupEnterprisePlugins();
}
- setupTokenStatusEndpoint(hasEnterprisePlugins);
+ setupTokenStatusEndpoint({ valid: hasEnterprisePlugins });
const cacheConfigs = [
createMockCacheConfigWithMultiplierStrategy({ model_id: 1 }),
diff --git a/frontend/src/metabase/admin/permissions/pages/CollectionPermissionsPage/tests/common.unit.spec.tsx b/frontend/src/metabase/admin/permissions/pages/CollectionPermissionsPage/tests/common.unit.spec.tsx
index 3b81a84a8b6..4d3c31e2c11 100644
--- a/frontend/src/metabase/admin/permissions/pages/CollectionPermissionsPage/tests/common.unit.spec.tsx
+++ b/frontend/src/metabase/admin/permissions/pages/CollectionPermissionsPage/tests/common.unit.spec.tsx
@@ -89,11 +89,14 @@ describe("Admin > CollectionPermissionsPage", () => {
expect(await screen.findAllByText("View")).toHaveLength(2);
expect(screen.queryByText("No access")).not.toBeInTheDocument();
- const lastRequest = await fetchMock
- .lastCall("path:/api/collection/graph", {
- method: "PUT",
- })
- ?.request?.json();
+ const lastCall = fetchMock.callHistory.lastCall(
+ "path:/api/collection/graph",
+ { method: "PUT" },
+ );
+ const lastRequest =
+ typeof lastCall?.options?.body === "string"
+ ? JSON.parse(lastCall?.options?.body)
+ : undefined;
expect(lastRequest).toEqual({
...defaultPermissionsGraph,
@@ -144,11 +147,14 @@ describe("Admin > CollectionPermissionsPage", () => {
expect(await screen.findAllByText("Curate")).toHaveLength(3);
expect(screen.queryByText("No access")).not.toBeInTheDocument();
- const lastRequest = await fetchMock
- .lastCall("path:/api/collection/graph", {
- method: "PUT",
- })
- ?.request?.json();
+ const lastCall = fetchMock.callHistory.lastCall(
+ "path:/api/collection/graph",
+ { method: "PUT" },
+ );
+ const lastRequest =
+ typeof lastCall?.options?.body === "string"
+ ? JSON.parse(lastCall?.options?.body)
+ : undefined;
expect(lastRequest).toEqual({
...defaultPermissionsGraph,
diff --git a/frontend/src/metabase/admin/permissions/pages/CollectionPermissionsPage/tests/enterprise.unit.spec.tsx b/frontend/src/metabase/admin/permissions/pages/CollectionPermissionsPage/tests/enterprise.unit.spec.tsx
index 03f69ad26d1..4badd8c47e2 100644
--- a/frontend/src/metabase/admin/permissions/pages/CollectionPermissionsPage/tests/enterprise.unit.spec.tsx
+++ b/frontend/src/metabase/admin/permissions/pages/CollectionPermissionsPage/tests/enterprise.unit.spec.tsx
@@ -101,11 +101,11 @@ describe("Admin > CollectionPermissionsPage (enterprise)", () => {
expect(await screen.findAllByText("View")).toHaveLength(2);
expect(await screen.findByText("No access")).toBeInTheDocument();
- const lastRequest = await fetchMock
- .lastCall("path:/api/collection/graph", {
- method: "PUT",
- })
- ?.request?.json();
+ const calls = fetchMock.callHistory.calls("path:/api/collection/graph", {
+ method: "PUT",
+ });
+ const lastCall = calls[calls.length - 1];
+ const lastRequest = await lastCall?.request?.json();
expect(lastRequest).toEqual({
...iaPermissionsGraph,
diff --git a/frontend/src/metabase/admin/permissions/pages/CollectionPermissionsPage/tests/setup.tsx b/frontend/src/metabase/admin/permissions/pages/CollectionPermissionsPage/tests/setup.tsx
index 3375d8f2aaf..2297c02cd4c 100644
--- a/frontend/src/metabase/admin/permissions/pages/CollectionPermissionsPage/tests/setup.tsx
+++ b/frontend/src/metabase/admin/permissions/pages/CollectionPermissionsPage/tests/setup.tsx
@@ -136,7 +136,7 @@ export function setup({
rootCollection,
});
- setupTokenStatusEndpoint(true);
+ setupTokenStatusEndpoint({ valid: true });
setupCollectionPermissionsGraphEndpoint(permissionsGraph);
setupGroupsEndpoint(permissionGroups);
diff --git a/frontend/src/metabase/admin/settings/components/ApiKeys/ManageApiKeys.unit.spec.tsx b/frontend/src/metabase/admin/settings/components/ApiKeys/ManageApiKeys.unit.spec.tsx
index 0b5c42c7bdb..3819bf66c75 100644
--- a/frontend/src/metabase/admin/settings/components/ApiKeys/ManageApiKeys.unit.spec.tsx
+++ b/frontend/src/metabase/admin/settings/components/ApiKeys/ManageApiKeys.unit.spec.tsx
@@ -68,7 +68,7 @@ async function setup(
await waitForLoaderToBeRemoved();
await waitFor(() => {
expect(
- fetchMock.calls("path:/api/api-key", { method: "GET" }),
+ fetchMock.callHistory.calls("path:/api/api-key", { method: "GET" }),
).toHaveLength(1);
});
}
@@ -117,17 +117,20 @@ describe("ManageApiKeys", () => {
expect(
await screen.findByText("Copy and save the API key"),
).toBeInTheDocument();
- expect(
- await fetchMock
- .lastCall("path:/api/api-key", { method: "POST" })
- ?.request?.json(),
- ).toEqual({ name: "New key", group_id: 5 });
+ const calls = fetchMock.callHistory.calls("path:/api/api-key", {
+ method: "POST",
+ });
+ const lastCall = calls[calls.length - 1];
+ expect(await lastCall?.request?.json()).toEqual({
+ name: "New key",
+ group_id: 5,
+ });
await userEvent.click(screen.getByRole("button", { name: "Done" }));
await waitFor(() =>
expect(
- fetchMock.calls("path:/api/api-key", { method: "GET" }),
+ fetchMock.callHistory.calls("path:/api/api-key", { method: "GET" }),
).toHaveLength(2),
);
});
@@ -154,11 +157,13 @@ describe("ManageApiKeys", () => {
await screen.findByText("Copy and save the API key");
expect(
- await fetchMock.lastCall(REGEN_URL, { method: "PUT" })?.request?.json(),
+ await fetchMock.callHistory
+ .lastCall(REGEN_URL, { method: "PUT" })
+ ?.request?.json(),
).toEqual({});
await waitFor(() => {
expect(
- fetchMock.calls("path:/api/api-key", { method: "GET" }),
+ fetchMock.callHistory.calls("path:/api/api-key", { method: "GET" }),
).toHaveLength(2);
});
});
@@ -188,12 +193,14 @@ describe("ManageApiKeys", () => {
await userEvent.click(screen.getByRole("button", { name: "Save" }));
await waitFor(async () => {
expect(
- await fetchMock.lastCall(EDIT_URL, { method: "PUT" })?.request?.json(),
+ await fetchMock.callHistory
+ .lastCall(EDIT_URL, { method: "PUT" })
+ ?.request?.json(),
).toEqual({ group_id: 5, name: "My Key" });
});
await waitFor(() => {
expect(
- fetchMock.calls("path:/api/api-key", { method: "GET" }),
+ fetchMock.callHistory.calls("path:/api/api-key", { method: "GET" }),
).toHaveLength(2);
});
});
@@ -214,11 +221,13 @@ describe("ManageApiKeys", () => {
await screen.findByRole("button", { name: "Delete API key" }),
);
await waitFor(() => {
- expect(fetchMock.calls(DELETE_URL, { method: "DELETE" })).toHaveLength(1);
+ expect(
+ fetchMock.callHistory.calls(DELETE_URL, { method: "DELETE" }),
+ ).toHaveLength(1);
});
await waitFor(() => {
expect(
- fetchMock.calls("path:/api/api-key", { method: "GET" }),
+ fetchMock.callHistory.calls("path:/api/api-key", { method: "GET" }),
).toHaveLength(2);
});
});
diff --git a/frontend/src/metabase/admin/settings/components/CloudPanel/CloudPanel.unit.spec.tsx b/frontend/src/metabase/admin/settings/components/CloudPanel/CloudPanel.unit.spec.tsx
index ae2a2d3b6e9..cb33511710b 100644
--- a/frontend/src/metabase/admin/settings/components/CloudPanel/CloudPanel.unit.spec.tsx
+++ b/frontend/src/metabase/admin/settings/components/CloudPanel/CloudPanel.unit.spec.tsx
@@ -1,5 +1,5 @@
import userEvent from "@testing-library/user-event";
-import fetchMock, { type MockResponse } from "fetch-mock";
+import fetchMock, { type UserRouteConfig } from "fetch-mock";
import { setupPropertiesEndpoints } from "__support__/server-mocks";
import { renderWithProviders, screen, waitFor, within } from "__support__/ui";
@@ -42,10 +42,6 @@ describe("CloudPanel", () => {
});
});
- afterEach(() => {
- fetchMock.reset();
- });
-
it("should be able to successfully go through migration flow", async () => {
const migrationProgressResponses = [
INIT_RESPONSE,
@@ -102,7 +98,7 @@ describe("CloudPanel", () => {
await waitFor(() => {
expect(
- fetchMock.called(`path:/api/cloud-migration/cancel`, {
+ fetchMock.callHistory.called(`path:/api/cloud-migration/cancel`, {
method: "PUT",
}),
).toBeTruthy();
@@ -128,7 +124,9 @@ describe("CloudPanel", () => {
});
it("should be able to start a new migration after a failed migration", async () => {
- fetchMock.get(`path:/api/cloud-migration`, ERROR_RESPONSE);
+ fetchMock.get(`path:/api/cloud-migration`, ERROR_RESPONSE, {
+ name: "cloud-migration-get",
+ });
const { mockMigrationStart, metabaseStoreLink } = setup();
await expectErrorState();
@@ -149,7 +147,9 @@ describe("CloudPanel", () => {
});
it("should be able to start a new migration after a successful migration", async () => {
- fetchMock.get(`path:/api/cloud-migration`, DONE_RESPONSE);
+ fetchMock.get(`path:/api/cloud-migration`, DONE_RESPONSE, {
+ name: "cloud-migration-get",
+ });
const { mockMigrationStart, metabaseStoreLink } = setup();
@@ -271,7 +271,9 @@ const expectErrorState = async () => {
).toBeInTheDocument();
};
-const startMigration = async (migrationResponses: MockResponse[]) => {
+const startMigration = async (
+ migrationResponses: UserRouteConfig["response"][],
+) => {
fetchMockCloudMigrationGetSequence(migrationResponses);
const { mockMigrationStart, store, metabaseStoreLink } = setup();
@@ -286,17 +288,17 @@ const startMigration = async (migrationResponses: MockResponse[]) => {
return { store, metabaseStoreLink };
};
-function fetchMockCloudMigrationGetSequence(responses: MockResponse[]) {
+function fetchMockCloudMigrationGetSequence(
+ responses: UserRouteConfig["response"][],
+) {
let called = 0;
-
+ fetchMock.removeRoute("cloud-migration-get");
return fetchMock.get(
`path:/api/cloud-migration`,
() => {
// hold the last response
return responses[Math.min(called++, responses.length - 1)];
},
- {
- overwriteRoutes: true,
- },
+ { name: "cloud-migration-get" },
);
}
diff --git a/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSdkSettings/tests/setup.tsx b/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSdkSettings/tests/setup.tsx
index 90a6a7d4acf..1d673dd997f 100644
--- a/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSdkSettings/tests/setup.tsx
+++ b/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSdkSettings/tests/setup.tsx
@@ -53,7 +53,7 @@ export async function setup({
if (hasEnterprisePlugins) {
setupEnterprisePlugins();
- setupTokenStatusEndpoint(true);
+ setupTokenStatusEndpoint({ valid: true });
}
setupPropertiesEndpoints(settings);
diff --git a/frontend/src/metabase/admin/settings/components/SettingsPages/GeneralSettingsPage.unit.spec.tsx b/frontend/src/metabase/admin/settings/components/SettingsPages/GeneralSettingsPage.unit.spec.tsx
index 2a78fefc640..6ec3cf7400d 100644
--- a/frontend/src/metabase/admin/settings/components/SettingsPages/GeneralSettingsPage.unit.spec.tsx
+++ b/frontend/src/metabase/admin/settings/components/SettingsPages/GeneralSettingsPage.unit.spec.tsx
@@ -2,6 +2,7 @@ import userEvent from "@testing-library/user-event";
import fetchMock from "fetch-mock";
import {
+ findRequests,
setupDashboardEndpoints,
setupPropertiesEndpoints,
setupSettingsEndpoints,
@@ -89,16 +90,15 @@ describe("GeneralSettingsPage", () => {
});
});
- it("should make only 4 api calls", async () => {
+ it("should make only 5 api calls", async () => {
await setup();
await waitFor(() => {
- const calls = fetchMock.calls();
- const urls = calls.map((call) => call[0]);
- expect(urls).toHaveLength(5);
+ const calls = fetchMock.callHistory.calls();
+ expect(calls).toHaveLength(5);
});
- const calls = fetchMock.calls();
- const urls = calls.map((call) => call[0]);
+ const calls = fetchMock.callHistory.calls();
+ const urls = calls.map((call) => call.url);
expect(urls).toContain("https://mysite.biz/api/health");
expect(urls).toContainEqual(expect.stringContaining("/api/dashboard/4242"));
expect(urls).toContainEqual(expect.stringContaining("/api/setting"));
@@ -135,13 +135,13 @@ describe("GeneralSettingsPage", () => {
await screen.findByDisplayValue("[email protected]");
await waitFor(async () => {
- const puts = await findPuts();
+ const puts = await findRequests("PUT");
expect(puts).toHaveLength(2);
});
- const puts = await findPuts();
- const [namePutUrl, namePutDetails] = puts[0];
- const [emailPutUrl, emailPutDetails] = puts[1];
+ const puts = await findRequests("PUT");
+ const { url: namePutUrl, body: namePutDetails } = puts[0];
+ const { url: emailPutUrl, body: emailPutDetails } = puts[1];
expect(namePutUrl).toContain("/api/setting/site-name");
expect(namePutDetails).toEqual({ value: "Metabasey" });
@@ -155,16 +155,3 @@ describe("GeneralSettingsPage", () => {
});
});
});
-
-async function findPuts() {
- const calls = fetchMock.calls();
- const data = calls.filter((call) => call[1]?.method === "PUT") ?? [];
-
- const puts = data.map(async ([putUrl, putDetails]) => {
- const body = ((await putDetails?.body) as string) ?? "{}";
-
- return [putUrl, JSON.parse(body ?? "{}")];
- });
-
- return Promise.all(puts);
-}
diff --git a/frontend/src/metabase/admin/settings/components/SettingsPages/test/AuthenticationSettingsPage.setup.tsx b/frontend/src/metabase/admin/settings/components/SettingsPages/test/AuthenticationSettingsPage.setup.tsx
index 463faa7f3f7..256aaa04300 100644
--- a/frontend/src/metabase/admin/settings/components/SettingsPages/test/AuthenticationSettingsPage.setup.tsx
+++ b/frontend/src/metabase/admin/settings/components/SettingsPages/test/AuthenticationSettingsPage.setup.tsx
@@ -81,7 +81,7 @@ export const setup = async (
setupUpdateSettingEndpoint();
setupSettingsEndpoints([]);
setupApiKeyEndpoints(testApiKeys);
- setupTokenStatusEndpoint(isEnterprise);
+ setupTokenStatusEndpoint({ valid: isEnterprise });
renderWithProviders(
<div>
diff --git a/frontend/src/metabase/admin/settings/components/widgets/AdminSettingInput.unit.spec.tsx b/frontend/src/metabase/admin/settings/components/widgets/AdminSettingInput.unit.spec.tsx
index 9853f91d106..cbc08dcaf07 100644
--- a/frontend/src/metabase/admin/settings/components/widgets/AdminSettingInput.unit.spec.tsx
+++ b/frontend/src/metabase/admin/settings/components/widgets/AdminSettingInput.unit.spec.tsx
@@ -2,6 +2,7 @@ import { userEvent } from "@testing-library/user-event";
import fetchMock from "fetch-mock";
import {
+ findRequests,
setupPropertiesEndpoints,
setupSettingsEndpoints,
setupUpdateSettingEndpoint,
@@ -168,7 +169,7 @@ describe("AdminSettingInput", () => {
});
await waitFor(() => {
- const calls = fetchMock.calls();
+ const calls = fetchMock.callHistory.calls();
expect(calls).toHaveLength(2);
});
@@ -187,8 +188,8 @@ describe("AdminSettingInput", () => {
const input = await screen.findByRole("switch");
await userEvent.click(input);
- const [putUrl, body] = await findPut();
- expect(putUrl).toContain("/api/setting/enable-xrays");
+ const [{ url, body }] = await findRequests("PUT");
+ expect(url).toContain("/api/setting/enable-xrays");
expect(body).toStrictEqual({ value: false });
});
@@ -208,8 +209,8 @@ describe("AdminSettingInput", () => {
const inputChanged = await screen.findByRole("textbox");
expect(inputChanged).toHaveValue("Wigglybase");
- const [putUrl, body] = await findPut();
- expect(putUrl).toContain("/api/setting/site-name");
+ const [{ url, body }] = await findRequests("PUT");
+ expect(url).toContain("/api/setting/site-name");
expect(body).toStrictEqual({ value: "Wigglybase" });
});
@@ -228,8 +229,8 @@ describe("AdminSettingInput", () => {
const inputChanged = await screen.findByRole("spinbutton");
expect(inputChanged).toHaveValue(33);
- const [putUrl, body] = await findPut();
- expect(putUrl).toContain("/api/setting/query-caching-min-ttl");
+ const [{ url, body }] = await findRequests("PUT");
+ expect(url).toContain("/api/setting/query-caching-min-ttl");
expect(body).toStrictEqual({ value: "33" });
});
@@ -249,8 +250,8 @@ describe("AdminSettingInput", () => {
const option = await screen.findByText("Simple");
await userEvent.click(option);
- const [putUrl, body] = await findPut();
- expect(putUrl).toContain("/api/setting/humanization-strategy");
+ const [{ url, body }] = await findRequests("PUT");
+ expect(url).toContain("/api/setting/humanization-strategy");
expect(body).toStrictEqual({ value: "simple" });
});
@@ -292,8 +293,8 @@ describe("AdminSettingInput", () => {
const option = await screen.findByText("Simple");
await userEvent.click(option);
- const [putUrl, body] = await findPut();
- expect(putUrl).toContain("/api/setting/humanization-strategy");
+ const [{ url, body }] = await findRequests("PUT");
+ expect(url).toContain("/api/setting/humanization-strategy");
expect(body).toStrictEqual({ value: "simple" });
});
@@ -322,8 +323,8 @@ describe("AdminSettingInput", () => {
const option = await screen.findByText("False");
await userEvent.click(option);
- const [putUrl, body] = await findPut();
- expect(putUrl).toContain(
+ const [{ url, body }] = await findRequests("PUT");
+ expect(url).toContain(
`/api/setting/${encodeURIComponent("bcc-enabled?")}`,
);
expect(body).toStrictEqual({ value: false });
@@ -341,13 +342,13 @@ describe("AdminSettingInput", () => {
const input = await screen.findByRole("textbox");
await userEvent.clear(input);
await userEvent.type(input, "Wigglybase");
- await fireEvent.blur(input);
+ fireEvent.blur(input);
const inputChanged = await screen.findByRole("textbox");
expect(inputChanged).toHaveValue("Wigglybase");
- const [putUrl, body] = await findPut();
- expect(putUrl).toContain("/api/setting/site-name");
+ const [{ url, body }] = await findRequests("PUT");
+ expect(url).toContain("/api/setting/site-name");
expect(body).toStrictEqual({ value: "Wigglybase" });
});
@@ -366,8 +367,8 @@ describe("AdminSettingInput", () => {
const inputChanged = await screen.findByLabelText("token");
expect(inputChanged).toHaveValue("new-secret-stuff");
- const [putUrl, body] = await findPut();
- expect(putUrl).toContain("/api/setting/premium-embedding-token");
+ const [{ url, body }] = await findRequests("PUT");
+ expect(url).toContain("/api/setting/premium-embedding-token");
expect(body).toStrictEqual({ value: "new-secret-stuff" });
});
@@ -387,12 +388,9 @@ describe("AdminSettingInput", () => {
const option = await screen.findByText("Simple");
await userEvent.click(option);
- const [putUrl, body] = await findPut();
- expect(putUrl).toContain("/api/setting/humanization-strategy");
+ const [{ url, body }] = await findRequests("PUT");
+ expect(url).toContain("/api/setting/humanization-strategy");
expect(body).toStrictEqual({ value: "simple" });
-
- const toast = await screen.findByText("Changes saved");
- expect(toast).toBeInTheDocument();
});
it("should show an error toast on save failure", async () => {
@@ -412,8 +410,8 @@ describe("AdminSettingInput", () => {
const option = await screen.findByText("Simple");
await userEvent.click(option);
- const [putUrl, body] = await findPut();
- expect(putUrl).toContain("/api/setting/humanization-strategy");
+ const [{ url, body }] = await findRequests("PUT");
+ expect(url).toContain("/api/setting/humanization-strategy");
expect(body).toStrictEqual({ value: "simple" });
const toast = await screen.findByText("Error saving humanization-strategy");
@@ -436,13 +434,3 @@ describe("AdminSettingInput", () => {
expect(screen.queryByRole("textbox")).not.toBeInTheDocument();
});
});
-
-async function findPut() {
- const calls = fetchMock.calls();
- const [putUrl, putDetails] =
- calls.find((call) => call[1]?.method === "PUT") ?? [];
-
- const body = ((await putDetails?.body) as string) ?? "{}";
-
- return [putUrl, JSON.parse(body)];
-}
diff --git a/frontend/src/metabase/admin/settings/components/widgets/AnonymousTrackingInput.unit.spec.tsx b/frontend/src/metabase/admin/settings/components/widgets/AnonymousTrackingInput.unit.spec.tsx
index d2c46d38bda..6d4c01e4378 100644
--- a/frontend/src/metabase/admin/settings/components/widgets/AnonymousTrackingInput.unit.spec.tsx
+++ b/frontend/src/metabase/admin/settings/components/widgets/AnonymousTrackingInput.unit.spec.tsx
@@ -1,7 +1,7 @@
import userEvent from "@testing-library/user-event";
-import fetchMock from "fetch-mock";
import {
+ findRequests,
setupPropertiesEndpoints,
setupSettingsEndpoints,
setupUpdateSettingEndpoint,
@@ -57,9 +57,9 @@ describe("AnonymousTrackingInput", () => {
await userEvent.click(screen.getByRole("switch"));
expect(trackingFN).toHaveBeenCalledWith(false);
- const [putUrl, putDetails] = await findPut();
- expect(putUrl).toMatch(/\/api\/setting\/anon-tracking-enabled/);
- expect(putDetails).toEqual({ value: false });
+ const [{ url, body }] = await findRequests("PUT");
+ expect(url).toMatch(/\/api\/setting\/anon-tracking-enabled/);
+ expect(body).toEqual({ value: false });
expect(await screen.findByRole("switch")).not.toBeChecked();
});
@@ -68,21 +68,11 @@ describe("AnonymousTrackingInput", () => {
setup({ value: false });
await userEvent.click(screen.getByRole("switch"));
- const [putUrl, putDetails] = await findPut();
- expect(putUrl).toMatch(/\/api\/setting\/anon-tracking-enabled/);
- expect(putDetails).toEqual({ value: true });
+ const [{ url, body }] = await findRequests("PUT");
+ expect(url).toMatch(/\/api\/setting\/anon-tracking-enabled/);
+ expect(body).toEqual({ value: true });
expect(trackingFN).toHaveBeenCalledWith(true);
expect(await screen.findByRole("switch")).toBeChecked();
});
});
-
-async function findPut() {
- const calls = fetchMock.calls();
- const [putUrl, putDetails] =
- calls.find((call) => call[1]?.method === "PUT") ?? [];
-
- const body = ((await putDetails?.body) as string) ?? "{}";
-
- return [putUrl, JSON.parse(body)];
-}
diff --git a/frontend/src/metabase/admin/settings/components/widgets/CustomHomepageDashboardSetting.unit.spec.tsx b/frontend/src/metabase/admin/settings/components/widgets/CustomHomepageDashboardSetting.unit.spec.tsx
index 9488066afe1..3df05c2b27b 100644
--- a/frontend/src/metabase/admin/settings/components/widgets/CustomHomepageDashboardSetting.unit.spec.tsx
+++ b/frontend/src/metabase/admin/settings/components/widgets/CustomHomepageDashboardSetting.unit.spec.tsx
@@ -2,6 +2,7 @@ import userEvent from "@testing-library/user-event";
import fetchMock from "fetch-mock";
import {
+ findRequests,
setupCurrentUserEndpoint,
setupDashboardEndpoints,
setupPropertiesEndpoints,
@@ -110,9 +111,9 @@ describe("CustomHomepageDashboardSetting", () => {
await userEvent.click(toggle);
expect(await screen.findByRole("switch")).toBeChecked();
- const [[putUrl, putDetails]] = await findPuts();
- expect(putUrl).toContain("/api/setting/custom-homepage");
- expect(putDetails).toEqual({ value: true });
+ const [{ url, body }] = await findRequests("PUT");
+ expect(url).toContain("/api/setting/custom-homepage");
+ expect(body).toEqual({ value: true });
});
it("should show selected dashboard name", async () => {
@@ -138,12 +139,12 @@ describe("CustomHomepageDashboardSetting", () => {
expect(screen.queryByText("Choose a dashboard")).not.toBeInTheDocument();
});
- const [[putUrl, putDetails], [putUrl2, putDetails2]] = await findPuts();
-
+ const [{ url: putUrl, body: putBody }, { url: putUrl2, body: putBody2 }] =
+ await findRequests("PUT");
expect(putUrl).toContain("/api/setting/custom-homepage-dashboard");
- expect(putDetails).toEqual({ value: 4242 });
+ expect(putBody).toEqual({ value: 4242 });
expect(putUrl2).toContain("/api/setting/dismissed-custom-dashboard-toast");
- expect(putDetails2).toEqual({ value: true });
+ expect(putBody2).toEqual({ value: true });
// dashboard name should be displayed
expect(await screen.findByText("My dashboard")).toBeInTheDocument();
@@ -167,24 +168,11 @@ describe("CustomHomepageDashboardSetting", () => {
await userEvent.click(await screen.findByText("My dashboard"));
await waitFor(() => {
- const calls = fetchMock.calls();
+ const calls = fetchMock.callHistory.calls();
const userCall = calls.find((call) =>
- call[0].includes("/api/user/current"),
+ call.url?.includes("/api/user/current"),
);
expect(userCall).toBeDefined();
});
});
});
-
-async function findPuts() {
- const calls = fetchMock.calls();
- const data = calls.filter((call) => call[1]?.method === "PUT") ?? [];
-
- const puts = data.map(async ([putUrl, putDetails]) => {
- const body = ((await putDetails?.body) as string) ?? "{}";
-
- return [putUrl, JSON.parse(body ?? "{}")];
- });
-
- return Promise.all(puts);
-}
diff --git a/frontend/src/metabase/admin/settings/components/widgets/EmailReplyToWidget.unit.spec.tsx b/frontend/src/metabase/admin/settings/components/widgets/EmailReplyToWidget.unit.spec.tsx
index 1066fa92ea6..4a250f1a81e 100644
--- a/frontend/src/metabase/admin/settings/components/widgets/EmailReplyToWidget.unit.spec.tsx
+++ b/frontend/src/metabase/admin/settings/components/widgets/EmailReplyToWidget.unit.spec.tsx
@@ -1,7 +1,7 @@
import userEvent from "@testing-library/user-event";
-import fetchMock from "fetch-mock";
import {
+ findRequests,
setupPropertiesEndpoints,
setupSettingsEndpoints,
setupUpdateSettingEndpoint,
@@ -79,8 +79,8 @@ describe("EmailReplyToWidget", () => {
const inputChanged = await screen.findByRole("textbox");
expect(inputChanged).toHaveValue("[email protected]");
- const [putUrl, body] = await findPut();
- expect(putUrl).toContain("/api/setting/email-reply-to");
+ const [{ url, body }] = await findRequests("PUT");
+ expect(url).toContain("/api/setting/email-reply-to");
expect(body).toStrictEqual({ value: ["[email protected]"] });
});
@@ -99,13 +99,3 @@ describe("EmailReplyToWidget", () => {
expect(screen.queryByRole("textbox")).not.toBeInTheDocument();
});
});
-
-async function findPut() {
- const calls = fetchMock.calls();
- const [putUrl, putDetails] =
- calls.find((call) => call[1]?.method === "PUT") ?? [];
-
- const body = ((await putDetails?.body) as string) ?? "{}";
-
- return [putUrl, JSON.parse(body)];
-}
diff --git a/frontend/src/metabase/admin/settings/components/widgets/HttpsOnlyWidget.unit.spec.tsx b/frontend/src/metabase/admin/settings/components/widgets/HttpsOnlyWidget.unit.spec.tsx
index dcda93c1b1b..4e52b8fcbab 100644
--- a/frontend/src/metabase/admin/settings/components/widgets/HttpsOnlyWidget.unit.spec.tsx
+++ b/frontend/src/metabase/admin/settings/components/widgets/HttpsOnlyWidget.unit.spec.tsx
@@ -2,6 +2,7 @@ import userEvent from "@testing-library/user-event";
import fetchMock from "fetch-mock";
import {
+ findRequests,
setupPropertiesEndpoints,
setupSettingsEndpoints,
setupUpdateSettingEndpoint,
@@ -79,13 +80,13 @@ describe("HttpsOnlyWidget", () => {
await screen.findByLabelText("undo-list");
await waitFor(() => {
- const calls = fetchMock.calls();
+ const calls = fetchMock.callHistory.calls();
expect(calls.length).toBe(2);
});
- const calls = fetchMock.calls();
+ const calls = fetchMock.callHistory.calls();
- const urls = calls.map((call) => call[0]);
+ const urls = calls.map((call) => call.request?.url);
expect(urls).not.toContain("http://myinsecuresite.guru/api/health");
expect(urls).not.toContain("https://myinsecuresite.guru/api/health");
expect(screen.queryByRole("switch")).not.toBeInTheDocument();
@@ -98,13 +99,13 @@ describe("HttpsOnlyWidget", () => {
await screen.findByLabelText("undo-list");
await waitFor(() => {
- const calls = fetchMock.calls();
+ const calls = fetchMock.callHistory.calls();
expect(calls.length).toBe(2);
});
- const calls = fetchMock.calls();
+ const calls = fetchMock.callHistory.calls();
- const urls = calls.map((call) => call[0]);
+ const urls = calls.map((call) => call.request?.url);
expect(urls).not.toContain("https://mysite.biz/api/health");
expect(screen.queryByRole("switch")).not.toBeInTheDocument();
expect(screen.queryByText(/HTTPS/i)).not.toBeInTheDocument();
@@ -144,18 +145,8 @@ describe("HttpsOnlyWidget", () => {
await userEvent.click(input);
- const [putUrl, putDetails] = await findPut();
- expect(putUrl).toContain("/api/setting/redirect-all-requests-to-https");
- expect(putDetails).toEqual({ value: true });
+ const [{ url, body }] = await findRequests("PUT");
+ expect(url).toContain("/api/setting/redirect-all-requests-to-https");
+ expect(body).toEqual({ value: true });
});
});
-
-async function findPut() {
- const calls = fetchMock.calls();
- const [putUrl, putDetails] =
- calls.find((call) => call[1]?.method === "PUT") ?? [];
-
- const body = ((await putDetails?.body) as string) ?? "{}";
-
- return [putUrl, JSON.parse(body)];
-}
diff --git a/frontend/src/metabase/admin/settings/components/widgets/Notifications/WebhookForm.unit.spec.tsx b/frontend/src/metabase/admin/settings/components/widgets/Notifications/WebhookForm.unit.spec.tsx
index 3bc79b67627..4a4cf305f44 100644
--- a/frontend/src/metabase/admin/settings/components/widgets/Notifications/WebhookForm.unit.spec.tsx
+++ b/frontend/src/metabase/admin/settings/components/widgets/Notifications/WebhookForm.unit.spec.tsx
@@ -174,8 +174,8 @@ describe("WebhookForm", () => {
advanceTimers: true,
});
- fetchMock.post("path:/api/channel/test", async (_url, opts) => {
- const body = JSON.parse((await opts.body) as string);
+ fetchMock.post("path:/api/channel/test", async (call) => {
+ const body = JSON.parse(call.options?.body as string);
return body.details.url?.endsWith("good") ? { ok: true } : 400;
});
diff --git a/frontend/src/metabase/admin/settings/components/widgets/SendTestEmailWidget.unit.spec.tsx b/frontend/src/metabase/admin/settings/components/widgets/SendTestEmailWidget.unit.spec.tsx
index 11872fb65fe..5ca1e74da9e 100644
--- a/frontend/src/metabase/admin/settings/components/widgets/SendTestEmailWidget.unit.spec.tsx
+++ b/frontend/src/metabase/admin/settings/components/widgets/SendTestEmailWidget.unit.spec.tsx
@@ -79,9 +79,7 @@ describe("SendTestEmailWidget", () => {
it("should show an error message if the test email errors", async () => {
await setup({ emailConfigured: true });
- fetchMock.post("path:/api/email/test", 400, {
- overwriteRoutes: true,
- });
+ fetchMock.modifyRoute("email-test", { response: 400 });
await userEvent.click(
screen.getByRole("button", { name: "Send test email" }),
diff --git a/frontend/src/metabase/admin/settings/components/widgets/SiteUrlWidget.unit.spec.tsx b/frontend/src/metabase/admin/settings/components/widgets/SiteUrlWidget.unit.spec.tsx
index a1b4324d878..8318f26b060 100644
--- a/frontend/src/metabase/admin/settings/components/widgets/SiteUrlWidget.unit.spec.tsx
+++ b/frontend/src/metabase/admin/settings/components/widgets/SiteUrlWidget.unit.spec.tsx
@@ -1,7 +1,7 @@
import userEvent from "@testing-library/user-event";
-import fetchMock from "fetch-mock";
import {
+ findRequests,
setupPropertiesEndpoints,
setupSettingsEndpoints,
setupUpdateSettingEndpoint,
@@ -62,9 +62,9 @@ describe("siteUrlWidget", () => {
await fireEvent.blur(input);
await screen.findByDisplayValue("newsite.guru");
- const [putUrl, putDetails] = await findPut();
- expect(putUrl).toMatch(/\/api\/setting\/site-url/);
- expect(putDetails).toEqual({ value: "http://newsite.guru" });
+ const [{ url, body }] = await findRequests("PUT");
+ expect(url).toMatch(/\/api\/setting\/site-url/);
+ expect(body).toEqual({ value: "http://newsite.guru" });
});
it("can change from http to https", async () => {
@@ -74,9 +74,9 @@ describe("siteUrlWidget", () => {
);
await userEvent.click(await screen.findByText("https://"));
- const [putUrl, putDetails] = await findPut();
- expect(putUrl).toMatch(/\/api\/setting\/site-url/);
- expect(putDetails).toEqual({ value: "https://mysite.biz" });
+ const [{ url, body }] = await findRequests("PUT");
+ expect(url).toMatch(/\/api\/setting\/site-url/);
+ expect(body).toEqual({ value: "https://mysite.biz" });
});
it("should show success toast", async () => {
@@ -108,13 +108,3 @@ describe("siteUrlWidget", () => {
).toBeInTheDocument();
});
});
-
-async function findPut() {
- const calls = fetchMock.calls();
- const [putUrl, putDetails] =
- calls.find((call) => call[1]?.method === "PUT") ?? [];
-
- const body = ((await putDetails?.body) as string) ?? "{}";
-
- return [putUrl, JSON.parse(body)];
-}
diff --git a/frontend/src/metabase/admin/settings/tests/setup.tsx b/frontend/src/metabase/admin/settings/tests/setup.tsx
index 92d80c7c055..e7d038bec05 100644
--- a/frontend/src/metabase/admin/settings/tests/setup.tsx
+++ b/frontend/src/metabase/admin/settings/tests/setup.tsx
@@ -164,7 +164,7 @@ export const setup = async ({
if (hasEnterprisePlugins) {
setupEnterprisePlugins();
- setupTokenStatusEndpoint(hasTokenFeatures);
+ setupTokenStatusEndpoint({ valid: hasTokenFeatures });
}
renderWithProviders(
diff --git a/frontend/src/metabase/admin/tools/components/LogLevelsModal/LogLevelsModal.unit.spec.tsx b/frontend/src/metabase/admin/tools/components/LogLevelsModal/LogLevelsModal.unit.spec.tsx
index a662030d1be..b86df30a5bf 100644
--- a/frontend/src/metabase/admin/tools/components/LogLevelsModal/LogLevelsModal.unit.spec.tsx
+++ b/frontend/src/metabase/admin/tools/components/LogLevelsModal/LogLevelsModal.unit.spec.tsx
@@ -51,7 +51,7 @@ const setup = ({ error, presets = [PRESET_A, PRESET_B] }: SetupOpts = {}) => {
setupDeleteLoggerAdjustmentEndpoint();
if (error) {
- setupLoggerPresetsEndpoint({ status: 500 }, { overwriteRoutes: true });
+ fetchMock.modifyRoute("logger-presets", { response: { status: 500 } });
}
return renderWithProviders(
@@ -121,7 +121,9 @@ describe("LogLevelsModal", () => {
await userEvent.click(screen.getByText("Reset to defaults"));
expect(
- fetchMock.calls("path:/api/logger/adjustment", { method: "DELETE" }),
+ fetchMock.callHistory.calls("path:/api/logger/adjustment", {
+ method: "DELETE",
+ }),
).toHaveLength(1);
expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
});
@@ -140,12 +142,13 @@ describe("LogLevelsModal", () => {
await userEvent.click(within(popover).getByText(PRESET_B.display_name));
await userEvent.click(screen.getByText("Save"));
- const calls = fetchMock.calls("path:/api/logger/adjustment", {
+ const calls = fetchMock.callHistory.calls("path:/api/logger/adjustment", {
method: "POST",
});
expect(calls).toHaveLength(1);
- const [_url, options] = calls[0];
+ const call = calls[0];
+ const options = call.options;
const body = await checkNotNull(options).body;
if (typeof body !== "string") {
diff --git a/frontend/src/metabase/admin/tools/components/Logs/Logs.unit.spec.tsx b/frontend/src/metabase/admin/tools/components/Logs/Logs.unit.spec.tsx
index 2ae7e6fe8f5..4de2b575caa 100644
--- a/frontend/src/metabase/admin/tools/components/Logs/Logs.unit.spec.tsx
+++ b/frontend/src/metabase/admin/tools/components/Logs/Logs.unit.spec.tsx
@@ -57,7 +57,6 @@ describe("Logs", () => {
afterEach(() => {
utilSpy.mockClear();
- fetchMock.restore();
jest.useRealTimers();
});
diff --git a/frontend/src/metabase/admin/tools/components/TasksApp/TasksApp.unit.spec.tsx b/frontend/src/metabase/admin/tools/components/TasksApp/TasksApp.unit.spec.tsx
index 6405d01ccd8..2d45a171d24 100644
--- a/frontend/src/metabase/admin/tools/components/TasksApp/TasksApp.unit.spec.tsx
+++ b/frontend/src/metabase/admin/tools/components/TasksApp/TasksApp.unit.spec.tsx
@@ -11,6 +11,7 @@ import {
act,
renderWithProviders,
screen,
+ waitFor,
waitForLoaderToBeRemoved,
within,
} from "__support__/ui";
@@ -112,7 +113,13 @@ describe("TasksApp", () => {
}),
});
- expect(fetchMock.calls("path:/api/task").map(([url]) => url)).toEqual([
+ await waitFor(() => {
+ expect(fetchMock.callHistory.calls("path:/api/task")).toHaveLength(1);
+ });
+
+ expect(
+ fetchMock.callHistory.calls("path:/api/task").map((call) => call.url),
+ ).toEqual([
"http://localhost/api/task?limit=50&offset=0&sort_column=started_at&sort_direction=desc",
]);
await waitForLoaderToBeRemoved();
@@ -125,8 +132,12 @@ describe("TasksApp", () => {
expect(history?.getCurrentLocation().search).toEqual("");
await userEvent.click(nextPage);
-
- expect(fetchMock.calls("path:/api/task").map(([url]) => url)).toEqual([
+ await waitFor(() => {
+ expect(fetchMock.callHistory.calls("path:/api/task")).toHaveLength(2);
+ });
+ expect(
+ fetchMock.callHistory.calls("path:/api/task").map((call) => call.url),
+ ).toEqual([
"http://localhost/api/task?limit=50&offset=0&sort_column=started_at&sort_direction=desc",
"http://localhost/api/task?limit=50&offset=50&sort_column=started_at&sort_direction=desc",
]);
@@ -142,7 +153,9 @@ describe("TasksApp", () => {
await userEvent.click(previousPage);
- expect(fetchMock.calls("path:/api/task").map(([url]) => url)).toEqual([
+ expect(
+ fetchMock.callHistory.calls("path:/api/task").map((call) => call.url),
+ ).toEqual([
"http://localhost/api/task?limit=50&offset=0&sort_column=started_at&sort_direction=desc",
"http://localhost/api/task?limit=50&offset=50&sort_column=started_at&sort_direction=desc",
"http://localhost/api/task?limit=50&offset=0&sort_column=started_at&sort_direction=desc",
@@ -167,7 +180,13 @@ describe("TasksApp", () => {
}),
});
- expect(fetchMock.calls("path:/api/task").map(([url]) => url)).toEqual([
+ await waitFor(() => {
+ expect(fetchMock.callHistory.calls("path:/api/task")).toHaveLength(1);
+ });
+
+ expect(
+ fetchMock.callHistory.calls("path:/api/task").map((call) => call.url),
+ ).toEqual([
"http://localhost/api/task?limit=50&offset=0&sort_column=started_at&sort_direction=desc",
]);
await waitForLoaderToBeRemoved();
@@ -177,7 +196,9 @@ describe("TasksApp", () => {
const taskPicker = screen.getByPlaceholderText("Filter by task");
await userEvent.click(nextPage);
- expect(fetchMock.calls("path:/api/task").map(([url]) => url)).toEqual([
+ expect(
+ fetchMock.callHistory.calls("path:/api/task").map((call) => call.url),
+ ).toEqual([
"http://localhost/api/task?limit=50&offset=0&sort_column=started_at&sort_direction=desc",
"http://localhost/api/task?limit=50&offset=50&sort_column=started_at&sort_direction=desc",
]);
@@ -190,7 +211,9 @@ describe("TasksApp", () => {
const taskPopover = screen.getByRole("listbox");
await userEvent.click(within(taskPopover).getByText("task-b"));
- expect(fetchMock.calls("path:/api/task").map(([url]) => url)).toEqual([
+ expect(
+ fetchMock.callHistory.calls("path:/api/task").map((call) => call.url),
+ ).toEqual([
"http://localhost/api/task?limit=50&offset=0&sort_column=started_at&sort_direction=desc",
"http://localhost/api/task?limit=50&offset=50&sort_column=started_at&sort_direction=desc",
"http://localhost/api/task?limit=50&offset=0&sort_column=started_at&sort_direction=desc&task=task-b",
@@ -212,7 +235,13 @@ describe("TasksApp", () => {
}),
});
- expect(fetchMock.calls("path:/api/task").map(([url]) => url)).toEqual([
+ await waitFor(() => {
+ expect(fetchMock.callHistory.calls("path:/api/task")).toHaveLength(1);
+ });
+
+ expect(
+ fetchMock.callHistory.calls("path:/api/task").map((call) => call.url),
+ ).toEqual([
"http://localhost/api/task?limit=50&offset=0&sort_column=started_at&sort_direction=desc",
]);
await waitForLoaderToBeRemoved();
@@ -222,7 +251,9 @@ describe("TasksApp", () => {
const taskStatusPicker = screen.getByPlaceholderText("Filter by status");
await userEvent.click(nextPage);
- expect(fetchMock.calls("path:/api/task").map(([url]) => url)).toEqual([
+ expect(
+ fetchMock.callHistory.calls("path:/api/task").map((call) => call.url),
+ ).toEqual([
"http://localhost/api/task?limit=50&offset=0&sort_column=started_at&sort_direction=desc",
"http://localhost/api/task?limit=50&offset=50&sort_column=started_at&sort_direction=desc",
]);
@@ -235,7 +266,9 @@ describe("TasksApp", () => {
const taskStatusPopover = screen.getByRole("listbox");
await userEvent.click(within(taskStatusPopover).getByText("Success"));
- expect(fetchMock.calls("path:/api/task").map(([url]) => url)).toEqual([
+ expect(
+ fetchMock.callHistory.calls("path:/api/task").map((call) => call.url),
+ ).toEqual([
"http://localhost/api/task?limit=50&offset=0&sort_column=started_at&sort_direction=desc",
"http://localhost/api/task?limit=50&offset=50&sort_column=started_at&sort_direction=desc",
"http://localhost/api/task?limit=50&offset=0&sort_column=started_at&sort_direction=desc&status=success",
@@ -257,7 +290,13 @@ describe("TasksApp", () => {
}),
});
- expect(fetchMock.calls("path:/api/task").map(([url]) => url)).toEqual([
+ await waitFor(() => {
+ expect(fetchMock.callHistory.calls("path:/api/task")).toHaveLength(1);
+ });
+
+ expect(
+ fetchMock.callHistory.calls("path:/api/task").map((call) => call.url),
+ ).toEqual([
"http://localhost/api/task?limit=50&offset=0&sort_column=started_at&sort_direction=desc",
]);
await waitForLoaderToBeRemoved();
@@ -269,7 +308,9 @@ describe("TasksApp", () => {
});
await userEvent.click(nextPage);
- expect(fetchMock.calls("path:/api/task").map(([url]) => url)).toEqual([
+ expect(
+ fetchMock.callHistory.calls("path:/api/task").map((call) => call.url),
+ ).toEqual([
"http://localhost/api/task?limit=50&offset=0&sort_column=started_at&sort_direction=desc",
"http://localhost/api/task?limit=50&offset=50&sort_column=started_at&sort_direction=desc",
]);
@@ -280,7 +321,9 @@ describe("TasksApp", () => {
await userEvent.click(startedAtHeader);
- expect(fetchMock.calls("path:/api/task").map(([url]) => url)).toEqual([
+ expect(
+ fetchMock.callHistory.calls("path:/api/task").map((call) => call.url),
+ ).toEqual([
"http://localhost/api/task?limit=50&offset=0&sort_column=started_at&sort_direction=desc",
"http://localhost/api/task?limit=50&offset=50&sort_column=started_at&sort_direction=desc",
"http://localhost/api/task?limit=50&offset=0&sort_column=started_at&sort_direction=asc",
@@ -296,7 +339,13 @@ describe("TasksApp", () => {
it("should allow to filter tasks list", async () => {
const { history } = setup();
- expect(fetchMock.calls("path:/api/task").map(([url]) => url)).toEqual([
+ await waitFor(() => {
+ expect(fetchMock.callHistory.calls("path:/api/task")).toHaveLength(1);
+ });
+
+ expect(
+ fetchMock.callHistory.calls("path:/api/task").map((call) => call.url),
+ ).toEqual([
"http://localhost/api/task?limit=50&offset=0&sort_column=started_at&sort_direction=desc",
]);
await waitForLoaderToBeRemoved();
@@ -320,7 +369,9 @@ describe("TasksApp", () => {
await userEvent.click(within(taskPopover).getByText("task-b"));
expect(taskPicker).toHaveValue("task-b");
- expect(fetchMock.calls("path:/api/task").map(([url]) => url)).toEqual([
+ expect(
+ fetchMock.callHistory.calls("path:/api/task").map((call) => call.url),
+ ).toEqual([
"http://localhost/api/task?limit=50&offset=0&sort_column=started_at&sort_direction=desc",
"http://localhost/api/task?limit=50&offset=0&sort_column=started_at&sort_direction=desc&task=task-b",
]);
@@ -344,7 +395,9 @@ describe("TasksApp", () => {
await userEvent.click(within(taskStatusPopover).getByText("Success"));
expect(taskStatusPicker).toHaveValue("Success");
- expect(fetchMock.calls("path:/api/task").map(([url]) => url)).toEqual([
+ expect(
+ fetchMock.callHistory.calls("path:/api/task").map((call) => call.url),
+ ).toEqual([
"http://localhost/api/task?limit=50&offset=0&sort_column=started_at&sort_direction=desc",
"http://localhost/api/task?limit=50&offset=0&sort_column=started_at&sort_direction=desc&task=task-b",
"http://localhost/api/task?limit=50&offset=0&sort_column=started_at&sort_direction=desc&status=success&task=task-b",
@@ -362,7 +415,9 @@ describe("TasksApp", () => {
await userEvent.click(clearTaskButton);
expect(taskPicker).toHaveValue("");
- expect(fetchMock.calls("path:/api/task").map(([url]) => url)).toEqual([
+ expect(
+ fetchMock.callHistory.calls("path:/api/task").map((call) => call.url),
+ ).toEqual([
"http://localhost/api/task?limit=50&offset=0&sort_column=started_at&sort_direction=desc",
"http://localhost/api/task?limit=50&offset=0&sort_column=started_at&sort_direction=desc&task=task-b",
"http://localhost/api/task?limit=50&offset=0&sort_column=started_at&sort_direction=desc&status=success&task=task-b",
@@ -378,7 +433,9 @@ describe("TasksApp", () => {
await userEvent.click(clearTaskStatusButton);
expect(taskStatusPicker).toHaveValue("");
- expect(fetchMock.calls("path:/api/task").map(([url]) => url)).toEqual([
+ expect(
+ fetchMock.callHistory.calls("path:/api/task").map((call) => call.url),
+ ).toEqual([
"http://localhost/api/task?limit=50&offset=0&sort_column=started_at&sort_direction=desc",
"http://localhost/api/task?limit=50&offset=0&sort_column=started_at&sort_direction=desc&task=task-b",
"http://localhost/api/task?limit=50&offset=0&sort_column=started_at&sort_direction=desc&status=success&task=task-b",
@@ -396,7 +453,13 @@ describe("TasksApp", () => {
it("should allow to sort tasks list", async () => {
const { history } = setup();
- expect(fetchMock.calls("path:/api/task").map(([url]) => url)).toEqual([
+ await waitFor(() => {
+ expect(fetchMock.callHistory.calls("path:/api/task")).toHaveLength(1);
+ });
+
+ expect(
+ fetchMock.callHistory.calls("path:/api/task").map((call) => call.url),
+ ).toEqual([
"http://localhost/api/task?limit=50&offset=0&sort_column=started_at&sort_direction=desc",
]);
await waitForLoaderToBeRemoved();
@@ -418,7 +481,9 @@ describe("TasksApp", () => {
expect(
within(startedAtHeader).getByRole("img", { name: "chevronup icon" }),
).toBeInTheDocument();
- expect(fetchMock.calls("path:/api/task").map(([url]) => url)).toEqual([
+ expect(
+ fetchMock.callHistory.calls("path:/api/task").map((call) => call.url),
+ ).toEqual([
"http://localhost/api/task?limit=50&offset=0&sort_column=started_at&sort_direction=desc",
"http://localhost/api/task?limit=50&offset=0&sort_column=started_at&sort_direction=asc",
]);
@@ -432,7 +497,9 @@ describe("TasksApp", () => {
expect(
within(endedAtHeader).getByRole("img", { name: "chevronup icon" }),
).toBeInTheDocument();
- expect(fetchMock.calls("path:/api/task").map(([url]) => url)).toEqual([
+ expect(
+ fetchMock.callHistory.calls("path:/api/task").map((call) => call.url),
+ ).toEqual([
"http://localhost/api/task?limit=50&offset=0&sort_column=started_at&sort_direction=desc",
"http://localhost/api/task?limit=50&offset=0&sort_column=started_at&sort_direction=asc",
"http://localhost/api/task?limit=50&offset=0&sort_column=ended_at&sort_direction=asc",
@@ -449,7 +516,9 @@ describe("TasksApp", () => {
expect(
within(durationHeader).getByRole("img", { name: "chevronup icon" }),
).toBeInTheDocument();
- expect(fetchMock.calls("path:/api/task").map(([url]) => url)).toEqual([
+ expect(
+ fetchMock.callHistory.calls("path:/api/task").map((call) => call.url),
+ ).toEqual([
"http://localhost/api/task?limit=50&offset=0&sort_column=started_at&sort_direction=desc",
"http://localhost/api/task?limit=50&offset=0&sort_column=started_at&sort_direction=asc",
"http://localhost/api/task?limit=50&offset=0&sort_column=ended_at&sort_direction=asc",
@@ -471,7 +540,13 @@ describe("TasksApp", () => {
}),
});
- expect(fetchMock.calls("path:/api/task").map(([url]) => url)).toEqual([
+ await waitFor(() => {
+ expect(fetchMock.callHistory.calls("path:/api/task")).toHaveLength(1);
+ });
+
+ expect(
+ fetchMock.callHistory.calls("path:/api/task").map((call) => call.url),
+ ).toEqual([
"http://localhost/api/task?limit=50&offset=0&sort_column=started_at&sort_direction=desc&task=task-b",
]);
await waitForLoaderToBeRemoved();
@@ -490,7 +565,13 @@ describe("TasksApp", () => {
}),
});
- expect(fetchMock.calls("path:/api/task").map(([url]) => url)).toEqual([
+ await waitFor(() => {
+ expect(fetchMock.callHistory.calls("path:/api/task")).toHaveLength(1);
+ });
+
+ expect(
+ fetchMock.callHistory.calls("path:/api/task").map((call) => call.url),
+ ).toEqual([
"http://localhost/api/task?limit=50&offset=0&sort_column=started_at&sort_direction=desc&status=success",
]);
await waitForLoaderToBeRemoved();
@@ -509,7 +590,13 @@ describe("TasksApp", () => {
}),
});
- expect(fetchMock.calls("path:/api/task").map(([url]) => url)).toEqual([
+ await waitFor(() => {
+ expect(fetchMock.callHistory.calls("path:/api/task")).toHaveLength(1);
+ });
+
+ expect(
+ fetchMock.callHistory.calls("path:/api/task").map((call) => call.url),
+ ).toEqual([
"http://localhost/api/task?limit=50&offset=0&sort_column=duration&sort_direction=asc",
]);
});
diff --git a/frontend/src/metabase/api/utils/settings.unit.spec.tsx b/frontend/src/metabase/api/utils/settings.unit.spec.tsx
index 413ee534ea2..b68885d5b5e 100644
--- a/frontend/src/metabase/api/utils/settings.unit.spec.tsx
+++ b/frontend/src/metabase/api/utils/settings.unit.spec.tsx
@@ -89,9 +89,9 @@ describe("useAdminSetting", () => {
expect(screen.getByText(/New Site Name/)).toBeInTheDocument();
});
- const apiCalls = fetchMock.calls();
- const putCall = apiCalls.find((call) => call[1]?.method === "PUT");
+ const apiCalls = fetchMock.callHistory.calls();
+ const putCall = apiCalls.find((call) => call.request?.method === "PUT");
- expect(putCall?.[0]).toContain("/api/setting/site-name");
+ expect(putCall?.request?.url).toContain("/api/setting/site-name");
});
});
diff --git a/frontend/src/metabase/api/utils/use-token-refresh.unit.spec.tsx b/frontend/src/metabase/api/utils/use-token-refresh.unit.spec.tsx
index 17236e29f03..fb1397e16b2 100644
--- a/frontend/src/metabase/api/utils/use-token-refresh.unit.spec.tsx
+++ b/frontend/src/metabase/api/utils/use-token-refresh.unit.spec.tsx
@@ -27,7 +27,11 @@ const waitForElevenSeconds = async () => {
await screen.findByText("Test");
};
-const setupRefreshableProperties = (hasRefresh = true) => {
+const setupRefreshableProperties = ({
+ hasRefresh,
+}: {
+ hasRefresh: boolean;
+}) => {
const settings = createMockSettings({
"site-name": "Test",
"token-status": {
@@ -40,7 +44,7 @@ const setupRefreshableProperties = (hasRefresh = true) => {
};
const setup = async (hasRefresh = true) => {
- setupRefreshableProperties(hasRefresh);
+ setupRefreshableProperties({ hasRefresh });
renderWithProviders(<TestComponent />);
await screen.findByText("Loading...");
await screen.findByText("Test");
@@ -84,7 +88,7 @@ describe("useTokenRefresh", () => {
await waitForElevenSeconds();
await waitForGets(2);
- setupRefreshableProperties(false); // remove the refresh flag
+ setupRefreshableProperties({ hasRefresh: false }); // remove the refresh flag
await waitForElevenSeconds();
await waitForGets(3); // should get one more
diff --git a/frontend/src/metabase/auth/components/Logout/Logout.unit.spec.tsx b/frontend/src/metabase/auth/components/Logout/Logout.unit.spec.tsx
index 23c72b6e7f3..62141d4089d 100644
--- a/frontend/src/metabase/auth/components/Logout/Logout.unit.spec.tsx
+++ b/frontend/src/metabase/auth/components/Logout/Logout.unit.spec.tsx
@@ -21,7 +21,9 @@ describe("Logout", () => {
setup();
- await waitFor(() => expect(fetchMock.done("path:/api/session")).toBe(true));
+ await waitFor(() =>
+ expect(fetchMock.callHistory.done("path:/api/session")).toBe(true),
+ );
await waitFor(() => expect(domUtils.reload).toHaveBeenCalled());
});
});
diff --git a/frontend/src/metabase/auth/components/PasswordPanel/PasswordPanel.unit.spec.tsx b/frontend/src/metabase/auth/components/PasswordPanel/PasswordPanel.unit.spec.tsx
index 3e2882b944a..e2059f795ff 100644
--- a/frontend/src/metabase/auth/components/PasswordPanel/PasswordPanel.unit.spec.tsx
+++ b/frontend/src/metabase/auth/components/PasswordPanel/PasswordPanel.unit.spec.tsx
@@ -61,7 +61,7 @@ describe("PasswordPanel", () => {
await userEvent.click(screen.getByRole("button", { name: "Sign in" }));
await waitFor(() => {
- expect(fetchMock.done("path:/api/session")).toBe(true);
+ expect(fetchMock.callHistory.done("path:/api/session")).toBe(true);
});
});
diff --git a/frontend/src/metabase/browse/containers/TableBrowser/TableBrowser.unit.spec.js b/frontend/src/metabase/browse/containers/TableBrowser/TableBrowser.unit.spec.js
index 22a1f9bca6b..03c470d81f1 100644
--- a/frontend/src/metabase/browse/containers/TableBrowser/TableBrowser.unit.spec.js
+++ b/frontend/src/metabase/browse/containers/TableBrowser/TableBrowser.unit.spec.js
@@ -14,9 +14,11 @@ import TableBrowser from "./TableBrowser";
describe("TableBrowser", () => {
it("should poll until tables have completed initial sync", async () => {
// initially, initial_sync_status='incomplete'
- fetchMock.get("path:/api/database/1/schema/public", [
- { id: 123, name: "foo", initial_sync_status: "incomplete" },
- ]);
+ fetchMock.get(
+ "path:/api/database/1/schema/public",
+ [{ id: 123, name: "foo", initial_sync_status: "incomplete" }],
+ { name: "database-get-schema" },
+ );
fetchMock.get("path:/api/database/1", [
{ id: 123, name: "bar", initial_sync_status: "complete" },
]);
@@ -25,20 +27,21 @@ describe("TableBrowser", () => {
expect(screen.getByText("foo")).toBeInTheDocument();
});
// check only one call has been made
- const calls = await fetchMock.calls(/\/api\/database\/1\/schema\/public/);
+ const calls = fetchMock.callHistory.calls(
+ "path:/api/database/1/schema/public",
+ );
expect(calls.length).toBe(1);
// check the loading spinner is present
expect(screen.getByTestId("loading-indicator")).toBeInTheDocument();
// change the table to have initial_sync_status='complete'
- fetchMock.get(
- "path:/api/database/1/schema/public",
- [{ id: 123, name: "foo", initial_sync_status: "complete" }],
- { overwriteRoutes: true },
- );
+ fetchMock.modifyRoute("database-get-schema", {
+ response: [{ id: 123, name: "foo", initial_sync_status: "complete" }],
+ });
await waitFor(
() => {
expect(
- fetchMock.calls(/\/api\/database\/1\/schema\/public/).length,
+ fetchMock.callHistory.calls("path:/api/database/1/schema/public")
+ .length,
).toBe(2);
},
{ timeout: 3000 },
diff --git a/frontend/src/metabase/collections/components/CollectionHeader/tests/common.unit.spec.tsx b/frontend/src/metabase/collections/components/CollectionHeader/tests/common.unit.spec.tsx
index 78295506dac..0d07285026e 100644
--- a/frontend/src/metabase/collections/components/CollectionHeader/tests/common.unit.spec.tsx
+++ b/frontend/src/metabase/collections/components/CollectionHeader/tests/common.unit.spec.tsx
@@ -1,7 +1,7 @@
import userEvent from "@testing-library/user-event";
import { findRequests } from "__support__/server-mocks";
-import { screen, waitFor, within } from "__support__/ui";
+import { screen, within } from "__support__/ui";
import type { CollectionId } from "metabase-types/api";
import { setup } from "./setup";
@@ -146,16 +146,12 @@ describe("CollectionHeader", () => {
const button = screen.getByLabelText("calendar icon");
expect(button).toBeInTheDocument();
- userEvent.click(button);
+ await userEvent.click(button);
+ const puts = await findRequests("PUT");
+ expect(puts).toHaveLength(1);
- const puts = await waitFor(async () => {
- const puts = await findRequests("PUT");
- expect(puts).toHaveLength(1);
- return puts;
- });
-
- expect(puts[0].url).toBe(
- "http://localhost/api/user-key-value/namespace/user_acknowledgement/key/events-menu",
+ expect(puts[0].url).toContain(
+ "/api/user-key-value/namespace/user_acknowledgement/key/events-menu",
);
});
});
diff --git a/frontend/src/metabase/collections/components/CollectionMenu/tests/common.unit.spec.tsx b/frontend/src/metabase/collections/components/CollectionMenu/tests/common.unit.spec.tsx
index 3852756009c..1f999bc81ae 100644
--- a/frontend/src/metabase/collections/components/CollectionMenu/tests/common.unit.spec.tsx
+++ b/frontend/src/metabase/collections/components/CollectionMenu/tests/common.unit.spec.tsx
@@ -168,7 +168,7 @@ describe("for your consideration", () => {
await userEvent.click(getIcon("ellipsis"));
expect(
- fetchMock.calls(
+ fetchMock.callHistory.calls(
"http://localhost/api/user-key-value/namespace/indicator-menu/key/collection-menu",
{ method: "PUT" },
),
@@ -183,7 +183,7 @@ describe("for your consideration", () => {
);
expect(
- fetchMock.calls(
+ fetchMock.callHistory.calls(
"http://localhost/api/user-key-value/namespace/user_acknowledgement/key/move-to-dashboard",
{ method: "PUT" },
),
@@ -202,7 +202,7 @@ describe("for your consideration", () => {
await userEvent.click(getIcon("ellipsis"));
expect(
- fetchMock.called(
+ fetchMock.callHistory.called(
"http://localhost/api/user-key-value/namespace/user_acknowledgement/key/collection-menu",
{ method: "PUT" },
),
@@ -221,7 +221,7 @@ describe("for your consideration", () => {
await userEvent.click(getIcon("ellipsis"));
expect(
- fetchMock.called(
+ fetchMock.callHistory.called(
"http://localhost/api/user-key-value/namespace/user_acknowledgement/key/collection-menu",
{ method: "PUT" },
),
@@ -243,7 +243,7 @@ describe("for your consideration", () => {
await userEvent.click(getIcon("ellipsis"));
expect(
- fetchMock.called(
+ fetchMock.callHistory.called(
"http://localhost/api/user-key-value/namespace/user_acknowledgement/key/collection-menu",
{ method: "PUT" },
),
@@ -262,7 +262,7 @@ describe("for your consideration", () => {
await userEvent.click(getIcon("ellipsis"));
expect(
- fetchMock.called(
+ fetchMock.callHistory.called(
"http://localhost/api/user-key-value/namespace/user_acknowledgement/key/collection-menu",
{ method: "PUT" },
),
@@ -281,7 +281,7 @@ describe("for your consideration", () => {
await userEvent.click(getIcon("ellipsis"));
expect(
- fetchMock.called(
+ fetchMock.callHistory.called(
"http://localhost/api/user-key-value/namespace/user_acknowledgement/key/collection-menu",
{ method: "PUT" },
),
diff --git a/frontend/src/metabase/collections/components/CollectionMenu/tests/premium.unit.spec.tsx b/frontend/src/metabase/collections/components/CollectionMenu/tests/premium.unit.spec.tsx
index 437ec239110..16efa944cec 100644
--- a/frontend/src/metabase/collections/components/CollectionMenu/tests/premium.unit.spec.tsx
+++ b/frontend/src/metabase/collections/components/CollectionMenu/tests/premium.unit.spec.tsx
@@ -128,7 +128,7 @@ describe("CollectionMenu", () => {
await userEvent.click(getIcon("ellipsis"));
expect(
- fetchMock.calls(
+ fetchMock.callHistory.calls(
"http://localhost/api/user-key-value/namespace/indicator-menu/key/collection-menu",
{ method: "PUT" },
),
@@ -150,7 +150,7 @@ describe("CollectionMenu", () => {
await userEvent.click(getIcon("ellipsis"));
expect(
- fetchMock.calls(
+ fetchMock.callHistory.calls(
"http://localhost/api/user-key-value/namespace/user_acknowledgement/key/collection-menu",
{ method: "PUT" },
),
@@ -183,12 +183,14 @@ describe("CollectionMenu", () => {
});
await waitFor(() =>
- expect(fetchMock.calls("express:/api/ee/stale/:id")).toHaveLength(1),
+ expect(
+ fetchMock.callHistory.calls("express:/api/ee/stale/:id"),
+ ).toHaveLength(1),
);
await waitFor(() =>
expect(
- fetchMock.calls(
+ fetchMock.callHistory.calls(
"http://localhost/api/user-key-value/namespace/indicator-menu/key/collection-menu",
{ method: "GET" },
),
@@ -196,7 +198,7 @@ describe("CollectionMenu", () => {
);
await waitFor(() =>
expect(
- fetchMock.calls(
+ fetchMock.callHistory.calls(
"http://localhost/api/user-key-value/namespace/user_acknowledgement/key/clean-stale-items",
{ method: "GET" },
),
@@ -207,7 +209,7 @@ describe("CollectionMenu", () => {
await userEvent.click(getIcon("ellipsis"));
expect(
- fetchMock.calls(
+ fetchMock.callHistory.calls(
"http://localhost/api/user-key-value/namespace/indicator-menu/key/collection-menu",
{ method: "PUT" },
),
@@ -230,8 +232,12 @@ describe("CollectionMenu", () => {
await assertIndicatorHidden();
await userEvent.click(getIcon("ellipsis"));
- expect(fetchMock.calls("path:/api/collection/1/items")).toHaveLength(0);
- expect(fetchMock.calls("express:/api/ee/stale/:id")).toHaveLength(0);
+ expect(
+ fetchMock.callHistory.calls("path:/api/collection/1/items"),
+ ).toHaveLength(0);
+ expect(
+ fetchMock.callHistory.calls("express:/api/ee/stale/:id"),
+ ).toHaveLength(0);
expect(
screen.queryByRole("menuitem", { name: /Clear out unused items/ }),
@@ -249,7 +255,9 @@ describe("CollectionMenu", () => {
await assertIndicatorHidden();
await userEvent.click(getIcon("ellipsis"));
- expect(fetchMock.calls("express:/api/ee/stale/:id")).toHaveLength(0);
+ expect(
+ fetchMock.callHistory.calls("express:/api/ee/stale/:id"),
+ ).toHaveLength(0);
expect(
screen.queryByRole("menuitem", { name: /Clear out unused items/ }),
diff --git a/frontend/src/metabase/collections/components/CollectionMenu/tests/setup.tsx b/frontend/src/metabase/collections/components/CollectionMenu/tests/setup.tsx
index 5327b8082d9..5760efd54bf 100644
--- a/frontend/src/metabase/collections/components/CollectionMenu/tests/setup.tsx
+++ b/frontend/src/metabase/collections/components/CollectionMenu/tests/setup.tsx
@@ -112,7 +112,7 @@ export const assertIndicatorVisible = async () => {
};
export const assertIndicatorHidden = async () => {
- await fetchMock.flush();
+ await fetchMock.callHistory.flush();
await waitFor(() =>
expect(screen.queryByTestId("thing-is-loading")).not.toBeInTheDocument(),
);
diff --git a/frontend/src/metabase/collections/components/PinnedQuestionCard/test/PinnedQuestionCard.unit.spec.tsx b/frontend/src/metabase/collections/components/PinnedQuestionCard/test/PinnedQuestionCard.unit.spec.tsx
index c5126a92f16..6353b116b13 100644
--- a/frontend/src/metabase/collections/components/PinnedQuestionCard/test/PinnedQuestionCard.unit.spec.tsx
+++ b/frontend/src/metabase/collections/components/PinnedQuestionCard/test/PinnedQuestionCard.unit.spec.tsx
@@ -12,7 +12,9 @@ describe("PinnedQuestionCard", () => {
expect(await screen.findByTestId("visualization-root")).toBeInTheDocument();
- expect(fetchMock.calls("path:/api/card/1/query")).toHaveLength(1);
+ expect(fetchMock.callHistory.calls("path:/api/card/1/query")).toHaveLength(
+ 1,
+ );
});
});
diff --git a/frontend/src/metabase/common/components/EntityPicker/components/EntityPickerModal/EntityPickerModal.unit.spec.tsx b/frontend/src/metabase/common/components/EntityPicker/components/EntityPickerModal/EntityPickerModal.unit.spec.tsx
index 8170efd75b0..cb09693c148 100644
--- a/frontend/src/metabase/common/components/EntityPicker/components/EntityPickerModal/EntityPickerModal.unit.spec.tsx
+++ b/frontend/src/metabase/common/components/EntityPicker/components/EntityPickerModal/EntityPickerModal.unit.spec.tsx
@@ -85,7 +85,6 @@ const mockSearchResults = createMockSearchResults({
});
const setup = ({
- title = "Pick a thing",
onItemSelect = jest.fn(),
onClose = jest.fn(),
onConfirm = jest.fn(),
@@ -108,7 +107,7 @@ const setup = ({
renderWithProviders(
<EntityPickerModal
- title={title}
+ title={"Pick a thing"}
onItemSelect={onItemSelect}
canSelectItem={true}
onClose={onClose}
diff --git a/frontend/src/metabase/common/components/Pickers/CollectionPicker/components/NewCollectionDialog.unit.spec.tsx b/frontend/src/metabase/common/components/Pickers/CollectionPicker/components/NewCollectionDialog.unit.spec.tsx
index 1eb83c5732f..3712cbaeca3 100644
--- a/frontend/src/metabase/common/components/Pickers/CollectionPicker/components/NewCollectionDialog.unit.spec.tsx
+++ b/frontend/src/metabase/common/components/Pickers/CollectionPicker/components/NewCollectionDialog.unit.spec.tsx
@@ -37,11 +37,11 @@ describe("new collection dialog", () => {
);
await userEvent.click(screen.getByRole("button", { name: "Create" }));
- const apiCalls = fetchMock.calls("path:/api/collection");
+ const apiCalls = fetchMock.callHistory.calls("path:/api/collection");
expect(apiCalls).toHaveLength(1);
- const [_url, options] = apiCalls[0];
- const body = JSON.parse((await options?.body) as string);
+ const call = apiCalls[0];
+ const body = JSON.parse(call.options?.body as string);
expect(body.parent_id).toBe(null);
});
@@ -53,11 +53,11 @@ describe("new collection dialog", () => {
);
await userEvent.click(screen.getByRole("button", { name: "Create" }));
- const apiCalls = fetchMock.calls("path:/api/collection");
+ const apiCalls = fetchMock.callHistory.calls("path:/api/collection");
expect(apiCalls).toHaveLength(1);
- const [_url, options] = apiCalls[0];
- const body = JSON.parse((await options?.body) as string);
+ const call = apiCalls[0];
+ const body = JSON.parse(call.options?.body as string);
expect(body.parent_id).toBe(12);
});
@@ -69,11 +69,11 @@ describe("new collection dialog", () => {
);
await userEvent.click(screen.getByRole("button", { name: "Create" }));
- const apiCalls = fetchMock.calls("path:/api/collection");
+ const apiCalls = fetchMock.callHistory.calls("path:/api/collection");
expect(apiCalls).toHaveLength(1);
- const [_url, options] = apiCalls[0];
- const body = JSON.parse((await options?.body) as string);
+ const call = apiCalls[0];
+ const body = JSON.parse(call.options?.body as string);
expect(body.parent_id).toBe(null);
});
});
diff --git a/frontend/src/metabase/common/components/Pickers/DashboardPicker/components/NewDashboardDialog.unit.spec.tsx b/frontend/src/metabase/common/components/Pickers/DashboardPicker/components/NewDashboardDialog.unit.spec.tsx
index ef08cb9bf23..51417c848e6 100644
--- a/frontend/src/metabase/common/components/Pickers/DashboardPicker/components/NewDashboardDialog.unit.spec.tsx
+++ b/frontend/src/metabase/common/components/Pickers/DashboardPicker/components/NewDashboardDialog.unit.spec.tsx
@@ -37,11 +37,11 @@ describe("new collection dialog", () => {
);
await userEvent.click(screen.getByRole("button", { name: "Create" }));
- const apiCalls = fetchMock.calls("path:/api/dashboard");
+ const apiCalls = fetchMock.callHistory.calls("path:/api/dashboard");
expect(apiCalls).toHaveLength(1);
- const [_url, options] = apiCalls[0];
- const body = JSON.parse((await options?.body) as string);
+ const call = apiCalls[0];
+ const body = JSON.parse(call.options?.body as string);
expect(body.collection_id).toBe(null);
});
@@ -53,11 +53,11 @@ describe("new collection dialog", () => {
);
await userEvent.click(screen.getByRole("button", { name: "Create" }));
- const apiCalls = fetchMock.calls("path:/api/dashboard");
+ const apiCalls = fetchMock.callHistory.calls("path:/api/dashboard");
expect(apiCalls).toHaveLength(1);
- const [_url, options] = apiCalls[0];
- const body = JSON.parse((await options?.body) as string);
+ const call = apiCalls[0];
+ const body = JSON.parse(call.options?.body as string);
expect(body.collection_id).toBe(12);
});
@@ -69,11 +69,11 @@ describe("new collection dialog", () => {
);
await userEvent.click(screen.getByRole("button", { name: "Create" }));
- const apiCalls = fetchMock.calls("path:/api/dashboard");
+ const apiCalls = fetchMock.callHistory.calls("path:/api/dashboard");
expect(apiCalls).toHaveLength(1);
- const [_url, options] = apiCalls[0];
- const body = JSON.parse((await options?.body) as string);
+ const call = apiCalls[0];
+ const body = JSON.parse(call.options?.body as string);
expect(body.collection_id).toBe(null);
});
});
diff --git a/frontend/src/metabase/common/components/Pickers/QuestionPicker/components/QuestionPicker.unit.spec.tsx b/frontend/src/metabase/common/components/Pickers/QuestionPicker/components/QuestionPicker.unit.spec.tsx
index 7821c93d29a..ed19549133d 100644
--- a/frontend/src/metabase/common/components/Pickers/QuestionPicker/components/QuestionPicker.unit.spec.tsx
+++ b/frontend/src/metabase/common/components/Pickers/QuestionPicker/components/QuestionPicker.unit.spec.tsx
@@ -594,7 +594,7 @@ describe("QuestionPickerModal", () => {
});
it("should automatically switch to the search tab when a search query is provided", async () => {
- await setupSearchEndpoints([]);
+ setupSearchEndpoints([]);
await setupModal();
const searchInput = await screen.findByPlaceholderText(/search/i);
@@ -617,7 +617,7 @@ describe("QuestionPickerModal", () => {
});
it("should switch back to the default tab when the search query is cleared", async () => {
- await setupSearchEndpoints([]);
+ setupSearchEndpoints([]);
await setupModal();
const searchInput = await screen.findByPlaceholderText(/search/i);
@@ -649,7 +649,7 @@ describe("QuestionPickerModal", () => {
});
it("should be able to search for metrics", async () => {
- await setupSearchEndpoints([nestedQuestion, myModel, myMetric]);
+ setupSearchEndpoints([nestedQuestion, myModel, myMetric]);
await setupModal({ models: ["card", "dataset", "metric"] });
const searchInput = await screen.findByPlaceholderText(/search/i);
await userEvent.type(searchInput, myMetric.name);
diff --git a/frontend/src/metabase/common/components/SaveQuestionForm/context.unit.spec.tsx b/frontend/src/metabase/common/components/SaveQuestionForm/context.unit.spec.tsx
index ee8b3411bf9..c9209969ce9 100644
--- a/frontend/src/metabase/common/components/SaveQuestionForm/context.unit.spec.tsx
+++ b/frontend/src/metabase/common/components/SaveQuestionForm/context.unit.spec.tsx
@@ -22,7 +22,6 @@ import { SaveQuestionProvider, useSaveQuestionContext } from "./context";
const TestComponent = () => {
const { values, saveToDashboard } = useSaveQuestionContext();
-
return (
<div>
{values.collection_id && (
diff --git a/frontend/src/metabase/common/components/UserCollectionList.unit.spec.tsx b/frontend/src/metabase/common/components/UserCollectionList.unit.spec.tsx
index 442c0051e73..a6853d6fa3e 100644
--- a/frontend/src/metabase/common/components/UserCollectionList.unit.spec.tsx
+++ b/frontend/src/metabase/common/components/UserCollectionList.unit.spec.tsx
@@ -15,8 +15,8 @@ const MockUsers = new Array(100).fill(0).map((_, index) =>
);
const setup = () => {
- fetchMock.get("path:/api/user", (_: any, __: any, request: Request) => {
- const params = new URL(request.url).searchParams;
+ fetchMock.get("path:/api/user", (call) => {
+ const params = new URL(call.url).searchParams;
const limit = parseInt(params.get("limit") ?? "0");
const offset = parseInt(params.get("offset") ?? "0");
return { data: MockUsers.slice(offset, offset + limit) };
diff --git a/frontend/src/metabase/common/hooks/entity-framework/use-entity-list-query/use-entity-list-query.unit.spec.tsx b/frontend/src/metabase/common/hooks/entity-framework/use-entity-list-query/use-entity-list-query.unit.spec.tsx
index 884950af2c9..6d13e8da748 100644
--- a/frontend/src/metabase/common/hooks/entity-framework/use-entity-list-query/use-entity-list-query.unit.spec.tsx
+++ b/frontend/src/metabase/common/hooks/entity-framework/use-entity-list-query/use-entity-list-query.unit.spec.tsx
@@ -124,8 +124,8 @@ describe("useEntityListQuery", () => {
expect(screen.getByText(TEST_DB.name)).toBeInTheDocument();
expect(screen.getByText(TEST_TABLE.name)).toBeInTheDocument();
- expect(fetchMock.calls("path:/api/database")).toHaveLength(1);
- expect(fetchMock.calls("path:/api/table")).toHaveLength(1);
+ expect(fetchMock.callHistory.calls("path:/api/database")).toHaveLength(1);
+ expect(fetchMock.callHistory.calls("path:/api/table")).toHaveLength(1);
});
it("should not reload data when re-rendered", async () => {
@@ -136,8 +136,8 @@ describe("useEntityListQuery", () => {
expect(screen.getByText(TEST_DB.name)).toBeInTheDocument();
expect(screen.getByText(TEST_TABLE.name)).toBeInTheDocument();
- expect(fetchMock.calls("path:/api/database")).toHaveLength(1);
- expect(fetchMock.calls("path:/api/table")).toHaveLength(1);
+ expect(fetchMock.callHistory.calls("path:/api/database")).toHaveLength(1);
+ expect(fetchMock.callHistory.calls("path:/api/table")).toHaveLength(1);
});
it("should reload data only for calls with the reload flag when re-mounted", async () => {
@@ -150,8 +150,8 @@ describe("useEntityListQuery", () => {
expect(screen.getByText(TEST_DB.name)).toBeInTheDocument();
expect(screen.getByText(TEST_TABLE.name)).toBeInTheDocument();
- expect(fetchMock.calls("path:/api/database")).toHaveLength(1);
- expect(fetchMock.calls("path:/api/table")).toHaveLength(2);
+ expect(fetchMock.callHistory.calls("path:/api/database")).toHaveLength(1);
+ expect(fetchMock.callHistory.calls("path:/api/table")).toHaveLength(2);
});
it("should reload data when the reload flag is off and it is explicitly invalidated", async () => {
@@ -161,7 +161,7 @@ describe("useEntityListQuery", () => {
await userEvent.click(screen.getByText("Invalidate databases"));
await waitFor(() => {
- expect(fetchMock.calls("path:/api/database")).toHaveLength(2);
+ expect(fetchMock.callHistory.calls("path:/api/database")).toHaveLength(2);
});
expect(await screen.findByText(TEST_DB.name)).toBeInTheDocument();
});
@@ -173,7 +173,7 @@ describe("useEntityListQuery", () => {
await userEvent.click(screen.getByText("Invalidate tables"));
await waitFor(() => {
- expect(fetchMock.calls("path:/api/table")).toHaveLength(2);
+ expect(fetchMock.callHistory.calls("path:/api/table")).toHaveLength(2);
});
await waitForLoaderToBeRemoved();
@@ -181,17 +181,16 @@ describe("useEntityListQuery", () => {
});
it("should not remove loader in case second api call is cached", async () => {
- fetchMock.get(
- "path:/api/database",
- delay(100).then(() => {
- return [TEST_DB];
- }),
- { overwriteRoutes: true },
- );
-
const { rerender } = setup();
-
- expect(fetchMock.calls("path:/api/database")).toHaveLength(1);
+ fetchMock.modifyRoute("database-list", {
+ response: async () => {
+ await delay(100);
+ return [TEST_DB];
+ },
+ });
+ await waitFor(() => {
+ expect(fetchMock.callHistory.calls("path:/api/database")).toHaveLength(1);
+ });
rerender(
<>
@@ -201,7 +200,7 @@ describe("useEntityListQuery", () => {
);
// second component should not create extra request, make sure that caching works as expected
- expect(fetchMock.calls("path:/api/database")).toHaveLength(1);
+ expect(fetchMock.callHistory.calls("path:/api/database")).toHaveLength(1);
expect(
within(screen.getByTestId("test2")).getByTestId("loading-indicator"),
@@ -211,7 +210,7 @@ describe("useEntityListQuery", () => {
await delay(0); // trigger extra event loop to make sure React state has been updated
- expect(fetchMock.calls("path:/api/database")).toHaveLength(1);
+ expect(fetchMock.callHistory.calls("path:/api/database")).toHaveLength(1);
expect(screen.queryByTestId("loading-indicator")).not.toBeInTheDocument();
});
});
diff --git a/frontend/src/metabase/common/hooks/entity-framework/use-entity-query/use-entity-query.unit.spec.tsx b/frontend/src/metabase/common/hooks/entity-framework/use-entity-query/use-entity-query.unit.spec.tsx
index 5389f3fb496..0d251e31a47 100644
--- a/frontend/src/metabase/common/hooks/entity-framework/use-entity-query/use-entity-query.unit.spec.tsx
+++ b/frontend/src/metabase/common/hooks/entity-framework/use-entity-query/use-entity-query.unit.spec.tsx
@@ -96,8 +96,12 @@ describe("useEntityQuery", () => {
expect(screen.getByText(TEST_DB.name)).toBeInTheDocument();
expect(screen.getByText(TEST_TABLE.name)).toBeInTheDocument();
- expect(fetchMock.calls(`path:/api/database/${TEST_DB.id}`)).toHaveLength(1);
- expect(fetchMock.calls(`path:/api/table/${TEST_TABLE.id}`)).toHaveLength(1);
+ expect(
+ fetchMock.callHistory.calls(`path:/api/database/${TEST_DB.id}`),
+ ).toHaveLength(1);
+ expect(
+ fetchMock.callHistory.calls(`path:/api/table/${TEST_TABLE.id}`),
+ ).toHaveLength(1);
});
it("should not reload data when re-rendered", async () => {
@@ -108,8 +112,12 @@ describe("useEntityQuery", () => {
expect(screen.getByText(TEST_DB.name)).toBeInTheDocument();
expect(screen.getByText(TEST_TABLE.name)).toBeInTheDocument();
- expect(fetchMock.calls(`path:/api/database/${TEST_DB.id}`)).toHaveLength(1);
- expect(fetchMock.calls(`path:/api/table/${TEST_TABLE.id}`)).toHaveLength(1);
+ expect(
+ fetchMock.callHistory.calls(`path:/api/database/${TEST_DB.id}`),
+ ).toHaveLength(1);
+ expect(
+ fetchMock.callHistory.calls(`path:/api/table/${TEST_TABLE.id}`),
+ ).toHaveLength(1);
});
it("should reload data only for calls with the reload flag when re-mounted", async () => {
@@ -122,7 +130,11 @@ describe("useEntityQuery", () => {
expect(screen.getByText(TEST_DB.name)).toBeInTheDocument();
expect(screen.getByText(TEST_TABLE.name)).toBeInTheDocument();
- expect(fetchMock.calls(`path:/api/database/${TEST_DB.id}`)).toHaveLength(1);
- expect(fetchMock.calls(`path:/api/table/${TEST_TABLE.id}`)).toHaveLength(2);
+ expect(
+ fetchMock.callHistory.calls(`path:/api/database/${TEST_DB.id}`),
+ ).toHaveLength(1);
+ expect(
+ fetchMock.callHistory.calls(`path:/api/table/${TEST_TABLE.id}`),
+ ).toHaveLength(2);
});
});
diff --git a/frontend/src/metabase/common/hooks/use-user-key-value.unit.spec.tsx b/frontend/src/metabase/common/hooks/use-user-key-value.unit.spec.tsx
index 7a1ddc1d462..9a4782e1f1e 100644
--- a/frontend/src/metabase/common/hooks/use-user-key-value.unit.spec.tsx
+++ b/frontend/src/metabase/common/hooks/use-user-key-value.unit.spec.tsx
@@ -93,7 +93,7 @@ describe("useUserKeyValue", () => {
describe("setValue", () => {
it("should optimistically update the value and skip refetching", async () => {
- const mockedFetch = setupGetUserKeyValueEndpoint({
+ setupGetUserKeyValueEndpoint({
namespace: "test",
key: "test",
value: "before-value",
@@ -115,7 +115,7 @@ describe("useUserKeyValue", () => {
expect(result.current.value).toBe("before-value");
// set new value
- expect(mockedFetch.calls().length).toBe(1);
+ expect(fetchMock.callHistory.calls().length).toBe(1);
act(() => {
result.current.setValue("after-value");
});
@@ -128,15 +128,18 @@ describe("useUserKeyValue", () => {
});
expect(result.current?.isLoading).toBe(false);
expect(
- mockedFetch.calls(`path:/api/user-key-value/namespace/test/key/test`, {
- method: "GET",
- }),
+ fetchMock.callHistory.calls(
+ `path:/api/user-key-value/namespace/test/key/test`,
+ {
+ method: "GET",
+ },
+ ),
).toHaveLength(1);
expect(result.current.value).toBe("after-value");
});
it("should revert optimisitic update if update fails", async () => {
- const mockedFetch = setupGetUserKeyValueEndpoint({
+ setupGetUserKeyValueEndpoint({
namespace: "test",
key: "test",
value: "before-value",
@@ -154,7 +157,7 @@ describe("useUserKeyValue", () => {
expect(result.current.value).toBe("before-value");
// set new value
- expect(mockedFetch.calls().length).toBe(1);
+ expect(fetchMock.callHistory.calls().length).toBe(1);
act(() => {
result.current.setValue("after-value");
});
@@ -167,9 +170,12 @@ describe("useUserKeyValue", () => {
});
expect(result.current?.isLoading).toBe(false);
expect(
- mockedFetch.calls(`path:/api/user-key-value/namespace/test/key/test`, {
- method: "GET",
- }),
+ fetchMock.callHistory.calls(
+ `path:/api/user-key-value/namespace/test/key/test`,
+ {
+ method: "GET",
+ },
+ ),
).toHaveLength(1);
expect(result.current.value).toBe("before-value");
});
@@ -177,7 +183,7 @@ describe("useUserKeyValue", () => {
describe("clearValue", () => {
it("should optimistically delete a key and skip refetching its value", async () => {
- const mockedFetch = setupGetUserKeyValueEndpoint({
+ setupGetUserKeyValueEndpoint({
namespace: "test",
key: "test",
value: "value",
@@ -195,7 +201,7 @@ describe("useUserKeyValue", () => {
expect(result.current.value).toBe("value");
// set new value
- expect(mockedFetch.calls().length).toBe(1);
+ expect(fetchMock.callHistory.calls().length).toBe(1);
act(() => {
result.current.clearValue();
});
@@ -208,15 +214,18 @@ describe("useUserKeyValue", () => {
});
expect(result.current?.isLoading).toBe(false);
expect(
- mockedFetch.calls(`path:/api/user-key-value/namespace/test/key/test`, {
- method: "GET",
- }),
+ fetchMock.callHistory.calls(
+ `path:/api/user-key-value/namespace/test/key/test`,
+ {
+ method: "GET",
+ },
+ ),
).toHaveLength(1);
expect(result.current.value).toBe(undefined);
});
it("should revert optimisitic delete if deletion fails", async () => {
- const mockedFetch = setupGetUserKeyValueEndpoint({
+ setupGetUserKeyValueEndpoint({
namespace: "test",
key: "test",
value: "before-value",
@@ -234,7 +243,7 @@ describe("useUserKeyValue", () => {
expect(result.current.value).toBe("before-value");
// set new value
- expect(mockedFetch.calls().length).toBe(1);
+ expect(fetchMock.callHistory.calls().length).toBe(1);
act(() => {
result.current.clearValue();
});
@@ -247,9 +256,12 @@ describe("useUserKeyValue", () => {
});
expect(result.current?.isLoading).toBe(false);
expect(
- mockedFetch.calls(`path:/api/user-key-value/namespace/test/key/test`, {
- method: "GET",
- }),
+ fetchMock.callHistory.calls(
+ `path:/api/user-key-value/namespace/test/key/test`,
+ {
+ method: "GET",
+ },
+ ),
).toHaveLength(1);
expect(result.current.value).toBe("before-value");
});
diff --git a/frontend/src/metabase/dashboard/components/AddCardSidebar/AddCardSidebar.unit.spec.tsx b/frontend/src/metabase/dashboard/components/AddCardSidebar/AddCardSidebar.unit.spec.tsx
index cb84c5decdf..d734d2edc1a 100644
--- a/frontend/src/metabase/dashboard/components/AddCardSidebar/AddCardSidebar.unit.spec.tsx
+++ b/frontend/src/metabase/dashboard/components/AddCardSidebar/AddCardSidebar.unit.spec.tsx
@@ -232,19 +232,17 @@ describe("AddCardSideBar", () => {
name: "question in public collection",
model: "card",
});
- fetchMock.get(
- {
- url: "path:/api/search",
- query: {
- ...baseQuery,
- q: typedText,
- filter_items_in_personal_collection: "exclude",
- },
+ fetchMock.get({
+ url: "path:/api/search",
+ query: {
+ ...baseQuery,
+ q: typedText,
+ filter_items_in_personal_collection: "exclude",
},
- {
+ response: {
data: [questionInPublicCollection],
},
- );
+ });
expect(
await screen.findByText(questionInPublicCollection.name),
@@ -304,19 +302,17 @@ describe("AddCardSideBar", () => {
name: "question in public collection",
model: "card",
});
- fetchMock.get(
- {
- url: "path:/api/search",
- query: {
- ...baseQuery,
- q: typedText,
- filter_items_in_personal_collection: "exclude",
- },
+ fetchMock.get({
+ url: "path:/api/search",
+ query: {
+ ...baseQuery,
+ q: typedText,
+ filter_items_in_personal_collection: "exclude",
},
- {
+ response: {
data: [questionInPublicCollection],
},
- );
+ });
expect(
await screen.findByText(questionInPublicCollection.name),
@@ -401,18 +397,16 @@ describe("AddCardSideBar", () => {
name: "question in personal collection",
model: "card",
});
- fetchMock.get(
- {
- url: "path:/api/search",
- query: {
- ...baseQuery,
- q: typedText,
- },
+ fetchMock.get({
+ url: "path:/api/search",
+ query: {
+ ...baseQuery,
+ q: typedText,
},
- {
+ response: {
data: [questionInPublicCollection, questionInPersonalCollection],
},
- );
+ });
expect(
await screen.findByText(questionInPublicCollection.name),
@@ -423,7 +417,7 @@ describe("AddCardSideBar", () => {
// There's no way to math a URL that a query param is not present
// with fetch-mock, so we have to assert it manually.
- const call = fetchMock.lastCall("path:/api/search");
+ const call = fetchMock.callHistory.lastCall("path:/api/search");
const urlObject = new URL(checkNotNull(call?.request?.url));
expect(urlObject.pathname).toEqual("/api/search");
expect(
diff --git a/frontend/src/metabase/dashboard/components/ClickBehaviorSidebar/LinkOptions/LinkedEntityPicker/LinkedEntityPicker.unit.spec.tsx b/frontend/src/metabase/dashboard/components/ClickBehaviorSidebar/LinkOptions/LinkedEntityPicker/LinkedEntityPicker.unit.spec.tsx
index df82b16d5b3..078936dcf6b 100644
--- a/frontend/src/metabase/dashboard/components/ClickBehaviorSidebar/LinkOptions/LinkedEntityPicker/LinkedEntityPicker.unit.spec.tsx
+++ b/frontend/src/metabase/dashboard/components/ClickBehaviorSidebar/LinkOptions/LinkedEntityPicker/LinkedEntityPicker.unit.spec.tsx
@@ -195,7 +195,7 @@ describe("LinkedEntityPicker", () => {
await screen.findByText(dashboardSearchResult.name),
).toBeInTheDocument();
- const call = fetchMock.lastCall("path:/api/search");
+ const call = fetchMock.callHistory.lastCall("path:/api/search");
const urlObject = new URL(checkNotNull(call?.request?.url));
expect(urlObject.pathname).toEqual("/api/search");
expect(urlSearchParamsToObject(urlObject.searchParams)).toEqual({
@@ -256,7 +256,7 @@ describe("LinkedEntityPicker", () => {
await screen.findByText(dashboardSearchResult.name),
).toBeInTheDocument();
- const call = fetchMock.lastCall("path:/api/search");
+ const call = fetchMock.callHistory.lastCall("path:/api/search");
const urlObject = new URL(checkNotNull(call?.request?.url));
expect(urlObject.pathname).toEqual("/api/search");
expect(urlSearchParamsToObject(urlObject.searchParams)).toEqual({
@@ -334,7 +334,7 @@ describe("LinkedEntityPicker", () => {
await screen.findByText(questionSearchResult.name),
).toBeInTheDocument();
- const call = fetchMock.lastCall("path:/api/search");
+ const call = fetchMock.callHistory.lastCall("path:/api/search");
const urlObject = new URL(checkNotNull(call?.request?.url));
expect(urlObject.pathname).toEqual("/api/search");
@@ -398,7 +398,7 @@ describe("LinkedEntityPicker", () => {
await screen.findByText(questionSearchResult.name),
).toBeInTheDocument();
- const call = fetchMock.lastCall("path:/api/search");
+ const call = fetchMock.callHistory.lastCall("path:/api/search");
const urlObject = new URL(checkNotNull(call?.request?.url));
expect(urlObject.pathname).toEqual("/api/search");
expect(urlSearchParamsToObject(urlObject.searchParams)).toEqual({
diff --git a/frontend/src/metabase/dashboard/containers/CreateDashboardModal.unit.spec.tsx b/frontend/src/metabase/dashboard/containers/CreateDashboardModal.unit.spec.tsx
index 0b58406b958..5a56c08f853 100644
--- a/frontend/src/metabase/dashboard/containers/CreateDashboardModal.unit.spec.tsx
+++ b/frontend/src/metabase/dashboard/containers/CreateDashboardModal.unit.spec.tsx
@@ -57,7 +57,7 @@ function setup({ mockCreateDashboardResponse = true } = {}) {
const settings = mockSettings({});
if (mockCreateDashboardResponse) {
- fetchMock.post(`path:/api/dashboard`, (url, options) => options.body);
+ fetchMock.post(`path:/api/dashboard`, (call) => call?.options.body);
}
const collections = Object.values(COLLECTION);
setupCollectionsEndpoints({
diff --git a/frontend/src/metabase/dashboard/containers/DashboardApp/DashboardApp.unit.spec.tsx b/frontend/src/metabase/dashboard/containers/DashboardApp/DashboardApp.unit.spec.tsx
index 5af2c705c73..c3891b90d1a 100644
--- a/frontend/src/metabase/dashboard/containers/DashboardApp/DashboardApp.unit.spec.tsx
+++ b/frontend/src/metabase/dashboard/containers/DashboardApp/DashboardApp.unit.spec.tsx
@@ -248,12 +248,12 @@ describe("DashboardApp", () => {
it("should pass dashboard_load_id to dashboard and query_metadata endpoints", async () => {
const { dashboardId } = await setup();
- const dashboardURL = fetchMock.lastUrl(
+ const dashboardURL = fetchMock.callHistory.lastCall(
`path:/api/dashboard/${dashboardId}`,
- );
- const queryMetadataURL = fetchMock.lastUrl(
+ )?.url;
+ const queryMetadataURL = fetchMock.callHistory.lastCall(
`path:/api/dashboard/${dashboardId}/query_metadata`,
- );
+ )?.url;
const dashboardSearchParams = new URLSearchParams(
dashboardURL?.split("?")[1],
diff --git a/frontend/src/metabase/embedding/components/PublicLinkPopover/DashboardPublicLinkPopover.unit.spec.tsx b/frontend/src/metabase/embedding/components/PublicLinkPopover/DashboardPublicLinkPopover.unit.spec.tsx
index a2e22a33000..f85c9b23ad5 100644
--- a/frontend/src/metabase/embedding/components/PublicLinkPopover/DashboardPublicLinkPopover.unit.spec.tsx
+++ b/frontend/src/metabase/embedding/components/PublicLinkPopover/DashboardPublicLinkPopover.unit.spec.tsx
@@ -4,7 +4,7 @@ import { useState } from "react";
import { setupDashboardPublicLinkEndpoints } from "__support__/server-mocks";
import { mockSettings } from "__support__/settings";
-import { renderWithProviders, screen } from "__support__/ui";
+import { renderWithProviders, screen, waitFor } from "__support__/ui";
import type { Dashboard } from "metabase-types/api";
import { createMockDashboard, createMockUser } from "metabase-types/api/mocks";
import { createMockState } from "metabase-types/store/mocks";
@@ -84,23 +84,31 @@ describe("DashboardPublicLinkPopover", () => {
expect(screen.queryByTestId("extension-option")).not.toBeInTheDocument();
});
- it("should call Dashboard public link API when creating link", () => {
+ it("should call Dashboard public link API when creating link", async () => {
setup({ hasPublicLink: false });
- expect(
- fetchMock.calls(`path:/api/dashboard/${TEST_DASHBOARD_ID}/public_link`, {
- method: "POST",
- }),
- ).toHaveLength(1);
+ await waitFor(() => {
+ expect(
+ fetchMock.callHistory.calls(
+ `path:/api/dashboard/${TEST_DASHBOARD_ID}/public_link`,
+ {
+ method: "POST",
+ },
+ ),
+ ).toHaveLength(1);
+ });
});
it("should call the Dashboard public link API when deleting link", async () => {
setup({ hasPublicLink: true });
await userEvent.click(screen.getByText("Remove public link"));
expect(
- fetchMock.calls(`path:/api/dashboard/${TEST_DASHBOARD_ID}/public_link`, {
- method: "DELETE",
- }),
+ fetchMock.callHistory.calls(
+ `path:/api/dashboard/${TEST_DASHBOARD_ID}/public_link`,
+ {
+ method: "DELETE",
+ },
+ ),
).toHaveLength(1);
});
diff --git a/frontend/src/metabase/embedding/components/PublicLinkPopover/QuestionPublicLinkPopover.unit.spec.tsx b/frontend/src/metabase/embedding/components/PublicLinkPopover/QuestionPublicLinkPopover.unit.spec.tsx
index b2c3b030d3e..7e6dc8c0d3c 100644
--- a/frontend/src/metabase/embedding/components/PublicLinkPopover/QuestionPublicLinkPopover.unit.spec.tsx
+++ b/frontend/src/metabase/embedding/components/PublicLinkPopover/QuestionPublicLinkPopover.unit.spec.tsx
@@ -41,7 +41,7 @@ const TestComponent = ({
);
};
-const setup = ({
+const setup = async ({
hasPublicLink = true,
isAdmin = true,
}: {
@@ -73,19 +73,21 @@ const setup = ({
renderWithProviders(<TestComponent question={question} onClose={onClose} />, {
storeInitialState: state,
});
+
+ await screen.findByText("Public link");
};
describe("QuestionPublicLinkPopover", () => {
it("should display a question-specific public url", async () => {
- setup();
+ await setup();
expect(
await screen.findByDisplayValue(`${SITE_URL}/public/question/mock-uuid`),
).toBeInTheDocument();
});
- it("should display extensions for the public link", () => {
- setup();
+ it("should display extensions for the public link", async () => {
+ await setup();
const extensionOptions = screen.getAllByTestId("extension-option");
@@ -97,28 +99,34 @@ describe("QuestionPublicLinkPopover", () => {
]);
});
- it("should call Card public link API when creating link", () => {
- setup({ hasPublicLink: false });
+ it("should call Card public link API when creating link", async () => {
+ await setup({ hasPublicLink: false });
expect(
- fetchMock.calls(`path:/api/card/${TEST_CARD_ID}/public_link`, {
- method: "POST",
- }),
+ fetchMock.callHistory.calls(
+ `path:/api/card/${TEST_CARD_ID}/public_link`,
+ {
+ method: "POST",
+ },
+ ),
).toHaveLength(1);
});
it("should call the Card public link API when deleting link", async () => {
- setup({ hasPublicLink: true });
+ await setup({ hasPublicLink: true });
await userEvent.click(screen.getByText("Remove public link"));
expect(
- fetchMock.calls(`path:/api/card/${TEST_CARD_ID}/public_link`, {
- method: "DELETE",
- }),
+ fetchMock.callHistory.calls(
+ `path:/api/card/${TEST_CARD_ID}/public_link`,
+ {
+ method: "DELETE",
+ },
+ ),
).toHaveLength(1);
});
- it("should not show non-admins the option to remove a public link", () => {
- setup({ isAdmin: false });
+ it("should not show non-admins the option to remove a public link", async () => {
+ await setup({ isAdmin: false });
expect(screen.queryByText("Remove public link")).not.toBeInTheDocument();
});
diff --git a/frontend/src/metabase/entities/model-indexes/actions.unit.spec.ts b/frontend/src/metabase/entities/model-indexes/actions.unit.spec.ts
index 13691df7037..001d8befd07 100644
--- a/frontend/src/metabase/entities/model-indexes/actions.unit.spec.ts
+++ b/frontend/src/metabase/entities/model-indexes/actions.unit.spec.ts
@@ -74,7 +74,7 @@ describe("Entities > model-indexes > actions", () => {
const { dispatch } = setup();
await updateModelIndexes(model)(dispatch);
- const calls = fetchMock.calls();
+ const calls = fetchMock.callHistory.calls();
// No API calls to fetch model indexes
expect(calls).toHaveLength(0);
@@ -96,15 +96,16 @@ describe("Entities > model-indexes > actions", () => {
await updateModelIndexes(model)(dispatch);
- const createCalls = await fetchMock.calls("createModelIndex");
+ const createCalls = fetchMock.callHistory.calls("createModelIndex");
expect(createCalls).toHaveLength(1);
- const [, options] = createCalls[0];
+ const call = createCalls[0];
+ const options = call.options;
expect(options?.method).toBe("POST");
// @ts-expect-error ???
- const body = JSON.parse(await options?.body) as Partial<ModelIndex>;
+ const body = JSON.parse(options?.body) as Partial<ModelIndex>;
expect(body.model_id).toBe(model.id());
expect(body.pk_ref).toEqual(pkFieldRef);
expect(body.value_ref).toEqual(indexFieldRef);
@@ -132,11 +133,13 @@ describe("Entities > model-indexes > actions", () => {
await updateModelIndexes(model)(dispatch);
- const deleteCalls = fetchMock.calls("deleteModelIndex");
+ const deleteCalls = fetchMock.callHistory.calls("deleteModelIndex");
expect(deleteCalls).toHaveLength(1);
- const [url, options] = deleteCalls[0];
+ const deleteCall = deleteCalls[0];
+ const url = deleteCall.url;
+ const options = deleteCall.options;
expect(url).toContain("/api/model-index/99");
expect(options?.method).toBe("DELETE");
@@ -163,8 +166,10 @@ describe("Entities > model-indexes > actions", () => {
await updateModelIndexes(model)(dispatch);
- const fetchCalls = await fetchMock.calls(`getModelIndexes-${model.id()}`);
- const createCalls = await fetchMock.calls("createModelIndex");
+ const fetchCalls = fetchMock.callHistory.calls(
+ `getModelIndexes-${model.id()}`,
+ );
+ const createCalls = fetchMock.callHistory.calls("createModelIndex");
// no calls to Create
expect(createCalls).toHaveLength(0);
@@ -188,8 +193,10 @@ describe("Entities > model-indexes > actions", () => {
await updateModelIndexes(model)(dispatch);
- const fetchCalls = await fetchMock.calls(`getModelIndexes-${model.id()}`);
- const deleteCalls = fetchMock.calls("deleteModelIndex");
+ const fetchCalls = fetchMock.callHistory.calls(
+ `getModelIndexes-${model.id()}`,
+ );
+ const deleteCalls = fetchMock.callHistory.calls("deleteModelIndex");
// Expect 1 fetch for model indexes
expect(fetchCalls).toHaveLength(1);
diff --git a/frontend/src/metabase/home/components/EmbedHomepage/tests/setup.tsx b/frontend/src/metabase/home/components/EmbedHomepage/tests/setup.tsx
index 22e9e7a4f52..369ca67d545 100644
--- a/frontend/src/metabase/home/components/EmbedHomepage/tests/setup.tsx
+++ b/frontend/src/metabase/home/components/EmbedHomepage/tests/setup.tsx
@@ -60,12 +60,12 @@ export async function setup({
}
export const getLastHomepageSettingSettingCall = () =>
- fetchMock.lastCall("path:/api/setting/embedding-homepage", {
+ fetchMock.callHistory.lastCall("path:/api/setting/embedding-homepage", {
method: "PUT",
});
export const getLastFeedbackCall = () =>
- fetchMock.lastCall("path:/api/product-feedback", {
+ fetchMock.callHistory.lastCall("path:/api/product-feedback", {
method: "POST",
});
diff --git a/frontend/src/metabase/metadata/components/DiscardFieldValuesButton/DiscardFieldValuesButton.unit.spec.tsx b/frontend/src/metabase/metadata/components/DiscardFieldValuesButton/DiscardFieldValuesButton.unit.spec.tsx
index d8cb1db9d62..d5e484dab63 100644
--- a/frontend/src/metabase/metadata/components/DiscardFieldValuesButton/DiscardFieldValuesButton.unit.spec.tsx
+++ b/frontend/src/metabase/metadata/components/DiscardFieldValuesButton/DiscardFieldValuesButton.unit.spec.tsx
@@ -43,9 +43,12 @@ describe("DiscardFieldValuesButton", () => {
await userEvent.click(button);
expect(
- fetchMock.calls(`path:/api/field/${field.id}/discard_values`, {
- method: "POST",
- }),
+ fetchMock.callHistory.calls(
+ `path:/api/field/${field.id}/discard_values`,
+ {
+ method: "POST",
+ },
+ ),
).toHaveLength(1);
await waitFor(() => {
expect(button).toHaveTextContent("Discard triggered!");
@@ -65,9 +68,12 @@ describe("DiscardFieldValuesButton", () => {
await userEvent.click(button);
expect(
- fetchMock.calls(`path:/api/field/${field.id}/discard_values`, {
- method: "POST",
- }),
+ fetchMock.callHistory.calls(
+ `path:/api/field/${field.id}/discard_values`,
+ {
+ method: "POST",
+ },
+ ),
).toHaveLength(1);
await waitFor(() => {
expect(button).toHaveTextContent("Discard triggered!");
@@ -80,9 +86,12 @@ describe("DiscardFieldValuesButton", () => {
expect(button).toHaveTextContent("Discard triggered!");
await userEvent.click(button);
expect(
- fetchMock.calls(`path:/api/field/${field.id}/discard_values`, {
- method: "POST",
- }),
+ fetchMock.callHistory.calls(
+ `path:/api/field/${field.id}/discard_values`,
+ {
+ method: "POST",
+ },
+ ),
).toHaveLength(2);
await act(() => {
@@ -101,20 +110,21 @@ describe("DiscardFieldValuesButton", () => {
it("should show error message toast", async () => {
const { field } = setup();
- fetchMock.post(
- `path:/api/field/${field.id}/discard_values`,
- { status: 500 },
- { overwriteRoutes: true },
- );
+ fetchMock.modifyRoute(`field-${field.id}-discard-values`, {
+ response: { status: 500 },
+ });
const button = screen.getByRole("button");
expect(button).toHaveTextContent("Discard cached field values");
await userEvent.click(button);
expect(
- fetchMock.calls(`path:/api/field/${field.id}/discard_values`, {
- method: "POST",
- }),
+ fetchMock.callHistory.calls(
+ `path:/api/field/${field.id}/discard_values`,
+ {
+ method: "POST",
+ },
+ ),
).toHaveLength(1);
await waitFor(() => {
expect(button).toHaveTextContent("Discard cached field values");
diff --git a/frontend/src/metabase/metadata/components/DiscardTableFieldValuesButton/DiscardTableFieldValuesButton.unit.spec.tsx b/frontend/src/metabase/metadata/components/DiscardTableFieldValuesButton/DiscardTableFieldValuesButton.unit.spec.tsx
index ae507693b6e..974a549284a 100644
--- a/frontend/src/metabase/metadata/components/DiscardTableFieldValuesButton/DiscardTableFieldValuesButton.unit.spec.tsx
+++ b/frontend/src/metabase/metadata/components/DiscardTableFieldValuesButton/DiscardTableFieldValuesButton.unit.spec.tsx
@@ -42,9 +42,12 @@ describe("DiscardTableFieldValuesButton", () => {
await userEvent.click(button);
expect(
- fetchMock.calls(`path:/api/table/${table.id}/discard_values`, {
- method: "POST",
- }),
+ fetchMock.callHistory.calls(
+ `path:/api/table/${table.id}/discard_values`,
+ {
+ method: "POST",
+ },
+ ),
).toHaveLength(1);
await waitFor(() => {
expect(button).toHaveTextContent("Discard triggered!");
@@ -64,9 +67,12 @@ describe("DiscardTableFieldValuesButton", () => {
await userEvent.click(button);
expect(
- fetchMock.calls(`path:/api/table/${table.id}/discard_values`, {
- method: "POST",
- }),
+ fetchMock.callHistory.calls(
+ `path:/api/table/${table.id}/discard_values`,
+ {
+ method: "POST",
+ },
+ ),
).toHaveLength(1);
await waitFor(() => {
expect(button).toHaveTextContent("Discard triggered!");
@@ -79,9 +85,12 @@ describe("DiscardTableFieldValuesButton", () => {
expect(button).toHaveTextContent("Discard triggered!");
await userEvent.click(button);
expect(
- fetchMock.calls(`path:/api/table/${table.id}/discard_values`, {
- method: "POST",
- }),
+ fetchMock.callHistory.calls(
+ `path:/api/table/${table.id}/discard_values`,
+ {
+ method: "POST",
+ },
+ ),
).toHaveLength(2);
await act(() => {
@@ -100,20 +109,21 @@ describe("DiscardTableFieldValuesButton", () => {
it("should show error message toast", async () => {
const { table } = setup();
- fetchMock.post(
- `path:/api/table/${table.id}/discard_values`,
- { status: 500 },
- { overwriteRoutes: true },
- );
+ fetchMock.modifyRoute(`table-${table.id}-discard-values`, {
+ response: { status: 500 },
+ });
const button = screen.getByRole("button");
expect(button).toHaveTextContent("Discard cached field values");
await userEvent.click(button);
expect(
- fetchMock.calls(`path:/api/table/${table.id}/discard_values`, {
- method: "POST",
- }),
+ fetchMock.callHistory.calls(
+ `path:/api/table/${table.id}/discard_values`,
+ {
+ method: "POST",
+ },
+ ),
).toHaveLength(1);
await waitFor(() => {
expect(button).toHaveTextContent("Discard cached field values");
diff --git a/frontend/src/metabase/metadata/components/RescanFieldButton/RescanFieldButton.unit.spec.tsx b/frontend/src/metabase/metadata/components/RescanFieldButton/RescanFieldButton.unit.spec.tsx
index 3bdcc015442..db2ee813967 100644
--- a/frontend/src/metabase/metadata/components/RescanFieldButton/RescanFieldButton.unit.spec.tsx
+++ b/frontend/src/metabase/metadata/components/RescanFieldButton/RescanFieldButton.unit.spec.tsx
@@ -43,7 +43,7 @@ describe("RescanFieldButton", () => {
await userEvent.click(button);
expect(
- fetchMock.calls(`path:/api/field/${field.id}/rescan_values`, {
+ fetchMock.callHistory.calls(`path:/api/field/${field.id}/rescan_values`, {
method: "POST",
}),
).toHaveLength(1);
@@ -65,7 +65,7 @@ describe("RescanFieldButton", () => {
await userEvent.click(button);
expect(
- fetchMock.calls(`path:/api/field/${field.id}/rescan_values`, {
+ fetchMock.callHistory.calls(`path:/api/field/${field.id}/rescan_values`, {
method: "POST",
}),
).toHaveLength(1);
@@ -80,7 +80,7 @@ describe("RescanFieldButton", () => {
expect(button).toHaveTextContent("Scan triggered!");
await userEvent.click(button);
expect(
- fetchMock.calls(`path:/api/field/${field.id}/rescan_values`, {
+ fetchMock.callHistory.calls(`path:/api/field/${field.id}/rescan_values`, {
method: "POST",
}),
).toHaveLength(2);
@@ -101,18 +101,16 @@ describe("RescanFieldButton", () => {
it("should show error message toast", async () => {
const { field } = setup();
- fetchMock.post(
- `path:/api/field/${field.id}/rescan_values`,
- { status: 500 },
- { overwriteRoutes: true },
- );
+ fetchMock.modifyRoute(`field-${field.id}-rescan-values`, {
+ response: { status: 500 },
+ });
const button = screen.getByRole("button");
expect(button).toHaveTextContent("Re-scan field");
await userEvent.click(button);
expect(
- fetchMock.calls(`path:/api/field/${field.id}/rescan_values`, {
+ fetchMock.callHistory.calls(`path:/api/field/${field.id}/rescan_values`, {
method: "POST",
}),
).toHaveLength(1);
diff --git a/frontend/src/metabase/metadata/components/RescanTableFieldsButton/RescanTableFieldsButton.unit.spec.tsx b/frontend/src/metabase/metadata/components/RescanTableFieldsButton/RescanTableFieldsButton.unit.spec.tsx
index 4ffe3901add..dcb91885c6c 100644
--- a/frontend/src/metabase/metadata/components/RescanTableFieldsButton/RescanTableFieldsButton.unit.spec.tsx
+++ b/frontend/src/metabase/metadata/components/RescanTableFieldsButton/RescanTableFieldsButton.unit.spec.tsx
@@ -42,7 +42,7 @@ describe("RescanTableFieldsButton", () => {
await userEvent.click(button);
expect(
- fetchMock.calls(`path:/api/table/${table.id}/rescan_values`, {
+ fetchMock.callHistory.calls(`path:/api/table/${table.id}/rescan_values`, {
method: "POST",
}),
).toHaveLength(1);
@@ -64,7 +64,7 @@ describe("RescanTableFieldsButton", () => {
await userEvent.click(button);
expect(
- fetchMock.calls(`path:/api/table/${table.id}/rescan_values`, {
+ fetchMock.callHistory.calls(`path:/api/table/${table.id}/rescan_values`, {
method: "POST",
}),
).toHaveLength(1);
@@ -79,7 +79,7 @@ describe("RescanTableFieldsButton", () => {
expect(button).toHaveTextContent("Scan triggered!");
await userEvent.click(button);
expect(
- fetchMock.calls(`path:/api/table/${table.id}/rescan_values`, {
+ fetchMock.callHistory.calls(`path:/api/table/${table.id}/rescan_values`, {
method: "POST",
}),
).toHaveLength(2);
@@ -100,18 +100,16 @@ describe("RescanTableFieldsButton", () => {
it("should show error message toast", async () => {
const { table } = setup();
- fetchMock.post(
- `path:/api/table/${table.id}/rescan_values`,
- { status: 500 },
- { overwriteRoutes: true },
- );
+ fetchMock.modifyRoute(`table-${table.id}-rescan-values`, {
+ response: { status: 500 },
+ });
const button = screen.getByRole("button");
expect(button).toHaveTextContent("Re-scan table");
await userEvent.click(button);
expect(
- fetchMock.calls(`path:/api/table/${table.id}/rescan_values`, {
+ fetchMock.callHistory.calls(`path:/api/table/${table.id}/rescan_values`, {
method: "POST",
}),
).toHaveLength(1);
diff --git a/frontend/src/metabase/metadata/components/SyncTableSchemaButton/SyncTableSchemaButton.unit.spec.tsx b/frontend/src/metabase/metadata/components/SyncTableSchemaButton/SyncTableSchemaButton.unit.spec.tsx
index bcc9c053a19..b2aa5f28c0a 100644
--- a/frontend/src/metabase/metadata/components/SyncTableSchemaButton/SyncTableSchemaButton.unit.spec.tsx
+++ b/frontend/src/metabase/metadata/components/SyncTableSchemaButton/SyncTableSchemaButton.unit.spec.tsx
@@ -42,7 +42,7 @@ describe("SyncTableSchemaButton", () => {
await userEvent.click(button);
expect(
- fetchMock.calls(`path:/api/table/${table.id}/sync_schema`, {
+ fetchMock.callHistory.calls(`path:/api/table/${table.id}/sync_schema`, {
method: "POST",
}),
).toHaveLength(1);
@@ -64,7 +64,7 @@ describe("SyncTableSchemaButton", () => {
await userEvent.click(button);
expect(
- fetchMock.calls(`path:/api/table/${table.id}/sync_schema`, {
+ fetchMock.callHistory.calls(`path:/api/table/${table.id}/sync_schema`, {
method: "POST",
}),
).toHaveLength(1);
@@ -79,7 +79,7 @@ describe("SyncTableSchemaButton", () => {
expect(button).toHaveTextContent("Sync triggered!");
await userEvent.click(button);
expect(
- fetchMock.calls(`path:/api/table/${table.id}/sync_schema`, {
+ fetchMock.callHistory.calls(`path:/api/table/${table.id}/sync_schema`, {
method: "POST",
}),
).toHaveLength(2);
@@ -100,18 +100,16 @@ describe("SyncTableSchemaButton", () => {
it("should show error message toast", async () => {
const { table } = setup();
- fetchMock.post(
- `path:/api/table/${table.id}/sync_schema`,
- { status: 500 },
- { overwriteRoutes: true },
- );
+ fetchMock.modifyRoute(`table-${table.id}-sync-schema`, {
+ response: { status: 500 },
+ });
const button = screen.getByRole("button");
expect(button).toHaveTextContent("Sync table schema");
await userEvent.click(button);
expect(
- fetchMock.calls(`path:/api/table/${table.id}/sync_schema`, {
+ fetchMock.callHistory.calls(`path:/api/table/${table.id}/sync_schema`, {
method: "POST",
}),
).toHaveLength(1);
diff --git a/frontend/src/metabase/metadata/pages/DataModel/DataModel.unit.spec.tsx b/frontend/src/metabase/metadata/pages/DataModel/DataModel.unit.spec.tsx
index 7baa62f0824..2bd2768dc85 100644
--- a/frontend/src/metabase/metadata/pages/DataModel/DataModel.unit.spec.tsx
+++ b/frontend/src/metabase/metadata/pages/DataModel/DataModel.unit.spec.tsx
@@ -202,12 +202,9 @@ async function setup({
}
if (unauthorizedField) {
- setupUnauthorizedFieldEndpoint(unauthorizedField, {
- overwriteRoutes: true,
- });
+ setupUnauthorizedFieldEndpoint(unauthorizedField);
setupUnauthorizedFieldValuesEndpoints(
getRawTableFieldId(unauthorizedField),
- { overwriteRoutes: true },
);
}
@@ -297,19 +294,16 @@ describe("DataModel", () => {
it("should allow to search for a table", async () => {
await setup();
- setupSearchEndpoints(
- [
- createMockSearchResult({
- id: getNextId(),
- model: "table",
- name: ORDERS_TABLE.display_name,
- table_name: ORDERS_TABLE.display_name,
- table_schema: "public",
- database_name: SAMPLE_DB.name,
- }),
- ],
- { overwriteRoutes: true },
- );
+ setupSearchEndpoints([
+ createMockSearchResult({
+ id: getNextId(),
+ model: "table",
+ name: ORDERS_TABLE.display_name,
+ table_name: ORDERS_TABLE.display_name,
+ table_schema: "public",
+ database_name: SAMPLE_DB.name,
+ }),
+ ]);
const searchValue = ORDERS_TABLE.name.substring(0, 3);
await userEvent.type(getTableSearchInput(), searchValue);
@@ -711,7 +705,9 @@ describe("DataModel", () => {
await waitFor(() => {
const path = `path:/api/table/${ORDERS_TABLE.id}/rescan_values`;
- expect(fetchMock.called(path, { method: "POST" })).toBeTruthy();
+ expect(
+ fetchMock.callHistory.called(path, { method: "POST" }),
+ ).toBeTruthy();
});
});
@@ -733,7 +729,9 @@ describe("DataModel", () => {
await waitFor(() => {
const path = `path:/api/table/${ORDERS_TABLE.id}/discard_values`;
- expect(fetchMock.called(path, { method: "POST" })).toBeTruthy();
+ expect(
+ fetchMock.callHistory.called(path, { method: "POST" }),
+ ).toBeTruthy();
});
});
});
@@ -876,7 +874,9 @@ describe("DataModel", () => {
hasFieldValuesAccess: false,
unauthorizedField: ORDERS_QUANTITY_FIELD,
});
- setupDatabaseIdFieldsEndpoints(SAMPLE_DB, { overwriteRoutes: true });
+ setupDatabaseIdFieldsEndpoints({
+ database: SAMPLE_DB,
+ });
expect(screen.getByText("Custom mapping")).toBeInTheDocument();
expect(
@@ -905,7 +905,9 @@ describe("DataModel", () => {
await waitFor(() => {
const path = `path:/api/field/${ORDERS_ID_FIELD.id}/rescan_values`;
- expect(fetchMock.called(path, { method: "POST" })).toBeTruthy();
+ expect(
+ fetchMock.callHistory.called(path, { method: "POST" }),
+ ).toBeTruthy();
});
});
@@ -928,7 +930,9 @@ describe("DataModel", () => {
await waitFor(() => {
const path = `path:/api/field/${ORDERS_ID_FIELD.id}/discard_values`;
- expect(fetchMock.called(path, { method: "POST" })).toBeTruthy();
+ expect(
+ fetchMock.callHistory.called(path, { method: "POST" }),
+ ).toBeTruthy();
});
});
});
diff --git a/frontend/src/metabase/metadata/pages/DataModel/components/TablePicker/TableVisibilityToggle.unit.spec.tsx b/frontend/src/metabase/metadata/pages/DataModel/components/TablePicker/TableVisibilityToggle.unit.spec.tsx
index 9852b815706..ca24ac1a99e 100644
--- a/frontend/src/metabase/metadata/pages/DataModel/components/TablePicker/TableVisibilityToggle.unit.spec.tsx
+++ b/frontend/src/metabase/metadata/pages/DataModel/components/TablePicker/TableVisibilityToggle.unit.spec.tsx
@@ -48,17 +48,18 @@ describe("TableVisibilityToggle", () => {
await userEvent.click(toggle);
expect(
- fetchMock.calls(`path:/api/table/${VISIBLE_TABLE.id}`, {
+ fetchMock.callHistory.calls(`path:/api/table/${VISIBLE_TABLE.id}`, {
method: "PUT",
}),
).toHaveLength(1);
- const body = await (fetchMock.calls(
+ const call = fetchMock.callHistory.calls(
`path:/api/table/${VISIBLE_TABLE.id}`,
{
method: "PUT",
},
- )[0][1]?.body as unknown as Promise<string>);
+ )[0];
+ const body = await (call.options?.body as unknown as Promise<string>);
expect(JSON.parse(body)).toEqual({ visibility_type: "hidden" });
@@ -73,18 +74,16 @@ describe("TableVisibilityToggle", () => {
table: VISIBLE_TABLE,
});
- fetchMock.put(
- `path:/api/table/${VISIBLE_TABLE.id}`,
- { status: 500 },
- { overwriteRoutes: true },
- );
+ fetchMock.modifyRoute(`table-${VISIBLE_TABLE.id}-put`, {
+ response: { status: 500 },
+ });
const toggle = screen.getByLabelText("eye icon");
expect(toggle).toBeInTheDocument();
await userEvent.click(toggle);
expect(
- fetchMock.calls(`path:/api/table/${VISIBLE_TABLE.id}`, {
+ fetchMock.callHistory.calls(`path:/api/table/${VISIBLE_TABLE.id}`, {
method: "PUT",
}),
).toHaveLength(1);
@@ -125,17 +124,18 @@ describe("TableVisibilityToggle", () => {
await userEvent.click(toggle);
expect(
- fetchMock.calls(`path:/api/table/${HIDDEN_TABLE.id}`, {
+ fetchMock.callHistory.calls(`path:/api/table/${HIDDEN_TABLE.id}`, {
method: "PUT",
}),
).toHaveLength(1);
- const body = await (fetchMock.calls(
+ const call = fetchMock.callHistory.calls(
`path:/api/table/${HIDDEN_TABLE.id}`,
{
method: "PUT",
},
- )[0][1]?.body as unknown as Promise<string>);
+ )[0];
+ const body = await (call.options?.body as unknown as Promise<string>);
expect(JSON.parse(body)).toEqual({ visibility_type: null });
@@ -150,10 +150,11 @@ describe("TableVisibilityToggle", () => {
table: HIDDEN_TABLE,
});
+ fetchMock.removeRoute(`table-${HIDDEN_TABLE.id}-put`);
fetchMock.put(
`path:/api/table/${HIDDEN_TABLE.id}`,
{ status: 500 },
- { overwriteRoutes: true },
+ { name: `table-${HIDDEN_TABLE.id}-put` },
);
const toggle = screen.getByLabelText("eye_crossed_out icon");
@@ -161,7 +162,7 @@ describe("TableVisibilityToggle", () => {
await userEvent.click(toggle);
expect(
- fetchMock.calls(`path:/api/table/${HIDDEN_TABLE.id}`, {
+ fetchMock.callHistory.calls(`path:/api/table/${HIDDEN_TABLE.id}`, {
method: "PUT",
}),
).toHaveLength(1);
diff --git a/frontend/src/metabase/models/containers/ModelActions/ModelActions.unit.spec.tsx b/frontend/src/metabase/models/containers/ModelActions/ModelActions.unit.spec.tsx
index c9a868b59b5..e9f0bb75216 100644
--- a/frontend/src/metabase/models/containers/ModelActions/ModelActions.unit.spec.tsx
+++ b/frontend/src/metabase/models/containers/ModelActions/ModelActions.unit.spec.tsx
@@ -200,13 +200,11 @@ async function setup({
setupDatabasesEndpoints(databases);
- fetchMock.get(
- {
- url: "path:/api/card",
- query: { f: "using_model", model_id: card.id },
- },
- usedBy,
- );
+ fetchMock.get({
+ url: "path:/api/card",
+ query: { f: "using_model", model_id: card.id },
+ response: usedBy,
+ });
setupCardsEndpoints([card]);
setupCardQueryMetadataEndpoint(
@@ -438,11 +436,16 @@ describe("ModelActions", () => {
);
expect(
- fetchMock.calls(`path:/api/action/${action.id}`, { method: "PUT" }),
+ fetchMock.callHistory.calls(`path:/api/action/${action.id}`, {
+ method: "PUT",
+ }),
).toHaveLength(1);
- const call = fetchMock.lastCall(`path:/api/action/${action.id}`, {
- method: "PUT",
- });
+ const call = fetchMock.callHistory.lastCall(
+ `path:/api/action/${action.id}`,
+ {
+ method: "PUT",
+ },
+ );
expect(await call?.request?.json()).toEqual({
id: action.id,
archived: true,
@@ -472,7 +475,7 @@ describe("ModelActions", () => {
for (const action of actions) {
expect(
- fetchMock.called(`path:/api/action/${action.id}`, {
+ fetchMock.callHistory.called(`path:/api/action/${action.id}`, {
method: "DELETE",
}),
).toBe(true);
@@ -580,14 +583,17 @@ describe("ModelActions", () => {
it("allows to create implicit actions", async () => {
const action = createMockQueryAction({ model_id: modelCard.id });
await setupActions({ model: modelCard, actions: [action] });
- fetchMock.post("path:/api/action", {}, { overwriteRoutes: true });
+ fetchMock.modifyRoute("action-post", { response: {} });
await userEvent.click(screen.getByLabelText("Actions menu"));
await userEvent.click(await screen.findByText("Create basic actions"));
- const createActionCalls = fetchMock.calls("path:/api/action", {
- method: "POST",
- });
+ const createActionCalls = fetchMock.callHistory.calls(
+ "path:/api/action",
+ {
+ method: "POST",
+ },
+ );
expect(createActionCalls).toHaveLength(3);
expect(await createActionCalls[0].request?.json()).toEqual({
@@ -612,15 +618,18 @@ describe("ModelActions", () => {
it("allows to create implicit actions from the empty state", async () => {
await setupActions({ model: modelCard, actions: [] });
- fetchMock.post("path:/api/action", {}, { overwriteRoutes: true });
+ fetchMock.modifyRoute("action-post", { response: {} });
await userEvent.click(
screen.getByRole("button", { name: /Create basic action/i }),
);
- const createActionCalls = fetchMock.calls("path:/api/action", {
- method: "POST",
- });
+ const createActionCalls = fetchMock.callHistory.calls(
+ "path:/api/action",
+ {
+ method: "POST",
+ },
+ );
expect(createActionCalls).toHaveLength(3);
expect(await createActionCalls[0].request?.json()).toEqual({
diff --git a/frontend/src/metabase/models/containers/NewModelOptions/tests/common.unit.spec.tsx b/frontend/src/metabase/models/containers/NewModelOptions/tests/common.unit.spec.tsx
index 613f4463b9c..2d9c5139aae 100644
--- a/frontend/src/metabase/models/containers/NewModelOptions/tests/common.unit.spec.tsx
+++ b/frontend/src/metabase/models/containers/NewModelOptions/tests/common.unit.spec.tsx
@@ -24,7 +24,6 @@ describe("NewModelOptions (OSS)", () => {
delay(2000).then(() => {
return [createMockDatabase()];
}),
- { overwriteRoutes: true },
);
expect(screen.getByTestId("loading-indicator")).toBeInTheDocument();
diff --git a/frontend/src/metabase/nav/components/LicenseTokenMissingBanner/useLicenseTokenMissingBanner.unit.spec.ts b/frontend/src/metabase/nav/components/LicenseTokenMissingBanner/useLicenseTokenMissingBanner.unit.spec.ts
index eb166c35228..ed24b1d1169 100644
--- a/frontend/src/metabase/nav/components/LicenseTokenMissingBanner/useLicenseTokenMissingBanner.unit.spec.ts
+++ b/frontend/src/metabase/nav/components/LicenseTokenMissingBanner/useLicenseTokenMissingBanner.unit.spec.ts
@@ -1,5 +1,4 @@
import { act } from "@testing-library/react";
-import fetchMock from "fetch-mock";
import { setupEnterprisePlugins } from "__support__/enterprise";
import {
@@ -161,7 +160,6 @@ describe("useLicenseTokenMissingBanner", () => {
};
beforeEach(() => {
- fetchMock.reset();
jest.useFakeTimers();
jest.setSystemTime(NOW);
});
diff --git a/frontend/src/metabase/nav/components/WhatsNewNotification/WhatsNewNotification.unit.spec.tsx b/frontend/src/metabase/nav/components/WhatsNewNotification/WhatsNewNotification.unit.spec.tsx
index c743f805160..7b9588a35dd 100644
--- a/frontend/src/metabase/nav/components/WhatsNewNotification/WhatsNewNotification.unit.spec.tsx
+++ b/frontend/src/metabase/nav/components/WhatsNewNotification/WhatsNewNotification.unit.spec.tsx
@@ -157,23 +157,21 @@ describe("WhatsNewNotification", () => {
dismissButton.click();
await waitFor(() => {
- expect(fetchMock.called(LAST_ACK_SETTINGS_URL)).toBe(true);
+ expect(fetchMock.callHistory.called(LAST_ACK_SETTINGS_URL)).toBe(true);
});
await waitFor(() => {
- const fetchOptions = fetchMock.lastOptions(LAST_ACK_SETTINGS_URL);
- expect(fetchOptions?.method).toBe("PUT");
+ const calls = fetchMock.callHistory.calls(LAST_ACK_SETTINGS_URL);
+ const lastCall = calls[calls.length - 1];
+ expect(lastCall?.request?.method).toBe("PUT");
});
await waitFor(async () => {
- const fetchOptions = fetchMock.lastOptions(LAST_ACK_SETTINGS_URL);
- expect(
- JSON.parse(await (fetchOptions?.body as Promise<string>)),
- ).toEqual({ value: currentVersionTag });
+ const lastCall = fetchMock.callHistory.lastCall(LAST_ACK_SETTINGS_URL);
+ expect(JSON.parse(lastCall?.options?.body as string)).toEqual({
+ value: currentVersionTag,
+ });
});
-
- // Clean up fetchMock after the test
- fetchMock.reset();
});
it("should link the most recent eligible release notes", async () => {
diff --git a/frontend/src/metabase/nav/components/search/SearchResults/SearchResults.unit.spec.tsx b/frontend/src/metabase/nav/components/search/SearchResults/SearchResults.unit.spec.tsx
index 21337c0f078..e71d8890775 100644
--- a/frontend/src/metabase/nav/components/search/SearchResults/SearchResults.unit.spec.tsx
+++ b/frontend/src/metabase/nav/components/search/SearchResults/SearchResults.unit.spec.tsx
@@ -178,6 +178,8 @@ describe("SearchResults", () => {
it("should only call the /api/user/recipients endpoint once even if there are multiple search results", async () => {
await setup();
- expect(fetchMock.calls("path:/api/user/recipients").length).toBe(1);
+ expect(
+ fetchMock.callHistory.calls("path:/api/user/recipients").length,
+ ).toBe(1);
});
});
diff --git a/frontend/src/metabase/nav/containers/MainNavbar/MainNavbarContainer/AddDataModal/tests/setup.tsx b/frontend/src/metabase/nav/containers/MainNavbar/MainNavbarContainer/AddDataModal/tests/setup.tsx
index 696045b902b..89811424185 100644
--- a/frontend/src/metabase/nav/containers/MainNavbar/MainNavbarContainer/AddDataModal/tests/setup.tsx
+++ b/frontend/src/metabase/nav/containers/MainNavbar/MainNavbarContainer/AddDataModal/tests/setup.tsx
@@ -97,7 +97,7 @@ export const setup = ({
if (hasEnterprisePlugins) {
setupEnterprisePlugins();
}
- setupTokenStatusEndpoint(true);
+ setupTokenStatusEndpoint({ valid: true });
setupDatabaseListEndpoint(databases);
diff --git a/frontend/src/metabase/notifications/DashboardSubscriptionsSidebar/tests/common.unit.spec.ts b/frontend/src/metabase/notifications/DashboardSubscriptionsSidebar/tests/common.unit.spec.ts
index a18d07225bc..37347930268 100644
--- a/frontend/src/metabase/notifications/DashboardSubscriptionsSidebar/tests/common.unit.spec.ts
+++ b/frontend/src/metabase/notifications/DashboardSubscriptionsSidebar/tests/common.unit.spec.ts
@@ -78,9 +78,8 @@ describe("DashboardSubscriptionsSidebar", () => {
await userEvent.click(await screen.findByText("Send email now"));
- const payload = await fetchMock
- ?.lastCall("path:/api/pulse/test")
- ?.request?.json();
+ const lastCall = fetchMock.callHistory.lastCall("path:/api/pulse/test");
+ const payload = await lastCall?.request?.json();
expect(payload.cards).toHaveLength(1);
expect(payload.cards[0].id).toEqual(dashcard.id);
});
diff --git a/frontend/src/metabase/notifications/DashboardSubscriptionsSidebar/tests/setup.tsx b/frontend/src/metabase/notifications/DashboardSubscriptionsSidebar/tests/setup.tsx
index b91ed115406..04ad8af46cf 100644
--- a/frontend/src/metabase/notifications/DashboardSubscriptionsSidebar/tests/setup.tsx
+++ b/frontend/src/metabase/notifications/DashboardSubscriptionsSidebar/tests/setup.tsx
@@ -147,10 +147,11 @@ export function setup(
users: [user],
});
- fetchMock.get(
- { url: `path:/api/pulse`, query: { dashboard_id: dashboard.id } },
- [],
- );
+ fetchMock.get({
+ url: `path:/api/pulse`,
+ query: { dashboard_id: dashboard.id },
+ response: [],
+ });
fetchMock.post("path:/api/pulse/test", 200);
diff --git a/frontend/src/metabase/notifications/modals/CreateOrEditQuestionAlertModal/CreateOrEditQuestionAlertModal.unit.spec.tsx b/frontend/src/metabase/notifications/modals/CreateOrEditQuestionAlertModal/CreateOrEditQuestionAlertModal.unit.spec.tsx
index 972c6a933b3..cf3c185b0cc 100644
--- a/frontend/src/metabase/notifications/modals/CreateOrEditQuestionAlertModal/CreateOrEditQuestionAlertModal.unit.spec.tsx
+++ b/frontend/src/metabase/notifications/modals/CreateOrEditQuestionAlertModal/CreateOrEditQuestionAlertModal.unit.spec.tsx
@@ -32,14 +32,6 @@ import { createSampleDatabase } from "metabase-types/api/mocks/presets";
import { createMockQueryBuilderState } from "metabase-types/store/mocks";
describe("CreateOrEditQuestionAlertModal", () => {
- beforeEach(() => {
- fetchMock.reset();
- });
-
- afterEach(() => {
- fetchMock.restore();
- });
-
it("should display first available channel by default - Email", async () => {
setup({
isAdmin: true,
@@ -267,11 +259,11 @@ describe("CreateOrEditQuestionAlertModal", () => {
await userEvent.click(saveButton);
// Verify the API was called with the correct cron schedule for 8am
- const calls = fetchMock.calls("path:/api/notification");
+ const calls = fetchMock.callHistory.calls("path:/api/notification");
expect(calls.length).toBe(1);
await waitFor(async () => {
- const requestBody = await calls[0][1]?.body;
+ const requestBody = await calls[0].options?.body;
const subscription = JSON.parse(requestBody as string).subscriptions[0];
// Verify the cron schedule is for 8am daily
@@ -312,11 +304,11 @@ describe("CreateOrEditQuestionAlertModal", () => {
await userEvent.click(saveButton);
// Verify the API was called with the correct cron schedule for 8am
- const calls = fetchMock.calls("path:/api/notification");
+ const calls = fetchMock.callHistory.calls("path:/api/notification");
expect(calls.length).toBe(1);
await waitFor(async () => {
- const requestBody = await calls[0][1]?.body;
+ const requestBody = await calls[0].options?.body;
const subscription = JSON.parse(requestBody as string).subscriptions[0];
// Verify the cron schedule is for 8am daily
@@ -372,11 +364,13 @@ describe("CreateOrEditQuestionAlertModal", () => {
await userEvent.click(saveButton);
// Verify the API was called with the correct cron schedule for Tuesday at 2pm
- const calls = fetchMock.calls(`path:/api/notification/${notificationId}`);
+ const calls = fetchMock.callHistory.calls(
+ `path:/api/notification/${notificationId}`,
+ );
expect(calls.length).toBe(1);
await waitFor(async () => {
- const requestBody = await calls[0][1]?.body;
+ const requestBody = await calls[0].options?.body;
const subscription = JSON.parse(requestBody as string).subscriptions[0];
// Verify the cron schedule is for Tuesday at 2pm (day 3)
diff --git a/frontend/src/metabase/palette/components/test/PaletteResults/PaletteResults-oss.unit.spec.tsx b/frontend/src/metabase/palette/components/test/PaletteResults/PaletteResults-oss.unit.spec.tsx
index be8fb5535d7..f8f59f92333 100644
--- a/frontend/src/metabase/palette/components/test/PaletteResults/PaletteResults-oss.unit.spec.tsx
+++ b/frontend/src/metabase/palette/components/test/PaletteResults/PaletteResults-oss.unit.spec.tsx
@@ -119,7 +119,7 @@ describe("PaletteResults", () => {
).toHaveTextContent("lame collection");
// One call is always made to determine if the instance has models inside useCommandPaletteBasicActions
- expect(fetchMock.calls("path:/api/search").length).toBe(2);
+ expect(fetchMock.callHistory.calls("path:/api/search").length).toBe(2);
});
it("should provide links to settings pages for admins", async () => {
@@ -159,7 +159,7 @@ describe("PaletteResults", () => {
).toBeInTheDocument();
// One call is always made to determine if the instance has models inside useCommandPaletteBasicActions
- expect(fetchMock.calls("path:/api/search").length).toBe(1);
+ expect(fetchMock.callHistory.calls("path:/api/search").length).toBe(1);
});
it("should provide a link to docs with the proper url param", async () => {
@@ -169,7 +169,7 @@ describe("PaletteResults", () => {
).toHaveAttribute("href", expect.stringContaining("?query=model"));
// One call is always made to determine if the instance has models inside useCommandPaletteBasicActions
- expect(fetchMock.calls("path:/api/search").length).toBe(2);
+ expect(fetchMock.callHistory.calls("path:/api/search").length).toBe(2);
});
it("should not allow you to select or click disabled items", async () => {
diff --git a/frontend/src/metabase/public/LocaleProvider.unit.spec.tsx b/frontend/src/metabase/public/LocaleProvider.unit.spec.tsx
index e94d81b99c0..f61d151d15e 100644
--- a/frontend/src/metabase/public/LocaleProvider.unit.spec.tsx
+++ b/frontend/src/metabase/public/LocaleProvider.unit.spec.tsx
@@ -164,6 +164,8 @@ const mockLocaleJsonResponse = (locale: string) => {
async function waitForLocaleJson(locale: string) {
await waitFor(() => {
- expect(fetchMock.done(`/app/locales/${locale}.json`)).toBe(true);
+ expect(fetchMock.callHistory.done(`/app/locales/${locale}.json`)).toBe(
+ true,
+ );
});
}
diff --git a/frontend/src/metabase/public/components/EmbedModal/StaticEmbedSetupPane/tests/setup.tsx b/frontend/src/metabase/public/components/EmbedModal/StaticEmbedSetupPane/tests/setup.tsx
index 80921f2a60f..a0a29f8e669 100644
--- a/frontend/src/metabase/public/components/EmbedModal/StaticEmbedSetupPane/tests/setup.tsx
+++ b/frontend/src/metabase/public/components/EmbedModal/StaticEmbedSetupPane/tests/setup.tsx
@@ -81,7 +81,7 @@ export async function setup({
values: [],
has_more_values: false,
});
- setupTokenStatusEndpoint(hasEnterprisePlugins);
+ setupTokenStatusEndpoint({ valid: hasEnterprisePlugins });
const settings = mockSettings({
"enable-embedding": true,
diff --git a/frontend/src/metabase/public/components/widgets/LegaleseStep/LegaleseStep.unit.spec.tsx b/frontend/src/metabase/public/components/widgets/LegaleseStep/LegaleseStep.unit.spec.tsx
index fe972ec9694..cb67334c4de 100644
--- a/frontend/src/metabase/public/components/widgets/LegaleseStep/LegaleseStep.unit.spec.tsx
+++ b/frontend/src/metabase/public/components/widgets/LegaleseStep/LegaleseStep.unit.spec.tsx
@@ -57,7 +57,7 @@ describe("LegaleseStep", () => {
const { goToNextStep } = setup();
await userEvent.click(screen.getByText("Agree and continue"));
- const settingPutCalls = fetchMock.calls(
+ const settingPutCalls = fetchMock.callHistory.calls(
"path:/api/setting/show-static-embed-terms",
);
diff --git a/frontend/src/metabase/public/containers/PublicAction/PublicAction.unit.spec.tsx b/frontend/src/metabase/public/containers/PublicAction/PublicAction.unit.spec.tsx
index 2cf4471393d..afffed4faca 100644
--- a/frontend/src/metabase/public/containers/PublicAction/PublicAction.unit.spec.tsx
+++ b/frontend/src/metabase/public/containers/PublicAction/PublicAction.unit.spec.tsx
@@ -152,7 +152,9 @@ describe("PublicAction", () => {
await waitFor(() => {
expect(
- fetchMock.done(`path:/api/public/action/${TEST_PUBLIC_ID}/execute`),
+ fetchMock.callHistory.done(
+ `path:/api/public/action/${TEST_PUBLIC_ID}/execute`,
+ ),
).toBe(true);
});
});
@@ -205,7 +207,9 @@ describe("PublicAction", () => {
);
await waitFor(() =>
expect(
- fetchMock.done(`path:/api/public/action/${TEST_PUBLIC_ID}/execute`),
+ fetchMock.callHistory.done(
+ `path:/api/public/action/${TEST_PUBLIC_ID}/execute`,
+ ),
).toBe(true),
);
});
diff --git a/frontend/src/metabase/public/containers/PublicOrEmbeddedDashboard/PublicOrEmbeddedDashboardPage/tests/PublicOrEmbeddedDashboardPage.enterprise.unit.spec.tsx b/frontend/src/metabase/public/containers/PublicOrEmbeddedDashboard/PublicOrEmbeddedDashboardPage/tests/PublicOrEmbeddedDashboardPage.enterprise.unit.spec.tsx
index b3d1afd02c9..8152001a1c6 100644
--- a/frontend/src/metabase/public/containers/PublicOrEmbeddedDashboard/PublicOrEmbeddedDashboardPage/tests/PublicOrEmbeddedDashboardPage.enterprise.unit.spec.tsx
+++ b/frontend/src/metabase/public/containers/PublicOrEmbeddedDashboard/PublicOrEmbeddedDashboardPage/tests/PublicOrEmbeddedDashboardPage.enterprise.unit.spec.tsx
@@ -74,7 +74,7 @@ describe("PublicOrEmbeddedDashboardPage", () => {
await setupEnterprise({ hash: { locale: expectedLocale } });
expect(
- fetchMock.calls(`path:/app/locales/${expectedLocale}.json`),
+ fetchMock.callHistory.calls(`path:/app/locales/${expectedLocale}.json`),
).toHaveLength(0);
});
});
diff --git a/frontend/src/metabase/public/containers/PublicOrEmbeddedDashboard/PublicOrEmbeddedDashboardPage/tests/PublicOrEmbeddedDashboardPage.premium.unit.spec.tsx b/frontend/src/metabase/public/containers/PublicOrEmbeddedDashboard/PublicOrEmbeddedDashboardPage/tests/PublicOrEmbeddedDashboardPage.premium.unit.spec.tsx
index 43f3a988b9b..8f5427463f1 100644
--- a/frontend/src/metabase/public/containers/PublicOrEmbeddedDashboard/PublicOrEmbeddedDashboardPage/tests/PublicOrEmbeddedDashboardPage.premium.unit.spec.tsx
+++ b/frontend/src/metabase/public/containers/PublicOrEmbeddedDashboard/PublicOrEmbeddedDashboardPage/tests/PublicOrEmbeddedDashboardPage.premium.unit.spec.tsx
@@ -99,7 +99,7 @@ describe("PublicOrEmbeddedDashboardPage", () => {
await setupPremium({ hash: { locale: expectedLocale } });
expect(
- fetchMock.calls(`path:/app/locales/${expectedLocale}.json`),
+ fetchMock.callHistory.calls(`path:/app/locales/${expectedLocale}.json`),
).toHaveLength(1);
});
});
diff --git a/frontend/src/metabase/public/containers/PublicOrEmbeddedQuestion/PublicOrEmbeddedQuestion/tests/PublicOrEmbeddedQuestion.enterprise.unit.spec.tsx b/frontend/src/metabase/public/containers/PublicOrEmbeddedQuestion/PublicOrEmbeddedQuestion/tests/PublicOrEmbeddedQuestion.enterprise.unit.spec.tsx
index c4cb8c7adc1..cc7d7598478 100644
--- a/frontend/src/metabase/public/containers/PublicOrEmbeddedQuestion/PublicOrEmbeddedQuestion/tests/PublicOrEmbeddedQuestion.enterprise.unit.spec.tsx
+++ b/frontend/src/metabase/public/containers/PublicOrEmbeddedQuestion/PublicOrEmbeddedQuestion/tests/PublicOrEmbeddedQuestion.enterprise.unit.spec.tsx
@@ -60,7 +60,7 @@ describe("PublicOrEmbeddedQuestion", () => {
await userEvent.hover(getIcon("download"));
expect(
- fetchMock.calls(`path:/app/locales/${expectedLocale}.json`),
+ fetchMock.callHistory.calls(`path:/app/locales/${expectedLocale}.json`),
).toHaveLength(0);
});
});
diff --git a/frontend/src/metabase/public/containers/PublicOrEmbeddedQuestion/PublicOrEmbeddedQuestion/tests/PublicOrEmbeddedQuestion.premium.unit.spec.tsx b/frontend/src/metabase/public/containers/PublicOrEmbeddedQuestion/PublicOrEmbeddedQuestion/tests/PublicOrEmbeddedQuestion.premium.unit.spec.tsx
index fb816d19fc2..c54c5f8afec 100644
--- a/frontend/src/metabase/public/containers/PublicOrEmbeddedQuestion/PublicOrEmbeddedQuestion/tests/PublicOrEmbeddedQuestion.premium.unit.spec.tsx
+++ b/frontend/src/metabase/public/containers/PublicOrEmbeddedQuestion/PublicOrEmbeddedQuestion/tests/PublicOrEmbeddedQuestion.premium.unit.spec.tsx
@@ -62,7 +62,7 @@ describe("PublicOrEmbeddedQuestion", () => {
await userEvent.hover(getIcon("download"));
expect(
- fetchMock.calls(`path:/app/locales/${expectedLocale}.json`),
+ fetchMock.callHistory.calls(`path:/app/locales/${expectedLocale}.json`),
).toHaveLength(1);
});
});
diff --git a/frontend/src/metabase/query_builder/components/AddToDashSelectDashModal/AddToDashSelectDashModal.unit.spec.tsx b/frontend/src/metabase/query_builder/components/AddToDashSelectDashModal/AddToDashSelectDashModal.unit.spec.tsx
index ebca697eb89..849cfa5226b 100644
--- a/frontend/src/metabase/query_builder/components/AddToDashSelectDashModal/AddToDashSelectDashModal.unit.spec.tsx
+++ b/frontend/src/metabase/query_builder/components/AddToDashSelectDashModal/AddToDashSelectDashModal.unit.spec.tsx
@@ -549,7 +549,7 @@ describe("AddToDashSelectDashModal", () => {
await waitForLoaderToBeRemoved();
await screen.findAllByTestId("result-item");
- const call = fetchMock.lastCall("path:/api/search");
+ const call = fetchMock.callHistory.lastCall("path:/api/search");
const urlObject = new URL(checkNotNull(call?.request?.url));
expect(urlObject.pathname).toEqual("/api/search");
expect(Object.fromEntries(urlObject.searchParams.entries())).toEqual({
@@ -579,7 +579,7 @@ describe("AddToDashSelectDashModal", () => {
await waitForLoaderToBeRemoved();
await screen.findAllByTestId("result-item");
- const call = fetchMock.lastCall("path:/api/search");
+ const call = fetchMock.callHistory.lastCall("path:/api/search");
const urlObject = new URL(checkNotNull(call?.request?.url));
expect(urlObject.pathname).toEqual("/api/search");
expect(Object.fromEntries(urlObject.searchParams.entries())).toEqual({
diff --git a/frontend/src/metabase/query_builder/components/DataSelector/saved-entity-picker/SavedEntityPicker.unit.spec.jsx b/frontend/src/metabase/query_builder/components/DataSelector/saved-entity-picker/SavedEntityPicker.unit.spec.jsx
index 4780f9f9334..80944d06fb5 100644
--- a/frontend/src/metabase/query_builder/components/DataSelector/saved-entity-picker/SavedEntityPicker.unit.spec.jsx
+++ b/frontend/src/metabase/query_builder/components/DataSelector/saved-entity-picker/SavedEntityPicker.unit.spec.jsx
@@ -34,15 +34,13 @@ const COLLECTIONS = {
};
function mockCollectionItemsEndpoint() {
- fetchMock.get(
- {
- url: "path:/api/collection/root/items",
- query: {
- sort_column: "name",
- sort_direction: "asc",
- },
+ fetchMock.get({
+ url: "path:/api/collection/root/items",
+ query: {
+ sort_column: "name",
+ sort_direction: "asc",
},
- {
+ response: {
total: 3,
data: [
createMockCollectionItem({
@@ -62,7 +60,7 @@ function mockCollectionItemsEndpoint() {
limit: null,
offset: null,
},
- );
+ });
}
async function setup() {
diff --git a/frontend/src/metabase/query_builder/components/DatasetEditor/DatasetEditor.unit.spec.tsx b/frontend/src/metabase/query_builder/components/DatasetEditor/DatasetEditor.unit.spec.tsx
index 1f8a1b1a3da..72435111838 100644
--- a/frontend/src/metabase/query_builder/components/DatasetEditor/DatasetEditor.unit.spec.tsx
+++ b/frontend/src/metabase/query_builder/components/DatasetEditor/DatasetEditor.unit.spec.tsx
@@ -5,7 +5,7 @@ import {
setupDatabasesEndpoints,
setupNativeQuerySnippetEndpoints,
} from "__support__/server-mocks";
-import { renderWithProviders } from "__support__/ui";
+import { renderWithProviders, screen } from "__support__/ui";
import { DatasetEditor } from "metabase/query_builder/components/DatasetEditor";
import Question from "metabase-lib/v1/Question";
import type { Card, UnsavedCard } from "metabase-types/api";
@@ -59,51 +59,47 @@ const defaultDatasetEditorProps = {
toggleTemplateTagsEditor: noop,
};
-const renderDatasetEditor = (card: Card | UnsavedCard) => {
+const renderDatasetEditor = async (card: Card | UnsavedCard) => {
setupDatabasesEndpoints([TEST_DB]);
setupCollectionsEndpoints({ collections: [ROOT_COLLECTION] });
setupNativeQuerySnippetEndpoints();
const question = new Question(card);
+ fetchMock.get("path:/api/search", { body: { data: [] } });
+ fetchMock.get("path:/api/model-index", { body: [] });
+
renderWithProviders(
<DatasetEditor {...defaultDatasetEditorProps} question={question} />,
);
+
+ await screen.findByText("Query");
};
describe("DatasetEditor", () => {
- beforeEach(() => {
- fetchMock.get("path:/api/search", () => ({ body: { data: [] } }));
- fetchMock.get("path:/api/model-index", () => ({ body: { data: [] } }));
- });
-
- afterEach(() => {
- jest.restoreAllMocks();
- });
-
- it("tries to load a model index for a saved model", () => {
- renderDatasetEditor(mockSavedModel);
- const calls = fetchMock.calls("path:/api/model-index");
+ it("tries to load a model index for a saved model", async () => {
+ await renderDatasetEditor(mockSavedModel);
+ const calls = fetchMock.callHistory.calls("path:/api/model-index");
expect(calls).toHaveLength(1);
expect(
new URL(calls[0]?.request?.url ?? "").searchParams.get("model_id"),
).toBe(`${mockSavedModel.id}`);
});
- it("does not try to load a model index for a saved question", () => {
- renderDatasetEditor(mockSavedCard);
- const calls = fetchMock.calls("path:/api/model-index");
+ it("does not try to load a model index for a saved question", async () => {
+ await renderDatasetEditor(mockSavedCard);
+ const calls = fetchMock.callHistory.calls("path:/api/model-index");
expect(calls).toHaveLength(0);
});
- it("does not try to load a model index for a saved metric", () => {
- renderDatasetEditor(mockSavedMetric);
- const calls = fetchMock.calls("path:/api/model-index");
+ it("does not try to load a model index for a saved metric", async () => {
+ await renderDatasetEditor(mockSavedMetric);
+ const calls = fetchMock.callHistory.calls("path:/api/model-index");
expect(calls).toHaveLength(0);
});
- it("does not try to load a model index when card is unsaved", () => {
- renderDatasetEditor(mockUnsavedCard);
- const calls = fetchMock.calls("path:/api/model-index");
+ it("does not try to load a model index when card is unsaved", async () => {
+ await renderDatasetEditor(mockUnsavedCard);
+ const calls = fetchMock.callHistory.calls("path:/api/model-index");
expect(calls).toHaveLength(0);
});
});
diff --git a/frontend/src/metabase/query_builder/components/NativeQueryEditor/CodeMirrorEditor/completers.unit.spec.tsx b/frontend/src/metabase/query_builder/components/NativeQueryEditor/CodeMirrorEditor/completers.unit.spec.tsx
index 445d6ce22b6..a2b9ccf974b 100644
--- a/frontend/src/metabase/query_builder/components/NativeQueryEditor/CodeMirrorEditor/completers.unit.spec.tsx
+++ b/frontend/src/metabase/query_builder/components/NativeQueryEditor/CodeMirrorEditor/completers.unit.spec.tsx
@@ -103,14 +103,14 @@ describe("useSchemaCompletion", () => {
const results = await complete("SELECT {{ foo|");
expect(results).toBe(null);
- expect(fetchMock.calls(url)).toHaveLength(0);
+ expect(fetchMock.callHistory.calls(url)).toHaveLength(0);
});
it("should not call the endpoint if the cursor is inside a closed tag", async () => {
const { complete, url } = setup({ matchStyle: "prefix" });
const results = await complete("SELECT {{ foo| }}");
expect(results).toBe(null);
- expect(fetchMock.calls(url)).toHaveLength(0);
+ expect(fetchMock.callHistory.calls(url)).toHaveLength(0);
});
it("should not call the endpoint if the cursor is inside an open snippet tag", async () => {
@@ -118,7 +118,7 @@ describe("useSchemaCompletion", () => {
const results = await complete("SELECT {{ snippet: foo|");
expect(results).toBe(null);
- expect(fetchMock.calls(url)).toHaveLength(0);
+ expect(fetchMock.callHistory.calls(url)).toHaveLength(0);
});
it("should not call the endpoint if the cursor is inside a closed snippet tag", async () => {
@@ -126,7 +126,7 @@ describe("useSchemaCompletion", () => {
const results = await complete("SELECT {{ snippet: foo| }}");
expect(results).toBe(null);
- expect(fetchMock.calls(url)).toHaveLength(0);
+ expect(fetchMock.callHistory.calls(url)).toHaveLength(0);
});
it("should not call the endpoint if the cursor is inside an open card tag", async () => {
@@ -134,7 +134,7 @@ describe("useSchemaCompletion", () => {
const results = await complete("SELECT {{ #foo|");
expect(results).toBe(null);
- expect(fetchMock.calls(url)).toHaveLength(0);
+ expect(fetchMock.callHistory.calls(url)).toHaveLength(0);
});
it("should not call the endpoint if the cursor is inside a closed card tag", async () => {
@@ -142,7 +142,7 @@ describe("useSchemaCompletion", () => {
const results = await complete("SELECT {{ #foo| }}");
expect(results).toBe(null);
- expect(fetchMock.calls(url)).toHaveLength(0);
+ expect(fetchMock.callHistory.calls(url)).toHaveLength(0);
});
it("should complete even when inside a word", async () => {
@@ -164,7 +164,7 @@ describe("useSchemaCompletion", () => {
},
],
});
- expect(fetchMock.calls(url)).toHaveLength(1);
+ expect(fetchMock.callHistory.calls(url)).toHaveLength(1);
});
it("should deduplicate results", async () => {
@@ -187,7 +187,7 @@ describe("useSchemaCompletion", () => {
},
],
});
- expect(fetchMock.calls(url)).toHaveLength(1);
+ expect(fetchMock.callHistory.calls(url)).toHaveLength(1);
});
describe("native-query-autocomplete-match-style = off", () => {
@@ -198,7 +198,7 @@ describe("useSchemaCompletion", () => {
const result = await complete("SELECT S|");
expect(result).toEqual(null);
- expect(fetchMock.calls(url)).toHaveLength(0);
+ expect(fetchMock.callHistory.calls(url)).toHaveLength(0);
});
});
@@ -209,9 +209,9 @@ describe("useSchemaCompletion", () => {
const { complete, url } = setup({ matchStyle });
const result = await complete("SELECT S|");
- const calls = fetchMock.calls(url);
+ const calls = fetchMock.callHistory.calls(url);
expect(calls).toHaveLength(1);
- expect(new URL(calls[0][0]).searchParams.get("prefix")).toBe("S");
+ expect(new URL(calls[0].url).searchParams.get("prefix")).toBe("S");
expect(result).toEqual({
from: 7,
@@ -237,10 +237,10 @@ describe("useSchemaCompletion", () => {
const { complete, url } = setup({ matchStyle });
const result = await complete("SELECT S|");
- const calls = fetchMock.calls(url);
+ const calls = fetchMock.callHistory.calls(url);
expect(calls).toHaveLength(1);
- expect(new URL(calls[0][0]).searchParams.get("substring")).toBe("S");
+ expect(new URL(calls[0].url).searchParams.get("substring")).toBe("S");
expect(result).toEqual({
from: 7,
@@ -270,7 +270,7 @@ describe("useSnippetCompletion", () => {
const url = "path:/api/native-query-snippet";
- function setup({
+ async function setup({
results = MOCK_RESULTS,
}: {
results?: Partial<NativeQuerySnippet>[];
@@ -280,31 +280,32 @@ describe("useSnippetCompletion", () => {
const complete = completer(() => useSnippetCompletion());
// the call gets made once before completing so it's always made
- expect(fetchMock.calls(url)).toHaveLength(1);
-
+ await waitFor(() => {
+ expect(fetchMock.callHistory.calls(url)).toHaveLength(1);
+ });
return { complete };
}
it("should not return snippet completions when not in a tag", async () => {
- const { complete } = setup();
+ const { complete } = await setup();
const results = await complete("SELECT S|");
expect(results).toBe(null);
});
it("should not return snippet completions when in a parameter tag", async () => {
- const { complete } = setup();
+ const { complete } = await setup();
const results = await complete("SELECT {{ foo| }}");
expect(results).toBe(null);
});
it("should not return snippet completions when in a card tag", async () => {
- const { complete } = setup();
+ const { complete } = await setup();
const results = await complete("SELECT {{ #foo| }}");
expect(results).toBe(null);
});
it("should return snippet completions when in an open snippet tag", async () => {
- const { complete } = setup();
+ const { complete } = await setup();
await waitFor(async () => {
const results = await complete("{{ snippet: fo| ");
@@ -323,7 +324,7 @@ describe("useSnippetCompletion", () => {
});
it("should return snippet completions when in an open snippet tag, inside a word", async () => {
- const { complete } = setup();
+ const { complete } = await setup();
await waitFor(async () => {
const results = await complete("{{ snippet: fo|o ");
@@ -342,7 +343,7 @@ describe("useSnippetCompletion", () => {
});
it("should return snippet completions when in a closed snippet tag", async () => {
- const { complete } = setup();
+ const { complete } = await setup();
await waitFor(async () => {
const results = await complete("{{ snippet: fo| }}");
@@ -361,7 +362,7 @@ describe("useSnippetCompletion", () => {
});
it("should return snippet completions when in a closed snippet tag, inside a word", async () => {
- const { complete } = setup();
+ const { complete } = await setup();
await waitFor(async () => {
const results = await complete("{{ snippet: fo|o }}");
@@ -428,7 +429,7 @@ describe("useCardTagCompletion", () => {
expect(result).toBe(null);
}
- expect(fetchMock.calls(url)).toHaveLength(0);
+ expect(fetchMock.callHistory.calls(url)).toHaveLength(0);
});
it("should autocomplete cards when inside an open card tag", async () => {
@@ -452,7 +453,7 @@ describe("useCardTagCompletion", () => {
},
],
});
- expect(fetchMock.calls(url)).toHaveLength(1);
+ expect(fetchMock.callHistory.calls(url)).toHaveLength(1);
});
it("should autocomplete cards when inside an open card tag, inside a word", async () => {
@@ -476,7 +477,7 @@ describe("useCardTagCompletion", () => {
},
],
});
- expect(fetchMock.calls(url)).toHaveLength(1);
+ expect(fetchMock.callHistory.calls(url)).toHaveLength(1);
});
it("should autocomplete cards when inside a closed card tag", async () => {
@@ -500,7 +501,7 @@ describe("useCardTagCompletion", () => {
},
],
});
- expect(fetchMock.calls(url)).toHaveLength(1);
+ expect(fetchMock.callHistory.calls(url)).toHaveLength(1);
});
it("should autocomplete cards when inside a closed card tag, inside a word", async () => {
@@ -524,7 +525,7 @@ describe("useCardTagCompletion", () => {
},
],
});
- expect(fetchMock.calls(url)).toHaveLength(1);
+ expect(fetchMock.callHistory.calls(url)).toHaveLength(1);
});
});
@@ -586,7 +587,7 @@ describe("useReferencedCardCompletion", () => {
expect(result).toBe(null);
}
- expect(fetchMock.calls("/api/card/*")).toHaveLength(0);
+ expect(fetchMock.callHistory.calls("/api/card/*")).toHaveLength(0);
});
it("should return columns from referenced cards", async () => {
@@ -601,7 +602,7 @@ describe("useReferencedCardCompletion", () => {
],
});
- expect(fetchMock.calls(url)).toHaveLength(1);
+ expect(fetchMock.callHistory.calls(url)).toHaveLength(1);
});
it("should return columns from referenced cards, inside word", async () => {
@@ -616,7 +617,7 @@ describe("useReferencedCardCompletion", () => {
{ label: "Bar", detail: "Referenced Question varchar" },
],
});
- expect(fetchMock.calls(url)).toHaveLength(1);
+ expect(fetchMock.callHistory.calls(url)).toHaveLength(1);
});
});
diff --git a/frontend/src/metabase/query_builder/components/template_tags/SnippetFormModal/SnippetFormModal.unit.spec.tsx b/frontend/src/metabase/query_builder/components/template_tags/SnippetFormModal/SnippetFormModal.unit.spec.tsx
index 2fb4312220d..2df4da027ed 100644
--- a/frontend/src/metabase/query_builder/components/template_tags/SnippetFormModal/SnippetFormModal.unit.spec.tsx
+++ b/frontend/src/metabase/query_builder/components/template_tags/SnippetFormModal/SnippetFormModal.unit.spec.tsx
@@ -32,30 +32,32 @@ async function setup({
withDefaultFoldersList = true,
onClose = jest.fn(),
}: SetupOpts = {}) {
- fetchMock.get(
- { url: "path:/api/collection/root", query: { namespace: "snippets" } },
- TOP_SNIPPETS_FOLDER,
- );
+ fetchMock.get({
+ url: "path:/api/collection/root",
+ query: { namespace: "snippets" },
+ response: TOP_SNIPPETS_FOLDER,
+ });
if (withDefaultFoldersList) {
- fetchMock.get(
- { url: "path:/api/collection", query: { namespace: "snippets" } },
- [TOP_SNIPPETS_FOLDER],
- );
+ fetchMock.get({
+ url: "path:/api/collection",
+ query: { namespace: "snippets" },
+ response: [TOP_SNIPPETS_FOLDER],
+ });
}
- fetchMock.post("path:/api/native-query-snippet", async (url) => {
+ fetchMock.post("path:/api/native-query-snippet", async (call) => {
return createMockNativeQuerySnippet(
- await fetchMock.lastCall(url)?.request?.json(),
+ await fetchMock.callHistory.lastCall(call.url)?.request?.json(),
);
});
if (snippet.id) {
fetchMock.put(
`path:/api/native-query-snippet/${snippet.id}`,
- async (url) => {
+ async (call) => {
return createMockNativeQuerySnippet(
- await fetchMock.lastCall(url)?.request?.json(),
+ await fetchMock.callHistory.lastCall(call.url)?.request?.json(),
);
},
);
@@ -112,10 +114,11 @@ describe("SnippetFormModal", () => {
});
it("shows folder picker if there are many folders", async () => {
- fetchMock.get(
- { url: "path:/api/collection", query: { namespace: "snippets" } },
- [TOP_SNIPPETS_FOLDER, createMockCollection()],
- );
+ fetchMock.get({
+ url: "path:/api/collection",
+ query: { namespace: "snippets" },
+ response: [TOP_SNIPPETS_FOLDER, createMockCollection()],
+ });
await setup({ withDefaultFoldersList: false });
@@ -212,10 +215,11 @@ describe("SnippetFormModal", () => {
});
it("shows folder picker if there are many folders", async () => {
- fetchMock.get(
- { url: "path:/api/collection", query: { namespace: "snippets" } },
- [TOP_SNIPPETS_FOLDER, createMockCollection()],
- );
+ fetchMock.get({
+ url: "path:/api/collection",
+ query: { namespace: "snippets" },
+ response: [TOP_SNIPPETS_FOLDER, createMockCollection()],
+ });
await setupEditing({ withDefaultFoldersList: false });
diff --git a/frontend/src/metabase/query_builder/components/view/ViewHeader/ViewTitleHeader.unit.spec.js b/frontend/src/metabase/query_builder/components/view/ViewHeader/ViewTitleHeader.unit.spec.js
index 5d2848eae0d..7b7572a69e4 100644
--- a/frontend/src/metabase/query_builder/components/view/ViewHeader/ViewTitleHeader.unit.spec.js
+++ b/frontend/src/metabase/query_builder/components/view/ViewHeader/ViewTitleHeader.unit.spec.js
@@ -206,10 +206,6 @@ function setupSavedNative(props = {}) {
}
describe("ViewTitleHeader", () => {
- beforeEach(() => {
- fetchMock.reset();
- });
-
const TEST_CASE = {
SAVED_GUI_QUESTION: {
card: getSavedGUIQuestionCard(),
diff --git a/frontend/src/metabase/query_builder/components/view/sidebars/ModelCacheManagementSection/ModelCacheManagementSection.unit.spec.tsx b/frontend/src/metabase/query_builder/components/view/sidebars/ModelCacheManagementSection/ModelCacheManagementSection.unit.spec.tsx
index 8c8ce4bf78c..15f64f770a6 100644
--- a/frontend/src/metabase/query_builder/components/view/sidebars/ModelCacheManagementSection/ModelCacheManagementSection.unit.spec.tsx
+++ b/frontend/src/metabase/query_builder/components/view/sidebars/ModelCacheManagementSection/ModelCacheManagementSection.unit.spec.tsx
@@ -110,7 +110,7 @@ describe("ModelCacheManagementSection", () => {
fireEvent.click(await screen.findByLabelText("refresh icon"));
// get, post, get
- await waitFor(() => expect(fetchMock.calls().length).toBe(3));
+ await waitFor(() => expect(fetchMock.callHistory.calls().length).toBe(3));
});
it("displays 'error' state correctly", async () => {
@@ -131,7 +131,7 @@ describe("ModelCacheManagementSection", () => {
fireEvent.click(await screen.findByLabelText("refresh icon"));
// get, post, get
- await waitFor(() => expect(fetchMock.calls().length).toBe(3));
+ await waitFor(() => expect(fetchMock.callHistory.calls().length).toBe(3));
});
it("disables refresh when DB management is not available to the user", async () => {
diff --git a/frontend/src/metabase/query_builder/components/view/sidebars/QuestionInfoSidebar/components/ModelUsageDetails.unit.spec.tsx b/frontend/src/metabase/query_builder/components/view/sidebars/QuestionInfoSidebar/components/ModelUsageDetails.unit.spec.tsx
index f6e53c77ec8..253d8929ae4 100644
--- a/frontend/src/metabase/query_builder/components/view/sidebars/QuestionInfoSidebar/components/ModelUsageDetails.unit.spec.tsx
+++ b/frontend/src/metabase/query_builder/components/view/sidebars/QuestionInfoSidebar/components/ModelUsageDetails.unit.spec.tsx
@@ -153,13 +153,11 @@ async function setup({
setupDatabasesEndpoints(databases);
- fetchMock.get(
- {
- url: "path:/api/card",
- query: { f: "using_model", model_id: card.id },
- },
- usedBy,
- );
+ fetchMock.get({
+ url: "path:/api/card",
+ query: { f: "using_model", model_id: card.id },
+ response: usedBy,
+ });
setupCardsEndpoints([card]);
setupCardQueryMetadataEndpoint(
diff --git a/frontend/src/metabase/query_builder/components/view/sidebars/QuestionInfoSidebar/tests/setup.tsx b/frontend/src/metabase/query_builder/components/view/sidebars/QuestionInfoSidebar/tests/setup.tsx
index 273e13e1889..f581fb0f6cc 100644
--- a/frontend/src/metabase/query_builder/components/view/sidebars/QuestionInfoSidebar/tests/setup.tsx
+++ b/frontend/src/metabase/query_builder/components/view/sidebars/QuestionInfoSidebar/tests/setup.tsx
@@ -65,7 +65,7 @@ export const setup = async ({
setupEnterprisePlugins();
}
- setupTokenStatusEndpoint(hasEnterprisePlugins);
+ setupTokenStatusEndpoint({ valid: hasEnterprisePlugins });
const TestQuestionInfoSidebar = () => (
<QuestionInfoSidebar question={question} onSave={onSave} />
diff --git a/frontend/src/metabase/query_builder/containers/QueryBuilder.unit.spec.tsx b/frontend/src/metabase/query_builder/containers/QueryBuilder.unit.spec.tsx
index b9b577dc828..3de0dc5674f 100644
--- a/frontend/src/metabase/query_builder/containers/QueryBuilder.unit.spec.tsx
+++ b/frontend/src/metabase/query_builder/containers/QueryBuilder.unit.spec.tsx
@@ -1,5 +1,4 @@
import userEvent from "@testing-library/user-event";
-import type { MockCall } from "fetch-mock";
import fetchMock from "fetch-mock";
import { setupJestCanvasMock } from "jest-canvas-mock";
@@ -161,10 +160,7 @@ describe("QueryBuilder", () => {
// So I test that case in Cypress in `28834-modified-native-question.cy.spec.js` instead.
it("should allow downloading results for a native query", async () => {
- const mockDownloadEndpoint = fetchMock.post(
- `path:/api/card/${TEST_NATIVE_CARD.id}/query/csv`,
- {},
- );
+ fetchMock.post(`path:/api/card/${TEST_NATIVE_CARD.id}/query/csv`, {});
await setup({
card: TEST_NATIVE_CARD,
dataset: TEST_NATIVE_CARD_DATASET,
@@ -187,11 +183,15 @@ describe("QueryBuilder", () => {
await screen.findByTestId("download-results-button"),
);
- expect(mockDownloadEndpoint.called()).toBe(true);
+ expect(
+ fetchMock.callHistory.calls(
+ `path:/api/card/${TEST_NATIVE_CARD.id}/query/csv`,
+ ),
+ ).toHaveLength(1);
});
it("should allow downloading results for a native query using the current result even the query has changed but not rerun (metabase#28834)", async () => {
- const mockDownloadEndpoint = fetchMock.post("path:/api/dataset/csv", {});
+ fetchMock.post("path:/api/dataset/csv", {});
await setup({
card: TEST_NATIVE_CARD,
dataset: TEST_NATIVE_CARD_DATASET,
@@ -220,10 +220,11 @@ describe("QueryBuilder", () => {
await screen.findByTestId("download-results-button"),
);
- const [url, options] = mockDownloadEndpoint.lastCall() as MockCall;
- const body = await Promise.resolve(options?.body);
+ const calls = fetchMock.callHistory.calls("path:/api/dataset/csv");
+ const lastCall = calls[calls.length - 1];
+ const body = await Promise.resolve(lastCall.options?.body);
const urlSearchParams = new URLSearchParams(body as string);
- expect(url).toEqual(expect.stringContaining("/api/dataset/csv"));
+ expect(lastCall.url).toEqual(expect.stringContaining("/api/dataset/csv"));
const query =
urlSearchParams instanceof URLSearchParams
? JSON.parse(urlSearchParams.get("query") ?? "{}")
diff --git a/frontend/src/metabase/query_builder/containers/QueryBuilder.unsaved-changes-warning.unit.spec.tsx b/frontend/src/metabase/query_builder/containers/QueryBuilder.unsaved-changes-warning.unit.spec.tsx
index a89c1237f58..663a8f0f91e 100644
--- a/frontend/src/metabase/query_builder/containers/QueryBuilder.unsaved-changes-warning.unit.spec.tsx
+++ b/frontend/src/metabase/query_builder/containers/QueryBuilder.unsaved-changes-warning.unit.spec.tsx
@@ -7,7 +7,6 @@ import {
setupCardQueryEndpoints,
setupCardQueryMetadataEndpoint,
setupCardsEndpoints,
- setupGetUserKeyValueEndpoint,
} from "__support__/server-mocks";
import {
act,
@@ -57,21 +56,6 @@ describe("QueryBuilder - unsaved changes warning", () => {
HTMLElement.prototype.getBoundingClientRect = jest
.fn()
.mockReturnValue({ height: 1, width: 1 });
-
- setupGetUserKeyValueEndpoint({
- namespace: "user_acknowledgement",
- key: "turn_into_model_modal",
- value: false,
- });
-
- setupGetUserKeyValueEndpoint({
- namespace: "last_download_format",
- key: "download_format_preference",
- value: {
- last_download_format: "csv",
- last_table_download_format: "csv",
- },
- });
});
afterEach(() => {
diff --git a/frontend/src/metabase/services.unit.spec.ts b/frontend/src/metabase/services.unit.spec.ts
index fc23338c644..7b0bb589e48 100644
--- a/frontend/src/metabase/services.unit.spec.ts
+++ b/frontend/src/metabase/services.unit.spec.ts
@@ -97,7 +97,9 @@ describe("metabase/services > runQuestionQuery", () => {
await setupRunQuestionQuery(question);
- const call = fetchMock.lastCall(`path:/api/card/${question.id()}/query`);
+ const call = fetchMock.callHistory.lastCall(
+ `path:/api/card/${question.id()}/query`,
+ );
expect(await call?.request?.json()).toEqual({
collection_preview: false,
ignore_cache: false,
@@ -114,7 +116,7 @@ describe("metabase/services > runQuestionQuery", () => {
it("should use the pivot endpoint for pivot tables", async () => {
const question = createMockSavedQuestion({ display: "pivot" });
await setupRunQuestionQuery(question);
- const call = fetchMock.lastCall(
+ const call = fetchMock.callHistory.lastCall(
`path:/api/card/pivot/${question.id()}/query`,
);
expect(await call?.request?.json()).toEqual({
@@ -131,7 +133,7 @@ describe("metabase/services > runQuestionQuery", () => {
await setupRunQuestionQuery(question);
- const call = fetchMock.lastCall(
+ const call = fetchMock.callHistory.lastCall(
`path:/api/dashboard/${dashboardId}/dashcard/${dashcardId}/card/${question.id()}/query`,
);
expect(await call?.request?.json()).toEqual({
@@ -152,7 +154,7 @@ describe("metabase/services > runQuestionQuery", () => {
await setupRunQuestionQuery(question);
- const call = fetchMock.lastCall(
+ const call = fetchMock.callHistory.lastCall(
`path:/api/dashboard/pivot/${dashboardId}/dashcard/${dashcardId}/card/${question.id()}/query`,
);
expect(await call?.request?.json()).toEqual({
@@ -169,7 +171,7 @@ describe("metabase/services > runQuestionQuery", () => {
await setupRunQuestionQuery(question);
- const call = fetchMock.lastCall("path:/api/dataset");
+ const call = fetchMock.callHistory.lastCall("path:/api/dataset");
expect(await call?.request?.json()).toEqual({
...question.datasetQuery(),
parameters: [],
@@ -181,7 +183,7 @@ describe("metabase/services > runQuestionQuery", () => {
await setupRunQuestionQuery(question);
- const call = fetchMock.lastCall("path:/api/dataset/pivot");
+ const call = fetchMock.callHistory.lastCall("path:/api/dataset/pivot");
expect(await call?.request?.json()).toEqual({
...question.datasetQuery(),
parameters: [],
diff --git a/frontend/src/metabase/setup/components/DataUsageStep/DataUsageStep.unit.spec.tsx b/frontend/src/metabase/setup/components/DataUsageStep/DataUsageStep.unit.spec.tsx
index fd0f8ccd165..1f8c6aff86b 100644
--- a/frontend/src/metabase/setup/components/DataUsageStep/DataUsageStep.unit.spec.tsx
+++ b/frontend/src/metabase/setup/components/DataUsageStep/DataUsageStep.unit.spec.tsx
@@ -52,7 +52,9 @@ describe("DataUsageStep", () => {
await userEvent.click(toggle);
await waitFor(() => {
- expect(fetchMock.called(TRACKING_PATH, { method: "PUT" })).toBeTruthy();
+ expect(
+ fetchMock.callHistory.called(TRACKING_PATH, { method: "PUT" }),
+ ).toBeTruthy();
});
expect(toggle).not.toBeChecked();
@@ -67,7 +69,9 @@ describe("DataUsageStep", () => {
await userEvent.click(toggle);
await waitFor(() => {
- expect(fetchMock.called(TRACKING_PATH, { method: "PUT" })).toBeTruthy();
+ expect(
+ fetchMock.callHistory.called(TRACKING_PATH, { method: "PUT" }),
+ ).toBeTruthy();
});
expect(await screen.findByText("An error occurred")).toBeInTheDocument();
diff --git a/frontend/src/metabase/setup/tests/enterprise.unit.spec.tsx b/frontend/src/metabase/setup/tests/enterprise.unit.spec.tsx
index 38d64bb78f7..9bc678f95f7 100644
--- a/frontend/src/metabase/setup/tests/enterprise.unit.spec.tsx
+++ b/frontend/src/metabase/setup/tests/enterprise.unit.spec.tsx
@@ -36,10 +36,6 @@ const sampleToken = "a".repeat(64);
const airgapToken = "airgap_toucan";
describe("setup (EE build, but no token)", () => {
- beforeEach(() => {
- fetchMock.reset();
- });
-
it("default step order should be correct, with the license step and data usage steps", async () => {
await setupEnterprise();
await skipWelcomeScreen();
@@ -181,6 +177,8 @@ const submit = async () => {
await userEvent.click(await submitBtn());
const settingEndpoint = "path:/api/setting/premium-embedding-token";
- await waitFor(() => expect(fetchMock.done(settingEndpoint)).toBe(true));
- return fetchMock.lastCall(settingEndpoint);
+ await waitFor(() =>
+ expect(fetchMock.callHistory.done(settingEndpoint)).toBe(true),
+ );
+ return fetchMock.callHistory.lastCall(settingEndpoint);
};
diff --git a/frontend/src/metabase/setup/tests/setup.tsx b/frontend/src/metabase/setup/tests/setup.tsx
index e96f19e0d55..2213e472db1 100644
--- a/frontend/src/metabase/setup/tests/setup.tsx
+++ b/frontend/src/metabase/setup/tests/setup.tsx
@@ -149,14 +149,15 @@ export const expectSectionsToHaveLabelsInOrder = ({
};
export const getLastSettingsPutPayload = async () => {
- const lastSettingsCall = fetchMock.lastCall("path:/api/setting", {
+ const settingsCalls = fetchMock.callHistory.calls("path:/api/setting", {
method: "PUT",
});
+ const lastSettingsCall = settingsCalls[settingsCalls.length - 1];
expect(lastSettingsCall).toBeTruthy();
- expect(lastSettingsCall![1]).toBeTruthy();
+ expect(lastSettingsCall.options?.body).toBeTruthy();
- return JSON.parse((await lastSettingsCall![1]!.body!) as string);
+ return JSON.parse((await lastSettingsCall.options!.body!) as string);
};
export const skipTokenStep = async (name = "Skip") =>
diff --git a/frontend/src/metabase/status/components/DownloadsStatus/DownloadsStatus.unit.spec.tsx b/frontend/src/metabase/status/components/DownloadsStatus/DownloadsStatus.unit.spec.tsx
index 7fb38adfbff..0ae4bc99a8a 100644
--- a/frontend/src/metabase/status/components/DownloadsStatus/DownloadsStatus.unit.spec.tsx
+++ b/frontend/src/metabase/status/components/DownloadsStatus/DownloadsStatus.unit.spec.tsx
@@ -48,7 +48,6 @@ describe("DownloadsStatus", () => {
afterEach(() => {
jest.useRealTimers();
jest.clearAllMocks();
- fetchMock.restore();
});
it("should show and update downloads status", async () => {
diff --git a/frontend/src/metabase/visualizations/components/ObjectDetail/ObjectDetail.unit.spec.tsx b/frontend/src/metabase/visualizations/components/ObjectDetail/ObjectDetail.unit.spec.tsx
index bdeb5f8da65..c43b5964b99 100644
--- a/frontend/src/metabase/visualizations/components/ObjectDetail/ObjectDetail.unit.spec.tsx
+++ b/frontend/src/metabase/visualizations/components/ObjectDetail/ObjectDetail.unit.spec.tsx
@@ -113,38 +113,34 @@ function setup({ hideOrdersTable = false }: SetupOpts = {}) {
}
function setupForeignKeyCountQueryEndpoints() {
- fetchMock.post(
- {
- name: "ordersCountQuery",
- url: "path:/api/dataset",
- matchPartialBody: true,
- body: {
- query: { "source-table": ORDERS_TABLE.id },
- },
+ fetchMock.post({
+ name: "ordersCountQuery",
+ url: "path:/api/dataset",
+ matchPartialBody: true,
+ body: {
+ query: { "source-table": ORDERS_TABLE.id },
},
- createMockDataset({
+ response: createMockDataset({
status: "completed",
data: {
rows: [[PRODUCTS_RECORD_RELATED_ORDERS_COUNT]],
},
}),
- );
- fetchMock.post(
- {
- name: "reviewsCountQuery",
- url: "path:/api/dataset",
- matchPartialBody: true,
- body: {
- query: { "source-table": REVIEWS_TABLE.id },
- },
+ });
+ fetchMock.post({
+ name: "reviewsCountQuery",
+ url: "path:/api/dataset",
+ matchPartialBody: true,
+ body: {
+ query: { "source-table": REVIEWS_TABLE.id },
},
- createMockDataset({
+ response: createMockDataset({
status: "completed",
data: {
rows: [[PRODUCTS_RECORD_RELATED_REVIEWS_COUNT]],
},
}),
- );
+ });
}
function findField(fields: Field[] | undefined, name: string) {
diff --git a/frontend/test/__support__/server-mocks/action.ts b/frontend/test/__support__/server-mocks/action.ts
index a9baf291d5a..e1f813a87f5 100644
--- a/frontend/test/__support__/server-mocks/action.ts
+++ b/frontend/test/__support__/server-mocks/action.ts
@@ -11,16 +11,18 @@ import {
} from "metabase-types/api/mocks";
export function setupActionEndpoints(action: WritebackAction) {
- fetchMock.get(`path:/api/action/${action.id}`, action);
- fetchMock.put(`path:/api/action/${action.id}`, action);
+ const getName = `action-${action.id}-get`;
+ const putName = `action-${action.id}-put`;
+
+ fetchMock.get(`path:/api/action/${action.id}`, action, { name: getName });
+ fetchMock.put(`path:/api/action/${action.id}`, action, { name: putName });
fetchMock.delete(`path:/api/action/${action.id}`, action);
}
function setupActionPostEndpoint() {
fetchMock.post(
- { url: "path:/api/action", overwriteRoutes: true },
- async (url) => {
- const call = fetchMock.lastCall(url);
+ "path:/api/action",
+ async (call) => {
const data = await call?.request?.json();
if (data.type === "implicit") {
return createMockImplicitQueryAction(data);
@@ -30,6 +32,7 @@ function setupActionPostEndpoint() {
}
throw new Error(`Unknown action type: ${data.type}`);
},
+ { name: "action-post" },
);
}
@@ -45,14 +48,11 @@ export function setupModelActionsEndpoints(
actions: WritebackAction[],
modelId: CardId,
) {
- fetchMock.get(
- {
- url: "path:/api/action",
- query: { "model-id": modelId },
- overwriteRoutes: false,
- },
- actions,
- );
+ fetchMock.get({
+ url: "path:/api/action",
+ query: { "model-id": modelId },
+ response: actions,
+ });
setupActionPostEndpoint();
diff --git a/frontend/test/__support__/server-mocks/activity.ts b/frontend/test/__support__/server-mocks/activity.ts
index 6ed10b576cc..7db8dd51a91 100644
--- a/frontend/test/__support__/server-mocks/activity.ts
+++ b/frontend/test/__support__/server-mocks/activity.ts
@@ -1,5 +1,4 @@
-import fetchMock, { type MockOptionsMethodGet } from "fetch-mock";
-import querystring from "querystring";
+import fetchMock, { type UserRouteConfig } from "fetch-mock";
import type {
Dashboard,
@@ -17,19 +16,20 @@ export function setupRecentViewsEndpoints(recentItems: RecentItem[]) {
export function setupRecentViewsAndSelectionsEndpoints(
recentItems: RecentItem[],
context: RecentContexts[] = ["selections", "views"],
- mockOptions: MockOptionsMethodGet = {},
+ routeConfig: UserRouteConfig = {},
mockPostRequest: boolean = true,
) {
- fetchMock.get(
- (url) =>
- url.endsWith(
- `/api/activity/recents?${querystring.stringify({ context })}`,
- ),
- {
- recents: recentItems,
+ fetchMock.get({
+ url: "path:/api/activity/recents",
+ query: {
+ context,
},
- { ...mockOptions },
- );
+ response: {
+ status: 200,
+ body: { recents: recentItems },
+ },
+ ...routeConfig,
+ });
if (mockPostRequest) {
fetchMock.post("path:/api/activity/recents", 200);
diff --git a/frontend/test/__support__/server-mocks/ai-entity-analysis.ts b/frontend/test/__support__/server-mocks/ai-entity-analysis.ts
index 2f108403d1b..58a007f9003 100644
--- a/frontend/test/__support__/server-mocks/ai-entity-analysis.ts
+++ b/frontend/test/__support__/server-mocks/ai-entity-analysis.ts
@@ -3,7 +3,9 @@ import fetchMock from "fetch-mock";
import type { AIEntityAnalysisResponse } from "metabase-types/api";
export function setupAnalyzeChartEndpoint(response: AIEntityAnalysisResponse) {
+ const name = "ai-analyze-chart";
+ fetchMock.removeRoute(name);
fetchMock.post("path:/api/ee/ai-entity-analysis/analyze-chart", response, {
- overwriteRoutes: true,
+ name,
});
}
diff --git a/frontend/test/__support__/server-mocks/audit.ts b/frontend/test/__support__/server-mocks/audit.ts
index a06224a864b..cac9963ab91 100644
--- a/frontend/test/__support__/server-mocks/audit.ts
+++ b/frontend/test/__support__/server-mocks/audit.ts
@@ -1,7 +1,4 @@
-import fetchMock, {
- type MockResponse,
- type MockResponseFunction,
-} from "fetch-mock";
+import fetchMock, { type UserRouteConfig } from "fetch-mock";
import type {
CardId,
@@ -32,7 +29,7 @@ export const setupAuditInfoEndpoint = ({
export const setupAuditUnsubscribeEndpoint = (
userId: User["id"],
- response?: MockResponse | MockResponseFunction,
+ response?: UserRouteConfig,
) => {
fetchMock.delete(
`path:/api/ee/audit-app/user/${userId}/subscriptions`,
diff --git a/frontend/test/__support__/server-mocks/card.ts b/frontend/test/__support__/server-mocks/card.ts
index 5792f495c36..8f7f2aee0e6 100644
--- a/frontend/test/__support__/server-mocks/card.ts
+++ b/frontend/test/__support__/server-mocks/card.ts
@@ -13,41 +13,67 @@ import { createMockCard } from "metabase-types/api/mocks";
import { PERMISSION_ERROR } from "./constants";
export function setupCardEndpoints(card: Card) {
- fetchMock.get(`path:/api/card/${card.id}`, card);
- fetchMock.put(`path:/api/card/${card.id}`, async (url) => {
- const lastCall = fetchMock.lastCall(url);
- return createMockCard(await lastCall?.request?.json());
+ fetchMock.get(`path:/api/card/${card.id}`, card, {
+ name: `card-${card.id}-get`,
+ });
+ fetchMock.put(
+ `path:/api/card/${card.id}`,
+ async (call) => {
+ const lastCall = fetchMock.callHistory.lastCall(call.url);
+ return createMockCard(await lastCall?.request?.json());
+ },
+ { name: `card-${card.id}-put` },
+ );
+ fetchMock.get(`path:/api/card/${card.id}/series`, [], {
+ name: `card-${card.id}-series`,
});
- fetchMock.get(`path:/api/card/${card.id}/series`, []);
}
export function setupCardByEntityIdEndpoints(card: Card) {
- fetchMock.get(`path:/api/card/${card.entity_id}`, card);
- fetchMock.put(`path:/api/card/${card.entity_id}`, async (url) => {
- const lastCall = fetchMock.lastCall(url);
- return createMockCard(await lastCall?.request?.json());
+ fetchMock.get(`path:/api/card/${card.entity_id}`, card, {
+ name: `card-entity-${card.entity_id}-get`,
+ });
+ fetchMock.put(
+ `path:/api/card/${card.entity_id}`,
+ async (call) => {
+ const lastCall = fetchMock.callHistory.lastCall(call.url);
+ return createMockCard(await lastCall?.request?.json());
+ },
+ { name: `card-entity-${card.entity_id}-put` },
+ );
+ fetchMock.get(`path:/api/card/${card.entity_id}/series`, [], {
+ name: `card-entity-${card.entity_id}-series`,
});
- fetchMock.get(`path:/api/card/${card.entity_id}/series`, []);
}
export function setupCardQueryMetadataEndpoint(
card: Card,
metadata: CardQueryMetadata,
) {
- fetchMock.get(`path:/api/card/${card.id}/query_metadata`, metadata);
+ fetchMock.get(`path:/api/card/${card.id}/query_metadata`, metadata, {
+ name: `card-${card.id}-query-metadata`,
+ });
}
export function setupCardsEndpoints(cards: Card[]) {
- fetchMock.get({ url: "path:/api/card", overwriteRoutes: false }, cards);
+ fetchMock.get({
+ url: "path:/api/card",
+ response: cards,
+ name: "cards-list",
+ });
setupCardCreateEndpoint();
cards.forEach((card) => setupCardEndpoints(card));
}
export function setupCardCreateEndpoint() {
- fetchMock.post("path:/api/card", async (url) => {
- const lastCall = fetchMock.lastCall(url);
- return createMockCard(await lastCall?.request?.json());
- });
+ fetchMock.post(
+ "path:/api/card",
+ async (call) => {
+ const lastCall = fetchMock.callHistory.lastCall(call.url);
+ return createMockCard(await lastCall?.request?.json());
+ },
+ { name: "card-create" },
+ );
}
export function setupUnauthorizedCardEndpoints(card: Card) {
diff --git a/frontend/test/__support__/server-mocks/collection.ts b/frontend/test/__support__/server-mocks/collection.ts
index 54b48af58fb..4501635f870 100644
--- a/frontend/test/__support__/server-mocks/collection.ts
+++ b/frontend/test/__support__/server-mocks/collection.ts
@@ -34,28 +34,26 @@ export function setupCollectionsEndpoints({
rootCollection = createMockCollection(ROOT_COLLECTION),
trashCollection = mockTrashCollection,
}: CollectionEndpoints) {
- fetchMock.get("path:/api/collection/root", rootCollection);
- fetchMock.get(`path:/api/collection/trash`, trashCollection);
- fetchMock.get(`path:/api/collection/${trashCollection.id}`, trashCollection);
+ fetchMock.get("path:/api/collection/root", rootCollection, {
+ name: "collection-root",
+ });
+ fetchMock.get(`path:/api/collection/trash`, trashCollection, {
+ name: "collection-trash",
+ });
+ fetchMock.get(`path:/api/collection/${trashCollection.id}`, trashCollection, {
+ name: `collection-${trashCollection.id}`,
+ });
fetchMock.get(
- {
- url: "path:/api/collection/tree",
- query: { "exclude-archived": true },
- overwriteRoutes: false,
- },
+ "path:/api/collection/tree",
collections.filter((collection) => !collection.archived),
+ { name: "collection-tree-exclude-archived" },
);
- fetchMock.get(
- {
- url: "path:/api/collection/tree",
- overwriteRoutes: false,
- },
- collections,
- );
- fetchMock.get(
- { url: "path:/api/collection", overwriteRoutes: false },
- collections,
- );
+ fetchMock.get("path:/api/collection/tree", collections, {
+ name: "collection-tree",
+ });
+ fetchMock.get("path:/api/collection", collections, {
+ name: "collection-list",
+ });
}
function getCollectionVirtualSchemaURLs(collection: Collection) {
@@ -84,8 +82,12 @@ export function setupCollectionVirtualSchemaEndpoints(
convertSavedQuestionToVirtualTable,
);
- fetchMock.get(urls.questions, questionVirtualTables);
- fetchMock.get(urls.models, modelVirtualTables);
+ fetchMock.get(urls.questions, questionVirtualTables, {
+ name: "collection-questions-virtual-tables",
+ });
+ fetchMock.get(urls.models, modelVirtualTables, {
+ name: "collection-models-virtual-tables",
+ });
}
export function setupCollectionItemsEndpoint({
@@ -97,24 +99,29 @@ export function setupCollectionItemsEndpoint({
collectionItems: CollectionItem[];
models?: string[];
}) {
- fetchMock.get(`path:/api/collection/${collection.id}/items`, (uri) => {
- const url = new URL(uri);
- const models = modelsParam ?? url.searchParams.getAll("models");
- const matchedItems = collectionItems.filter(({ model }) =>
- models.includes(model),
- );
-
- const limit = Number(url.searchParams.get("limit")) || matchedItems.length;
- const offset = Number(url.searchParams.get("offset")) || 0;
-
- return {
- data: matchedItems.slice(offset, offset + limit),
- total: matchedItems.length,
- models,
- limit,
- offset,
- };
- });
+ fetchMock.get(
+ `path:/api/collection/${collection.id}/items`,
+ (call) => {
+ const url = new URL(call.url);
+ const models = modelsParam ?? url.searchParams.getAll("models");
+ const matchedItems = collectionItems.filter(({ model }) =>
+ models.includes(model),
+ );
+
+ const limit =
+ Number(url.searchParams.get("limit")) || matchedItems.length;
+ const offset = Number(url.searchParams.get("offset")) || 0;
+
+ return {
+ data: matchedItems.slice(offset, offset + limit),
+ total: matchedItems.length,
+ models,
+ limit,
+ offset,
+ };
+ },
+ { name: `collection-${collection.id}-items` },
+ );
}
export function setupDashboardItemsEndpoint({
@@ -126,8 +133,8 @@ export function setupDashboardItemsEndpoint({
dashboardItems: CollectionItem[];
models?: string[];
}) {
- fetchMock.get(`path:/api/dashboard/${dashboard.id}/items`, (uri) => {
- const url = new URL(uri);
+ fetchMock.get(`path:/api/dashboard/${dashboard.id}/items`, (call) => {
+ const url = new URL(call.url);
const models = modelsParam ?? url.searchParams.getAll("models") ?? ["card"];
const limit =
Number(url.searchParams.get("limit")) || dashboardItems.length;
@@ -185,15 +192,17 @@ export function setupCollectionByIdEndpoint({
return;
}
- fetchMock.get(/api\/collection\/\d+$/, (url) => {
- const collectionIdParam = url.split("/")[5];
+ fetchMock.get(/api\/collection\/\d+$/, (call) => {
+ const urlString = call.url;
+ const parts = urlString.split("/");
+ const collectionIdParam = parts[parts.length - 1];
const collectionId = Number(collectionIdParam);
const collection = collections.find(
(collection) => collection.id === collectionId,
);
- return collection;
+ return collection || { status: 404, body: "Collection not found" };
});
}
@@ -211,8 +220,10 @@ function setupCollectionWithErrorById({
}
export function setupDashboardCollectionItemsEndpoint(dashboards: Dashboard[]) {
- fetchMock.get(/api\/collection\/(\d+|root)\/items/, (url) => {
- const collectionIdParam = url.split("/")[5];
+ fetchMock.get(/api\/collection\/(\d+|root)\/items/, (call) => {
+ const urlString = call.url;
+ const parts = urlString.split("/");
+ const collectionIdParam = parts[parts.indexOf("collection") + 1];
const collectionId =
collectionIdParam !== "root" ? Number(collectionIdParam) : null;
diff --git a/frontend/test/__support__/server-mocks/content-translation.ts b/frontend/test/__support__/server-mocks/content-translation.ts
index d00c3158ad3..fb136b51216 100644
--- a/frontend/test/__support__/server-mocks/content-translation.ts
+++ b/frontend/test/__support__/server-mocks/content-translation.ts
@@ -15,8 +15,8 @@ export function setupContentTranslationEndpoints({
fetchMock.get(
"express:/api/ee/content-translation/dictionary/:token",
- (url): DictionaryResponse => {
- const localeCode = new URL(url).searchParams.get("locale");
+ (call): DictionaryResponse => {
+ const localeCode = new URL(call.url).searchParams.get("locale");
if (!localeCode) {
throw new Error("Locale is required");
}
diff --git a/frontend/test/__support__/server-mocks/dashboard.ts b/frontend/test/__support__/server-mocks/dashboard.ts
index 8769e334248..0f95d2347ab 100644
--- a/frontend/test/__support__/server-mocks/dashboard.ts
+++ b/frontend/test/__support__/server-mocks/dashboard.ts
@@ -12,8 +12,8 @@ import { createMockDashboard } from "metabase-types/api/mocks";
export function setupDashboardEndpoints(dashboard: Dashboard) {
fetchMock.get(`path:/api/dashboard/${dashboard.id}`, dashboard);
- fetchMock.put(`path:/api/dashboard/${dashboard.id}`, async (url) => {
- const lastCall = fetchMock.lastCall(url);
+ fetchMock.put(`path:/api/dashboard/${dashboard.id}`, async (call) => {
+ const lastCall = fetchMock.callHistory.lastCall(call.url);
return createMockDashboard(await lastCall?.request?.json());
});
}
diff --git a/frontend/test/__support__/server-mocks/database.ts b/frontend/test/__support__/server-mocks/database.ts
index d5bfe48c741..ef59c6421d7 100644
--- a/frontend/test/__support__/server-mocks/database.ts
+++ b/frontend/test/__support__/server-mocks/database.ts
@@ -1,4 +1,4 @@
-import fetchMock, { type MockOptionsMethodGet } from "fetch-mock";
+import fetchMock from "fetch-mock";
import _ from "underscore";
import { SAVED_QUESTIONS_DATABASE } from "metabase/databases/constants";
@@ -13,15 +13,18 @@ export function setupDatabaseEndpoints(db: Database) {
fetchMock.post(`path:/api/database/${db.id}/sync_schema`, {});
fetchMock.post(`path:/api/database/${db.id}/rescan_values`, {});
fetchMock.post(`path:/api/database/${db.id}/discard_values`, {});
- fetchMock.get(`path:/api/database/${db.id}/healthcheck`, {
- body: { status: "ok" },
- });
+ fetchMock.get(
+ `path:/api/database/${db.id}/healthcheck`,
+ {
+ body: { status: "ok" },
+ },
+ { name: `database-${db.id}-healthcheck` },
+ );
setupSchemaEndpoints(db);
- setupDatabaseIdFieldsEndpoints(db);
+ setupDatabaseIdFieldsEndpoints({ database: db });
db.tables?.forEach((table) => setupTableEndpoints({ ...table, db }));
- fetchMock.put(`path:/api/database/${db.id}`, async (url) => {
- const call = fetchMock.lastCall(url);
+ fetchMock.put(`path:/api/database/${db.id}`, async (call) => {
const body = await call?.request?.json();
return { ...db, ...body };
});
@@ -34,13 +37,11 @@ export function setupDatabaseUsageInfoEndpoint(
fetchMock.get(`path:/api/database/${db.id}/usage_info`, usageInfo);
}
-export function setupDatabaseListEndpoint(
- databases: Database[],
- { overwriteRoutes = false }: { overwriteRoutes?: boolean } = {},
-) {
+export function setupDatabaseListEndpoint(databases: Database[]) {
fetchMock.get(
- { url: "path:/api/database", overwriteRoutes },
+ "path:/api/database",
{ data: databases, total: databases.length },
+ { name: "database-list" },
);
}
@@ -52,22 +53,23 @@ export function setupDatabasesEndpoints(
const databasesWithSavedQuestions = hasSavedQuestions
? [...databases, SAVED_QUESTIONS_DATABASE]
: databases;
- fetchMock.get(
- {
- url: "path:/api/database",
- query,
- overwriteRoutes: false,
- },
- {
+ fetchMock.get({
+ url: "path:/api/database",
+ query,
+ response: {
data: databasesWithSavedQuestions,
total: databasesWithSavedQuestions.length,
},
- );
- setupDatabaseListEndpoint(databases);
- fetchMock.post("path:/api/database", async (url) => {
- const lastCall = fetchMock.lastCall(url);
- return await lastCall?.request?.json();
+ name: "database-list-with-query",
});
+ setupDatabaseListEndpoint(databases);
+ fetchMock.post(
+ "path:/api/database",
+ async (call) => {
+ return await call?.request?.json();
+ },
+ { name: "database-post" },
+ );
databases.forEach((db) => setupDatabaseEndpoints(db));
}
@@ -82,21 +84,28 @@ export const setupSchemaEndpoints = (db: Database) => {
fetchMock.get(
`path:/api/database/${db.id}/schema/${schema}`,
schemas[schema],
+ { name: `database-${db.id}-schema-${schema}` },
);
});
};
-export function setupDatabaseIdFieldsEndpoints(
- { id, tables = [] }: Database,
- options?: MockOptionsMethodGet,
-) {
+export function setupDatabaseIdFieldsEndpoints({
+ database: { id, tables = [] },
+}: {
+ database: Database;
+}) {
const fields = tables.flatMap((table) =>
(table.fields ?? [])
.filter((field) => isTypePK(field.semantic_type))
.map((field) => ({ ...field, table })),
);
- fetchMock.get(`path:/api/database/${id}/idfields`, fields, options);
+ const name = `database-${id}-idfields`;
+ fetchMock.removeRoute(name);
+
+ fetchMock.get(`path:/api/database/${id}/idfields`, fields, {
+ name,
+ });
}
export const setupUnauthorizedSchemaEndpoints = (db: Database) => {
diff --git a/frontend/test/__support__/server-mocks/dataset.ts b/frontend/test/__support__/server-mocks/dataset.ts
index 594f089dc74..d1fc17811b1 100644
--- a/frontend/test/__support__/server-mocks/dataset.ts
+++ b/frontend/test/__support__/server-mocks/dataset.ts
@@ -5,7 +5,9 @@ import type { MockDatasetOpts } from "metabase-types/api/mocks";
import { createMockDataset } from "metabase-types/api/mocks";
export function setupAdhocQueryMetadataEndpoint(metadata: CardQueryMetadata) {
- fetchMock.post(`path:/api/dataset/query_metadata`, metadata);
+ fetchMock.post(`path:/api/dataset/query_metadata`, metadata, {
+ name: "dataset-query-metadata",
+ });
}
export function setupParameterValuesEndpoints(response: ParameterValues) {
@@ -20,20 +22,15 @@ export function setupParameterSearchValuesEndpoint(
query: string,
response: ParameterValues,
) {
- fetchMock.post(
- {
- url: `path:/api/dataset/parameter/search/${encodeURIComponent(query)}`,
- },
+ fetchMock.post({
+ url: `path:/api/dataset/parameter/search/${encodeURIComponent(query)}`,
response,
- { overwriteRoutes: false },
- );
+ name: `dataset-parameter-search-${query}`,
+ });
}
-export function setupCardDataset(
- options: MockDatasetOpts = {},
- overwriteRoutes = false,
-) {
+export function setupCardDataset(options: MockDatasetOpts = {}) {
fetchMock.post("path:/api/dataset", createMockDataset(options), {
- overwriteRoutes,
+ name: "dataset-post",
});
}
diff --git a/frontend/test/__support__/server-mocks/email.ts b/frontend/test/__support__/server-mocks/email.ts
index d70304f6b5b..9e09cb391da 100644
--- a/frontend/test/__support__/server-mocks/email.ts
+++ b/frontend/test/__support__/server-mocks/email.ts
@@ -11,7 +11,7 @@ const defaultSettings = {
export const setupEmailEndpoints = (settings = defaultSettings) => {
fetchMock.put("path:/api/email", settings);
- fetchMock.post("path:/api/email/test", 204);
+ fetchMock.post("path:/api/email/test", 204, { name: "email-test" });
fetchMock.delete("path:/api/email", 204);
};
diff --git a/frontend/test/__support__/server-mocks/entity-id.ts b/frontend/test/__support__/server-mocks/entity-id.ts
index dfaf1d94b7c..6f7e9dd03c2 100644
--- a/frontend/test/__support__/server-mocks/entity-id.ts
+++ b/frontend/test/__support__/server-mocks/entity-id.ts
@@ -27,7 +27,7 @@ export function setupEntityIdEndpoint(
fetchMock.post(
"path:/api/eid-translation/translate",
async (_url: string, options: RequestInit) => {
- const body = JSON.parse((await options.body) as string) as {
+ const body = JSON.parse(options.body as string) as {
entity_ids: TranslateEntityIdRequest;
};
const requestedIdMap = body?.entity_ids ?? {};
diff --git a/frontend/test/__support__/server-mocks/field.ts b/frontend/test/__support__/server-mocks/field.ts
index be7ebee3bde..c008f5998d6 100644
--- a/frontend/test/__support__/server-mocks/field.ts
+++ b/frontend/test/__support__/server-mocks/field.ts
@@ -1,4 +1,4 @@
-import fetchMock, { type MockOptionsMethodGet } from "fetch-mock";
+import fetchMock from "fetch-mock";
import type {
Field,
@@ -12,16 +12,24 @@ import { PERMISSION_ERROR } from "./constants";
export function setupFieldEndpoints(field: Field) {
fetchMock.get(`path:/api/field/${field.id}`, field);
- fetchMock.post(`path:/api/field/${field.id}/rescan_values`, {});
- fetchMock.post(`path:/api/field/${field.id}/discard_values`, {});
+ fetchMock.post(
+ `path:/api/field/${field.id}/rescan_values`,
+ {},
+ { name: `field-${field.id}-rescan-values` },
+ );
+ fetchMock.post(
+ `path:/api/field/${field.id}/discard_values`,
+ {},
+ { name: `field-${field.id}-discard-values` },
+ );
}
export function setupFieldValuesEndpoint(fieldValues: GetFieldValuesResponse) {
fetchMock.get(`path:/api/field/${fieldValues.field_id}/values`, fieldValues);
fetchMock.post(
`path:/api/field/${fieldValues.field_id}/values`,
- async (url) => {
- const lastCall = fetchMock.lastCall(url);
+ async (call) => {
+ const lastCall = fetchMock.callHistory.lastCall(call.url);
return createMockFieldValues(await lastCall?.request?.json());
},
);
@@ -33,42 +41,25 @@ export function setupRemappedFieldValueEndpoint(
value: string,
fieldValue: FieldValue,
) {
- fetchMock.get(
- {
- url: `path:/api/field/${fieldId}/remapping/${remappedFieldId}`,
- query: { value },
- },
- fieldValue,
- { overwriteRoutes: false },
- );
+ fetchMock.get({
+ url: `path:/api/field/${fieldId}/remapping/${remappedFieldId}`,
+ query: { value },
+ response: fieldValue,
+ });
}
-export function setupUnauthorizedFieldEndpoint(
- field: Field,
- options?: MockOptionsMethodGet,
-) {
- fetchMock.get(
- `path:/api/field/${field.id}`,
- {
- status: 403,
- body: PERMISSION_ERROR,
- },
- options,
- );
+export function setupUnauthorizedFieldEndpoint(field: Field) {
+ fetchMock.get(`path:/api/field/${field.id}`, {
+ status: 403,
+ body: PERMISSION_ERROR,
+ });
}
-export function setupUnauthorizedFieldValuesEndpoints(
- fieldId: FieldId,
- options?: MockOptionsMethodGet,
-) {
- fetchMock.get(
- `path:/api/field/${fieldId}/values`,
- {
- status: 403,
- body: PERMISSION_ERROR,
- },
- options,
- );
+export function setupUnauthorizedFieldValuesEndpoints(fieldId: FieldId) {
+ fetchMock.get(`path:/api/field/${fieldId}/values`, {
+ status: 403,
+ body: PERMISSION_ERROR,
+ });
}
export function setupFieldsValuesEndpoints(
@@ -83,17 +74,14 @@ export function setupFieldSearchValuesEndpoint(
searchValue: string,
result: FieldValue[] = [],
) {
- fetchMock.get(
- {
- url: `path:/api/field/${fieldId}/search/${searchFieldId}`,
- query: {
- value: searchValue,
- limit: 100, // corresponds to MAX_SEARCH_RESULTS in FieldValuesWidget
- },
+ fetchMock.get({
+ url: `path:/api/field/${fieldId}/search/${searchFieldId}`,
+ query: {
+ value: searchValue,
+ limit: 100, // corresponds to MAX_SEARCH_RESULTS in FieldValuesWidget
},
- {
+ response: {
body: result,
},
- { overwriteRoutes: false },
- );
+ });
}
diff --git a/frontend/test/__support__/server-mocks/gdrive.ts b/frontend/test/__support__/server-mocks/gdrive.ts
index 95227c9825e..dc00a7f9c6c 100644
--- a/frontend/test/__support__/server-mocks/gdrive.ts
+++ b/frontend/test/__support__/server-mocks/gdrive.ts
@@ -5,21 +5,23 @@ import type { GdrivePayload } from "metabase-types/api";
export function setupGdriveGetFolderEndpoint({
errorCode,
...gdrivePayload
-}: Partial<GdrivePayload> & { errorCode?: number }) {
+}: Partial<GdrivePayload> & {
+ errorCode?: number;
+} = {}) {
+ fetchMock.removeRoute("gdrive-get-folder");
+
if (errorCode) {
fetchMock.get("path:/api/ee/gsheets/connection", errorCode, {
- overwriteRoutes: true,
+ name: "gdrive-get-folder",
});
return;
}
-
fetchMock.get(
"path:/api/ee/gsheets/connection",
() => {
- // fetchmock gets confused if you try to return only a 'status' property
return { ...gdrivePayload, _test: "" };
},
- { overwriteRoutes: true },
+ { name: "gdrive-get-folder" },
);
}
diff --git a/frontend/test/__support__/server-mocks/google.ts b/frontend/test/__support__/server-mocks/google.ts
index ecf9a2bccb2..bd0000f7f8c 100644
--- a/frontend/test/__support__/server-mocks/google.ts
+++ b/frontend/test/__support__/server-mocks/google.ts
@@ -6,6 +6,6 @@ export function setupUpdateGoogleAuthEndpoint(
fetchMock.put(
new RegExp("/api/google/settings"),
{ status },
- { overwriteRoutes: true },
+ { name: "google-settings-put" },
);
}
diff --git a/frontend/test/__support__/server-mocks/impersonation.ts b/frontend/test/__support__/server-mocks/impersonation.ts
index 4777f633910..525988e7c72 100644
--- a/frontend/test/__support__/server-mocks/impersonation.ts
+++ b/frontend/test/__support__/server-mocks/impersonation.ts
@@ -5,30 +5,26 @@ import type { DatabaseId, GroupId, Impersonation } from "metabase-types/api";
export const setupExistingImpersonationEndpoint = (
impersonation: Impersonation,
) => {
- fetchMock.get(
- {
- url: `path:/api/ee/advanced-permissions/impersonation`,
- query: {
- db_id: impersonation.db_id,
- group_id: impersonation.group_id,
- },
+ fetchMock.get({
+ url: `path:/api/ee/advanced-permissions/impersonation`,
+ query: {
+ db_id: impersonation.db_id,
+ group_id: impersonation.group_id,
},
- impersonation,
- );
+ response: impersonation,
+ });
};
export const setupMissingImpersonationEndpoint = (
databaseId: DatabaseId,
groupId: GroupId,
) => {
- fetchMock.get(
- {
- url: `path:/api/ee/advanced-permissions/impersonation`,
- query: {
- db_id: databaseId,
- group_id: groupId,
- },
+ fetchMock.get({
+ url: `path:/api/ee/advanced-permissions/impersonation`,
+ query: {
+ db_id: databaseId,
+ group_id: groupId,
},
- () => null,
- );
+ response: null,
+ });
};
diff --git a/frontend/test/__support__/server-mocks/logger.ts b/frontend/test/__support__/server-mocks/logger.ts
index 0226a32c227..3a556eb8f18 100644
--- a/frontend/test/__support__/server-mocks/logger.ts
+++ b/frontend/test/__support__/server-mocks/logger.ts
@@ -1,29 +1,17 @@
-import fetchMock, {
- type MockOptionsMethodDelete,
- type MockOptionsMethodGet,
- type MockOptionsMethodPost,
- type MockResponse,
-} from "fetch-mock";
+import fetchMock from "fetch-mock";
import type { LoggerPreset } from "metabase-types/api";
-export function setupLoggerPresetsEndpoint(
- response: LoggerPreset[] | MockResponse,
- options?: MockOptionsMethodGet,
-) {
- fetchMock.get("path:/api/logger/presets", response, options);
+export function setupLoggerPresetsEndpoint(response: LoggerPreset[]) {
+ fetchMock.get("path:/api/logger/presets", response, {
+ name: "logger-presets",
+ });
}
-export function setupPostLoggerAdjustmentEndpoint(
- response: MockResponse = { status: 200 },
- options?: MockOptionsMethodPost,
-) {
- fetchMock.post("path:/api/logger/adjustment", response, options);
+export function setupPostLoggerAdjustmentEndpoint() {
+ fetchMock.post("path:/api/logger/adjustment", { status: 200 });
}
-export function setupDeleteLoggerAdjustmentEndpoint(
- response: MockResponse = { status: 200 },
- options?: MockOptionsMethodDelete,
-) {
- fetchMock.delete("path:/api/logger/adjustment", response, options);
+export function setupDeleteLoggerAdjustmentEndpoint() {
+ fetchMock.delete("path:/api/logger/adjustment", { status: 200 });
}
diff --git a/frontend/test/__support__/server-mocks/metabot.ts b/frontend/test/__support__/server-mocks/metabot.ts
index 803711319a8..e7f72574047 100644
--- a/frontend/test/__support__/server-mocks/metabot.ts
+++ b/frontend/test/__support__/server-mocks/metabot.ts
@@ -1,7 +1,4 @@
-import fetchMock, {
- type MockOptionsMethodGet,
- type MockOptionsMethodPost,
-} from "fetch-mock";
+import fetchMock, { type UserRouteConfig } from "fetch-mock";
import type {
MetabotApiEntity,
@@ -18,7 +15,6 @@ export function setupMetabotsEndpoint(
fetchMock.get(
"path:/api/ee/metabot-v3/metabot",
statusCode ? { status: statusCode } : { items: metabots },
- { overwriteRoutes: true },
);
}
@@ -28,8 +24,10 @@ export function setupMetabotEntitiesEndpoint(
) {
fetchMock.get(
`path:/api/ee/metabot-v3/metabot/${metabotId}/entities`,
- { items: entities },
- { overwriteRoutes: true },
+ {
+ items: entities,
+ },
+ { name: `metabot-${metabotId}-entities-get` },
);
}
@@ -54,28 +52,38 @@ export function setupMetabotPromptSuggestionsEndpointError(
);
}
-export function setupMetabotPromptSuggestionsEndpoint(
- metabotId: MetabotId,
- prompts: SuggestedMetabotPromptsResponse["prompts"],
+type SuggestionsEndpointOptions = {
+ metabotId: MetabotId;
+ prompts: SuggestedMetabotPromptsResponse["prompts"];
paginationContext: {
offset: number;
limit: number;
total: number;
- },
- options?: MockOptionsMethodGet,
-) {
+ };
+ delay?: UserRouteConfig["delay"];
+};
+
+export function setupMetabotPromptSuggestionsEndpoint({
+ metabotId,
+ prompts,
+ paginationContext,
+ delay,
+}: SuggestionsEndpointOptions) {
const { total, limit, offset } = paginationContext;
const page = prompts.slice(offset, offset + limit);
const body = { prompts: page, limit, offset, total };
- fetchMock.get(
- {
- url: `path:/api/ee/metabot-v3/metabot/${metabotId}/prompt-suggestions`,
- query: { limit, offset },
+ fetchMock.removeRoute(`metabot-${metabotId}-prompt-suggestions-get`);
+ fetchMock.get({
+ url: `path:/api/ee/metabot-v3/metabot/${metabotId}/prompt-suggestions`,
+ query: { limit, offset },
+ response: {
+ status: 200,
+ body,
},
- { status: 200, body },
- { overwriteRoutes: true, ...(options || {}) },
- );
+ name: `metabot-${metabotId}-prompt-suggestions-get`,
+ delay,
+ });
return {
...paginationContext,
@@ -95,7 +103,7 @@ export function setupRemoveMetabotPromptSuggestionEndpoint(
export function setupRegenerateMetabotPromptSuggestionsEndpoint(
metabotId: MetabotId,
- options?: MockOptionsMethodPost,
+ options?: UserRouteConfig,
) {
fetchMock.post(
`path:/api/ee/metabot-v3/metabot/${metabotId}/prompt-suggestions/regenerate`,
diff --git a/frontend/test/__support__/server-mocks/model-indexes.ts b/frontend/test/__support__/server-mocks/model-indexes.ts
index 1550e514da1..f6edfd44cb7 100644
--- a/frontend/test/__support__/server-mocks/model-indexes.ts
+++ b/frontend/test/__support__/server-mocks/model-indexes.ts
@@ -7,15 +7,12 @@ export function setupModelIndexEndpoints(
modelId: CardId,
indexes: ModelIndex[] = [],
) {
- fetchMock.get(
- {
- url: `path:/api/model-index`,
- query: { model_id: modelId },
- overwriteRoutes: false,
- },
- indexes,
- { name: `getModelIndexes-${modelId}` },
- );
+ fetchMock.get({
+ url: `path:/api/model-index`,
+ query: { model_id: modelId },
+ response: indexes,
+ name: `getModelIndexes-${modelId}`,
+ });
indexes.forEach((index) => {
fetchMock.delete(`path:/api/model-index/${index.id}`, 200, {
@@ -25,8 +22,8 @@ export function setupModelIndexEndpoints(
fetchMock.post(
`path:/api/model-index`,
- async (url) => {
- const lastCall = fetchMock.lastCall(url);
+ async (call) => {
+ const lastCall = fetchMock.callHistory.lastCall(call.url);
return createMockModelIndex(await lastCall?.request?.json());
},
{ name: `createModelIndex` },
diff --git a/frontend/test/__support__/server-mocks/native-query-snippet.ts b/frontend/test/__support__/server-mocks/native-query-snippet.ts
index c717f8c133f..ee5c64a6411 100644
--- a/frontend/test/__support__/server-mocks/native-query-snippet.ts
+++ b/frontend/test/__support__/server-mocks/native-query-snippet.ts
@@ -7,8 +7,8 @@ const PATH = "path:/api/native-query-snippet";
export function setupNativeQuerySnippetEndpoints(
{ snippets = [] }: { snippets?: NativeQuerySnippet[] } = { snippets: [] },
) {
- fetchMock.get(PATH, () => snippets);
+ fetchMock.get(PATH, snippets);
snippets.forEach((snippet) =>
- fetchMock.get(`${PATH}/${snippet.id}`, () => snippet),
+ fetchMock.get(`${PATH}/${snippet.id}`, snippet),
);
}
diff --git a/frontend/test/__support__/server-mocks/notification.ts b/frontend/test/__support__/server-mocks/notification.ts
index 3a3a4827594..f392bd4175a 100644
--- a/frontend/test/__support__/server-mocks/notification.ts
+++ b/frontend/test/__support__/server-mocks/notification.ts
@@ -11,8 +11,8 @@ export const setupListNotificationEndpoints = (
) => {
fetchMock.get("path:/api/notification", notifications, {
query: {
- card_id,
- include_inactive: false,
+ card_id: card_id ? card_id.toString() : "",
+ include_inactive: false.toString(),
},
});
};
diff --git a/frontend/test/__support__/server-mocks/performance.ts b/frontend/test/__support__/server-mocks/performance.ts
index c2881e13641..7fd46c89375 100644
--- a/frontend/test/__support__/server-mocks/performance.ts
+++ b/frontend/test/__support__/server-mocks/performance.ts
@@ -2,7 +2,7 @@ import fetchMock from "fetch-mock";
import type { CacheConfig } from "metabase-types/api";
export function setupPerformanceEndpoints(cacheConfigs: CacheConfig[]) {
- fetchMock.get({ url: "path:/api/cache" }, { data: cacheConfigs });
- fetchMock.put({ url: "path:/api/cache" }, {});
- fetchMock.delete({ url: "path:/api/cache" }, {});
+ fetchMock.get("path:/api/cache", { data: cacheConfigs });
+ fetchMock.put("path:/api/cache", {});
+ fetchMock.delete("path:/api/cache", {});
}
diff --git a/frontend/test/__support__/server-mocks/permissions.ts b/frontend/test/__support__/server-mocks/permissions.ts
index f9d00e79a61..64234987f04 100644
--- a/frontend/test/__support__/server-mocks/permissions.ts
+++ b/frontend/test/__support__/server-mocks/permissions.ts
@@ -35,12 +35,9 @@ export const setupCollectionPermissionsGraphEndpoint = (
permissionsGraph: CollectionPermissionsGraph,
) => {
fetchMock.get("path:/api/collection/graph", permissionsGraph);
- fetchMock.put(
- "path:/api/collection/graph",
- (url: string, opts: any, req: { body: any }) => {
- const body = JSON.parse(req.body);
- body.revision += 1;
- return body;
- },
- );
+ fetchMock.put("path:/api/collection/graph", (call) => {
+ const body = JSON.parse(call.options?.body as string);
+ body.revision += 1;
+ return body;
+ });
};
diff --git a/frontend/test/__support__/server-mocks/premium-features.ts b/frontend/test/__support__/server-mocks/premium-features.ts
index 9f108eb531c..7e6760e50fc 100644
--- a/frontend/test/__support__/server-mocks/premium-features.ts
+++ b/frontend/test/__support__/server-mocks/premium-features.ts
@@ -1,9 +1,14 @@
import fetchMock from "fetch-mock";
-export const setupTokenStatusEndpoint = (
- valid: boolean,
- features: string[] = [],
-) => {
+export const setupTokenStatusEndpoint = ({
+ valid,
+ features,
+}: {
+ valid: boolean;
+ features?: string[];
+}) => {
+ const name = "premium-token-status";
+ fetchMock.removeRoute(name);
fetchMock.get(
"path:/api/premium-features/token/status",
{
@@ -11,13 +16,13 @@ export const setupTokenStatusEndpoint = (
"valid-thru": valid ? "2099-12-31T12:00:00" : null,
features,
},
- { overwriteRoutes: true },
+ { name },
);
};
export const setupTokenStatusEndpointEmpty = () => {
fetchMock.get("path:/api/premium-features/token/status", 404, {
- overwriteRoutes: true,
+ name: "premium-token-status",
});
};
@@ -28,10 +33,19 @@ export const setupTokenActivationEndpoint = ({
success?: boolean;
status?: number;
}) => {
+ const name = "premium-token-activation";
+ try {
+ fetchMock.removeRoute(name);
+ } catch {
+ // Route might not exist, ignore
+ }
const responseStatus = status ?? (success ? 204 : 400);
fetchMock.put(
"path:/api/setting/premium-embedding-token",
{ success, error: success ? undefined : "Invalid token" },
- { response: responseStatus, overwriteRoutes: true },
+ {
+ response: responseStatus,
+ name,
+ },
);
};
diff --git a/frontend/test/__support__/server-mocks/search.ts b/frontend/test/__support__/server-mocks/search.ts
index d50f44c4c19..10563169ce6 100644
--- a/frontend/test/__support__/server-mocks/search.ts
+++ b/frontend/test/__support__/server-mocks/search.ts
@@ -1,17 +1,16 @@
-import fetchMock, { type MockOptionsMethodGet } from "fetch-mock";
+import fetchMock from "fetch-mock";
import { match } from "ts-pattern";
import type { CollectionItem, SearchResult } from "metabase-types/api";
import type { EmbeddingDataPicker } from "metabase-types/store/embedding-data-picker";
-export function setupSearchEndpoints(
- items: (CollectionItem | SearchResult)[],
- options?: MockOptionsMethodGet,
-) {
+export function setupSearchEndpoints(items: (CollectionItem | SearchResult)[]) {
+ const name = "search";
+ fetchMock.removeRoute(name);
fetchMock.get(
"path:/api/search",
- (uri) => {
- const url = new URL(uri);
+ (call) => {
+ const url = new URL(call.url);
const models = url.searchParams.getAll("models");
const limit = Number(url.searchParams.get("limit")) || 50;
const offset = Number(url.searchParams.get("offset"));
@@ -30,7 +29,6 @@ export function setupSearchEndpoints(
matchedItems = matchedItems.filter(
({ model }) => !models.length || models.includes(model),
);
-
return {
data: matchedItems.slice(offset, offset + limit),
total: matchedItems.length,
@@ -41,7 +39,7 @@ export function setupSearchEndpoints(
table_db_id,
};
},
- options,
+ { name },
);
}
@@ -53,17 +51,15 @@ export function setupEmbeddingDataPickerDecisionEndpoints(
.with("staged", () => 100)
.exhaustive();
- fetchMock.get(
- {
- name: "entity-count",
- url: "path:/api/search",
- query: {
- models: ["dataset", "table"],
- limit: 0,
- },
+ fetchMock.get({
+ name: "entity-count",
+ url: "path:/api/search",
+ query: {
+ models: ["dataset", "table"],
+ limit: 0,
},
- {
+ response: {
total: mockEntityCount,
},
- );
+ });
}
diff --git a/frontend/test/__support__/server-mocks/segment.ts b/frontend/test/__support__/server-mocks/segment.ts
index 890c26fe0d9..0edb7dd15ab 100644
--- a/frontend/test/__support__/server-mocks/segment.ts
+++ b/frontend/test/__support__/server-mocks/segment.ts
@@ -8,8 +8,10 @@ export function setupSegmentEndpoint(segment: Segment) {
}
export function setupSegmentsEndpoints(segments: Segment[]) {
- fetchMock.post("path:/api/segment", async (url) => {
- const metric = await fetchMock.lastCall(url)?.request?.json();
+ fetchMock.post("path:/api/segment", async (call) => {
+ const metric = await fetchMock.callHistory
+ .lastCall(call.url)
+ ?.request?.json();
return createMockSegment(metric);
});
fetchMock.get("path:/api/segment", segments);
diff --git a/frontend/test/__support__/server-mocks/session.ts b/frontend/test/__support__/server-mocks/session.ts
index f277090b51a..0adb03b8818 100644
--- a/frontend/test/__support__/server-mocks/session.ts
+++ b/frontend/test/__support__/server-mocks/session.ts
@@ -9,29 +9,36 @@ import type {
export function setupPropertiesEndpoints(
settings: Settings | EnterpriseSettings,
) {
+ fetchMock.removeRoute("get-session-properties");
fetchMock.get("path:/api/session/properties", settings, {
- overwriteRoutes: true,
+ name: "get-session-properties",
});
}
export function setupLoginEndpoint() {
- fetchMock.post("path:/api/session", 204);
+ fetchMock.post("path:/api/session", 204, { name: "session-login" });
}
export function setupLogoutEndpoint() {
- fetchMock.delete("path:/api/session", 204);
+ fetchMock.delete("path:/api/session", 204, { name: "session-logout" });
}
export function setupForgotPasswordEndpoint() {
- fetchMock.post("path:/api/session/forgot_password", 204);
+ fetchMock.post("path:/api/session/forgot_password", 204, {
+ name: "session-forgot-password",
+ });
}
export function setupResetPasswordEndpoint() {
- fetchMock.post("path:/api/session/reset_password", 204);
+ fetchMock.post("path:/api/session/reset_password", 204, {
+ name: "session-reset-password",
+ });
}
export function setupPasswordResetTokenEndpoint(
status: PasswordResetTokenStatus,
) {
- fetchMock.get("path:/api/session/password_reset_token_valid", status);
+ fetchMock.get("path:/api/session/password_reset_token_valid", status, {
+ name: "session-password-reset-token",
+ });
}
diff --git a/frontend/test/__support__/server-mocks/settings.ts b/frontend/test/__support__/server-mocks/settings.ts
index bcbc58e746d..cc86d9d4d3f 100644
--- a/frontend/test/__support__/server-mocks/settings.ts
+++ b/frontend/test/__support__/server-mocks/settings.ts
@@ -11,7 +11,7 @@ import type {
} from "metabase-types/api";
export function setupSettingsEndpoints(settings: SettingDefinition[]) {
- fetchMock.get("path:/api/setting", settings);
+ fetchMock.get("path:/api/setting", settings, { name: "settings-list" });
}
export function setupSettingEndpoint<K extends EnterpriseSettingKey>({
@@ -24,23 +24,25 @@ export function setupSettingEndpoint<K extends EnterpriseSettingKey>({
if (settingValue === null || settingValue === undefined) {
throw new Error("settingValue must be non-null and non-undefined");
}
- fetchMock.get("path:/api/setting/" + settingKey, settingValue);
+ fetchMock.get(
+ "path:/api/setting/" + settingKey,
+ { body: settingValue },
+ { name: `setting-${settingKey}` },
+ );
}
export function setupUpdateSettingEndpoint(
{ status }: { status?: number } = { status: 204 },
) {
- fetchMock.put(
- new RegExp("/api/setting/"),
- { status },
- { overwriteRoutes: true },
- );
+ const name = "update-setting";
+ fetchMock.removeRoute(name);
+ fetchMock.put(new RegExp("/api/setting/"), { status }, { name: name });
}
export function setupUpdateSettingsEndpoint(
{ status }: { status?: number } = { status: 204 },
) {
- fetchMock.put("path:/api/setting", { status }, { overwriteRoutes: true });
+ fetchMock.put("path:/api/setting", { status });
}
export function setupScimEndpoints(
diff --git a/frontend/test/__support__/server-mocks/table.ts b/frontend/test/__support__/server-mocks/table.ts
index 10a8470c54f..5c9389906f1 100644
--- a/frontend/test/__support__/server-mocks/table.ts
+++ b/frontend/test/__support__/server-mocks/table.ts
@@ -10,10 +10,26 @@ export function setupTableEndpoints(
) {
fetchMock.get(`path:/api/table/${table.id}`, table);
fetchMock.get(`path:/api/table/${table.id}/fks`, foreignKeys);
- fetchMock.put(`path:/api/table/${table.id}`, {});
- fetchMock.post(`path:/api/table/${table.id}/rescan_values`, {});
- fetchMock.post(`path:/api/table/${table.id}/sync_schema`, {});
- fetchMock.post(`path:/api/table/${table.id}/discard_values`, {});
+ fetchMock.put(
+ `path:/api/table/${table.id}`,
+ {},
+ { name: `table-${table.id}-put` },
+ );
+ fetchMock.post(
+ `path:/api/table/${table.id}/rescan_values`,
+ {},
+ { name: `table-${table.id}-rescan-values` },
+ );
+ fetchMock.post(
+ `path:/api/table/${table.id}/sync_schema`,
+ {},
+ { name: `table-${table.id}-sync-schema` },
+ );
+ fetchMock.post(
+ `path:/api/table/${table.id}/discard_values`,
+ {},
+ { name: `table-${table.id}-discard-values` },
+ );
setupTableQueryMetadataEndpoint(table);
table.fields?.forEach((field) => setupFieldEndpoints({ ...field, table }));
}
@@ -36,11 +52,14 @@ export function setupUploadManagementEndpoint(tables: Table[]) {
* @param failureId - the id of the table that should fail to delete, any other id will succeed
*/
export function setupDeleteUploadManagementDeleteEndpoint(failureId?: number) {
- fetchMock.delete(`glob:*/api/ee/upload-management/tables/*`, (url) => {
- return url.includes(`/${failureId}`)
+ fetchMock.delete(`glob:*/api/ee/upload-management/tables/*`, (call) => {
+ return call.url.includes(`/${failureId}`)
? {
throws: { data: { message: "It's dead Jim" } },
}
- : true;
+ : // fetch-mock doesn't like returning true directly
+ new Response(JSON.stringify(true), {
+ status: 200,
+ });
});
}
diff --git a/frontend/test/__support__/server-mocks/task.ts b/frontend/test/__support__/server-mocks/task.ts
index 5a9246d0882..c19bcb467d2 100644
--- a/frontend/test/__support__/server-mocks/task.ts
+++ b/frontend/test/__support__/server-mocks/task.ts
@@ -1,22 +1,22 @@
-import fetchMock, { type MockOptionsMethodGet } from "fetch-mock";
+import fetchMock, { type UserRouteConfig } from "fetch-mock";
import type { ListTasksResponse, Task } from "metabase-types/api";
export function setupTasksEndpoints(
response: ListTasksResponse,
- options?: MockOptionsMethodGet,
+ options?: UserRouteConfig,
) {
fetchMock.get("path:/api/task", response, options);
response.data.forEach((task) => setupTaskEndpoint(task));
}
-export function setupTaskEndpoint(task: Task, options?: MockOptionsMethodGet) {
+export function setupTaskEndpoint(task: Task, options?: UserRouteConfig) {
fetchMock.get(`path:/api/task/${task.id}`, task, options);
}
export function setupUniqueTasksEndpoint(
tasks: string[],
- options?: MockOptionsMethodGet,
+ options?: UserRouteConfig,
) {
fetchMock.get(`path:/api/task/unique-tasks`, tasks, options);
}
diff --git a/frontend/test/__support__/server-mocks/user-key-value.ts b/frontend/test/__support__/server-mocks/user-key-value.ts
index 9fba36dc4df..9de7650db15 100644
--- a/frontend/test/__support__/server-mocks/user-key-value.ts
+++ b/frontend/test/__support__/server-mocks/user-key-value.ts
@@ -12,13 +12,11 @@ export const setupUserKeyValueEndpoints = ({
const getName = `get-${name}`;
const putName = `put-${name}`;
-
fetchMock.get(
`path:/api/user-key-value/namespace/${namespace}/key/${key}`,
- {
+ new Response(JSON.stringify(value), {
status: 200,
- body: value,
- },
+ }),
{
name: getName,
},
@@ -26,9 +24,7 @@ export const setupUserKeyValueEndpoints = ({
fetchMock.put(
`path:/api/user-key-value/namespace/${namespace}/key/${key}`,
- {
- status: 200,
- },
+ { status: 200 },
{
name: putName,
},
@@ -48,10 +44,14 @@ export const setupUserKeyValueEndpoints = ({
};
export function setupGetUserKeyValueEndpoint(kv: UserKeyValue) {
- return fetchMock.get(
+ fetchMock.get(
`path:/api/user-key-value/namespace/${kv.namespace}/key/${kv.key}`,
- { status: 200, body: kv.value },
- { overwriteRoutes: true },
+ new Response(JSON.stringify(kv.value), {
+ status: 200,
+ headers: { "Content-Type": "application/json" },
+ }),
+
+ { name: "get-key-value" },
);
}
@@ -59,7 +59,6 @@ export function setupNullGetUserKeyValueEndpoints() {
return fetchMock.get(
`express:/api/user-key-value/namespace/:namespace/key/:key`,
{ status: 200 },
- { overwriteRoutes: true },
);
}
@@ -67,7 +66,6 @@ export function setupUpdateUserKeyValueEndpoint(kv: UserKeyValue) {
return fetchMock.put(
`path:/api/user-key-value/namespace/${kv.namespace}/key/${kv.key}`,
{ status: 200, body: kv.value },
- { overwriteRoutes: true },
);
}
@@ -75,7 +73,6 @@ export function setupDeleteUserKeyValueEndpoint(k: UserKeyValueKey) {
return fetchMock.delete(
`path:/api/user-key-value/namespace/${k.namespace}/key/${k.key}`,
{ status: 200 },
- { overwriteRoutes: true },
);
}
diff --git a/frontend/test/__support__/server-mocks/user.ts b/frontend/test/__support__/server-mocks/user.ts
index 4a7a1e2dd2a..ee2f9e33504 100644
--- a/frontend/test/__support__/server-mocks/user.ts
+++ b/frontend/test/__support__/server-mocks/user.ts
@@ -1,4 +1,3 @@
-import type { MockOptionsMethodGet } from "fetch-mock";
import fetchMock from "fetch-mock";
import type {
@@ -17,11 +16,8 @@ export function setupUsersEndpoints(users: UserListResult[]) {
return fetchMock.get("path:/api/user", { data: users, total: users.length });
}
-export function setupCurrentUserEndpoint(
- user: User,
- options?: MockOptionsMethodGet,
-) {
- return fetchMock.get("path:/api/user/current", user, options);
+export function setupCurrentUserEndpoint(user: User) {
+ return fetchMock.get("path:/api/user/current", user);
}
export function setupUserAttributesEndpoint(attributes: UserAttributeKey[]) {
diff --git a/frontend/test/__support__/server-mocks/util.ts b/frontend/test/__support__/server-mocks/util.ts
index 4100731e3fe..672e07c72a8 100644
--- a/frontend/test/__support__/server-mocks/util.ts
+++ b/frontend/test/__support__/server-mocks/util.ts
@@ -12,14 +12,27 @@ type ResponseInfo = {
export async function findRequests(
method: "PUT" | "POST" | "GET" | "DELETE",
): Promise<ResponseInfo[]> {
- const calls = fetchMock.calls();
- const data = calls.filter((call) => call[1]?.method === method) ?? [];
+ // Ensure all async call history is complete
+ await fetchMock.callHistory.flush();
- const reqs = data.map(async ([url, details]) => {
- const body = ((await details?.body) as string) ?? "{}";
+ const calls = fetchMock.callHistory.calls();
+ const filteredCalls = calls.filter((call) => call.request?.method === method);
- return { url, body: JSON.parse(body ?? "{}") };
- });
+ return Promise.all(
+ filteredCalls.map(async (call) => {
+ let bodyText = "";
- return Promise.all(reqs);
+ // Try to get body from options first, then from request
+ if (call.options?.body) {
+ bodyText = call.options.body.toString();
+ } else if (call.request?.body && !call.request.bodyUsed) {
+ bodyText = await call.request.clone().text();
+ }
+
+ return {
+ url: call.url || "",
+ body: bodyText ? JSON.parse(bodyText) : {},
+ };
+ }),
+ );
}
diff --git a/frontend/test/__support__/utils.ts b/frontend/test/__support__/utils.ts
index 805ab939e44..be996d9945a 100644
--- a/frontend/test/__support__/utils.ts
+++ b/frontend/test/__support__/utils.ts
@@ -1,4 +1,4 @@
-import type fetchMock from "fetch-mock";
+import type { CallLog } from "fetch-mock";
import { act, waitFor } from "./ui";
@@ -23,9 +23,7 @@ export async function delay(duration: number) {
* better failure messages (request arrived but wrong details vs request never
* arrived)
*/
-export const waitForRequest = async (
- requestFn: () => fetchMock.MockCall | undefined,
-) => {
+export const waitForRequest = async (requestFn: () => CallLog | undefined) => {
try {
// try catch to make jest show the line where waitForRequest was originally called
await waitFor(() => {
diff --git a/frontend/test/jest-setup-env.js b/frontend/test/jest-setup-env.js
index 4baee92c53b..9b6068d10b9 100644
--- a/frontend/test/jest-setup-env.js
+++ b/frontend/test/jest-setup-env.js
@@ -2,7 +2,12 @@ import "@testing-library/jest-dom";
import fetchMock from "fetch-mock";
beforeEach(() => {
- fetchMock.restore();
+ fetchMock.mockGlobal();
+});
+
+afterEach(() => {
+ fetchMock.removeRoutes();
+ fetchMock.callHistory.clear();
fetchMock.catch((url, request) => {
const errorMessage = `Caught unmocked ${request.method} request to: ${url}`;
diff --git a/frontend/test/metabase/lib/api.unit.spec.js b/frontend/test/metabase/lib/api.unit.spec.js
index 3d34ca9071f..a574ffe71d4 100644
--- a/frontend/test/metabase/lib/api.unit.spec.js
+++ b/frontend/test/metabase/lib/api.unit.spec.js
@@ -30,8 +30,8 @@ describe("api", () => {
it("should PUT with remaining params as body", async () => {
expect.assertions(1);
- fetchMock.put("path:/hello/123", async (uri) => {
- const body = await fetchMock.lastCall(uri).request.json();
+ fetchMock.put("path:/hello/123", async (call) => {
+ const body = await call?.request?.json();
expect(body).toEqual({ other: "stuff" });
return 200;
});
@@ -40,8 +40,8 @@ describe("api", () => {
it("should PUT with a specific params as the body", async () => {
expect.assertions(1);
- fetchMock.put("path:/hello/123", async (uri) => {
- const body = await fetchMock.lastCall(uri).request.json();
+ fetchMock.put("path:/hello/123", async (call) => {
+ const body = await call?.request?.json();
expect(body).toEqual(["i", "am", "an", "array"]);
return 200;
});
@@ -62,9 +62,16 @@ describe("api", () => {
it("GET should retry and succeed if 503 then 200", async () => {
expect.assertions(1);
- fetchMock.getOnce({ url: "path:/hello", overwriteRoutes: false }, 503);
fetchMock.getOnce(
- { url: "path:/hello", overwriteRoutes: false },
+ {
+ url: "path:/hello",
+ },
+ 503,
+ );
+ fetchMock.getOnce(
+ {
+ url: "path:/hello",
+ },
successResponse,
);
const hello = GET("/hello", { retry: true });
@@ -79,10 +86,30 @@ describe("api", () => {
it("GET should fail if after retryCount it still returns 503", async () => {
expect.assertions(1);
- fetchMock.getOnce({ url: "path:/hello", overwriteRoutes: false }, 503);
- fetchMock.getOnce({ url: "path:/hello", overwriteRoutes: false }, 503);
- fetchMock.getOnce({ url: "path:/hello", overwriteRoutes: false }, 503);
- fetchMock.getOnce({ url: "path:/hello", overwriteRoutes: false }, 503);
+ fetchMock.getOnce(
+ {
+ url: "path:/hello",
+ },
+ 503,
+ );
+ fetchMock.getOnce(
+ {
+ url: "path:/hello",
+ },
+ 503,
+ );
+ fetchMock.getOnce(
+ {
+ url: "path:/hello",
+ },
+ 503,
+ );
+ fetchMock.getOnce(
+ {
+ url: "path:/hello",
+ },
+ 503,
+ );
const limitedRetryGET = api._makeMethod("GET", RETRY_THREE_TIMES);
const hello = limitedRetryGET("/hello", { retry: true });
await expect(hello()).rejects.toEqual(
@@ -91,11 +118,28 @@ describe("api", () => {
});
it("GET should succeed if the last attempt succeeds", async () => {
- fetchMock.getOnce({ url: "path:/hello", overwriteRoutes: false }, 503);
- fetchMock.getOnce({ url: "path:/hello", overwriteRoutes: false }, 503);
- fetchMock.getOnce({ url: "path:/hello", overwriteRoutes: false }, 503);
fetchMock.getOnce(
- { url: "path:/hello", overwriteRoutes: false },
+ {
+ url: "path:/hello",
+ },
+ 503,
+ );
+ fetchMock.getOnce(
+ {
+ url: "path:/hello",
+ },
+ 503,
+ );
+ fetchMock.getOnce(
+ {
+ url: "path:/hello",
+ },
+ 503,
+ );
+ fetchMock.getOnce(
+ {
+ url: "path:/hello",
+ },
successResponse,
);
const limitedRetryGET = api._makeMethod("GET", RETRY_THREE_TIMES);
diff --git a/jest.config.js b/jest.config.js
index e8a75ba51c3..6f436dfde27 100644
--- a/jest.config.js
+++ b/jest.config.js
@@ -8,6 +8,7 @@ const esmPackages = [
"d3",
"devlop",
"echarts",
+ "fetch-mock",
"hast.*",
"html-void-elements",
"is-absolute-url",
diff --git a/package.json b/package.json
index e2c0b68ac27..534487ff59a 100644
--- a/package.json
+++ b/package.json
@@ -270,7 +270,7 @@
"eslint-plugin-storybook": "^0.9.0",
"eslint-plugin-testing-library": "^5.11.1",
"eslint-plugin-ttag": "^1.1.0",
- "fetch-mock": "^9.11.0",
+ "fetch-mock": "^12.0.0",
"fork-ts-checker-webpack-plugin": "^9.0.2",
"get-nonce": "^1.0.1",
"glob": "^7.1.1",
diff --git a/yarn.lock b/yarn.lock
index 11d1534d338..d1f79454cee 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -71,50 +71,50 @@
dependencies:
"@babel/highlight" "^7.10.4"
-"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.10.4", "@babel/code-frame@^7.12.13", "@babel/code-frame@^7.16.7", "@babel/code-frame@^7.22.13", "@babel/code-frame@^7.25.9", "@babel/code-frame@^7.26.0", "@babel/code-frame@^7.26.2":
- version "7.26.2"
- resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.26.2.tgz#4b5fab97d33338eff916235055f0ebc21e573a85"
- integrity sha512-RJlIHRueQgwWitWgF8OdFYGZX328Ax5BCemNGlqHfplnRT9ESi8JkFlvaVYbS+UubVY6dpv87Fs2u5M29iNFVQ==
+"@babel/code-frame@^7.0.0", "@babel/code-frame@^7.10.4", "@babel/code-frame@^7.12.13", "@babel/code-frame@^7.16.7", "@babel/code-frame@^7.22.13", "@babel/code-frame@^7.27.1":
+ version "7.27.1"
+ resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.27.1.tgz#200f715e66d52a23b221a9435534a91cc13ad5be"
+ integrity sha512-cjQ7ZlQ0Mv3b47hABuTevyTuYN4i+loJKGeV9flcCgIK37cCXRh+L1bd3iBHlynerhQ7BhCkn2BPbQUL+rGqFg==
dependencies:
- "@babel/helper-validator-identifier" "^7.25.9"
+ "@babel/helper-validator-identifier" "^7.27.1"
js-tokens "^4.0.0"
- picocolors "^1.0.0"
+ picocolors "^1.1.1"
-"@babel/compat-data@^7.20.5", "@babel/compat-data@^7.22.6", "@babel/compat-data@^7.24.8", "@babel/compat-data@^7.26.5":
- version "7.26.5"
- resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.26.5.tgz#df93ac37f4417854130e21d72c66ff3d4b897fc7"
- integrity sha512-XvcZi1KWf88RVbF9wn8MN6tYFloU5qX8KjuF3E1PVBmJ9eypXfs4GRiJwLuTZL0iSnJUKn1BFPa5BPZZJyFzPg==
+"@babel/compat-data@^7.20.5", "@babel/compat-data@^7.22.6", "@babel/compat-data@^7.24.8", "@babel/compat-data@^7.27.2":
+ version "7.28.0"
+ resolved "https://registry.yarnpkg.com/@babel/compat-data/-/compat-data-7.28.0.tgz#9fc6fd58c2a6a15243cd13983224968392070790"
+ integrity sha512-60X7qkglvrap8mn1lh2ebxXdZYtUcpd7gsmy9kLaBJ4i/WdY8PqTSdxyA8qraikqKQK5C1KRBKXqznrVapyNaw==
-"@babel/core@^7.0.0", "@babel/core@^7.11.6", "@babel/core@^7.12.3", "@babel/core@^7.18.9", "@babel/core@^7.21.3", "@babel/core@^7.23.3", "@babel/core@^7.23.9", "@babel/core@^7.26.0", "@babel/core@^7.5.5":
- version "7.26.0"
- resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.26.0.tgz#d78b6023cc8f3114ccf049eb219613f74a747b40"
- integrity sha512-i1SLeK+DzNnQ3LL/CswPCa/E5u4lh1k6IAEphON8F+cXt0t9euTshDru0q7/IqMa1PMPz5RnHuHscF8/ZJsStg==
+"@babel/core@^7.11.6", "@babel/core@^7.12.3", "@babel/core@^7.18.9", "@babel/core@^7.21.3", "@babel/core@^7.23.3", "@babel/core@^7.23.9", "@babel/core@^7.26.0", "@babel/core@^7.5.5":
+ version "7.28.0"
+ resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.28.0.tgz#55dad808d5bf3445a108eefc88ea3fdf034749a4"
+ integrity sha512-UlLAnTPrFdNGoFtbSXwcGFQBtQZJCNjaN6hQNP3UPvuNXT1i82N26KL3dZeIpNalWywr9IuQuncaAfUaS1g6sQ==
dependencies:
"@ampproject/remapping" "^2.2.0"
- "@babel/code-frame" "^7.26.0"
- "@babel/generator" "^7.26.0"
- "@babel/helper-compilation-targets" "^7.25.9"
- "@babel/helper-module-transforms" "^7.26.0"
- "@babel/helpers" "^7.26.0"
- "@babel/parser" "^7.26.0"
- "@babel/template" "^7.25.9"
- "@babel/traverse" "^7.25.9"
- "@babel/types" "^7.26.0"
+ "@babel/code-frame" "^7.27.1"
+ "@babel/generator" "^7.28.0"
+ "@babel/helper-compilation-targets" "^7.27.2"
+ "@babel/helper-module-transforms" "^7.27.3"
+ "@babel/helpers" "^7.27.6"
+ "@babel/parser" "^7.28.0"
+ "@babel/template" "^7.27.2"
+ "@babel/traverse" "^7.28.0"
+ "@babel/types" "^7.28.0"
convert-source-map "^2.0.0"
debug "^4.1.0"
gensync "^1.0.0-beta.2"
json5 "^2.2.3"
semver "^6.3.1"
-"@babel/generator@^7.12.5", "@babel/generator@^7.26.0", "@babel/generator@^7.26.5", "@babel/generator@^7.7.2":
- version "7.26.5"
- resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.26.5.tgz#e44d4ab3176bbcaf78a5725da5f1dc28802a9458"
- integrity sha512-2caSP6fN9I7HOe6nqhtft7V4g7/V/gfDsC3Ag4W7kEzzvRGKqiv0pu0HogPiZ3KaVSoNDhUws6IJjDjpfmYIXw==
+"@babel/generator@^7.12.5", "@babel/generator@^7.28.0", "@babel/generator@^7.7.2":
+ version "7.28.0"
+ resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.28.0.tgz#9cc2f7bd6eb054d77dc66c2664148a0c5118acd2"
+ integrity sha512-lJjzvrbEeWrhB4P3QBsH7tey117PjLZnDbLiQEKjQ/fNJTjuq4HSqgFA+UNSwZT8D7dxxbnuSBMsa1lrWzKlQg==
dependencies:
- "@babel/parser" "^7.26.5"
- "@babel/types" "^7.26.5"
- "@jridgewell/gen-mapping" "^0.3.5"
- "@jridgewell/trace-mapping" "^0.3.25"
+ "@babel/parser" "^7.28.0"
+ "@babel/types" "^7.28.0"
+ "@jridgewell/gen-mapping" "^0.3.12"
+ "@jridgewell/trace-mapping" "^0.3.28"
jsesc "^3.0.2"
"@babel/helper-annotate-as-pure@^7.22.5", "@babel/helper-annotate-as-pure@^7.24.7":
@@ -132,13 +132,13 @@
"@babel/traverse" "^7.24.7"
"@babel/types" "^7.24.7"
-"@babel/helper-compilation-targets@^7.20.7", "@babel/helper-compilation-targets@^7.22.6", "@babel/helper-compilation-targets@^7.24.7", "@babel/helper-compilation-targets@^7.24.8", "@babel/helper-compilation-targets@^7.25.9":
- version "7.26.5"
- resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.26.5.tgz#75d92bb8d8d51301c0d49e52a65c9a7fe94514d8"
- integrity sha512-IXuyn5EkouFJscIDuFF5EsiSolseme1s0CZB+QxVugqJLYmKdxI1VfIBOst0SUu4rnk2Z7kqTwmoO1lp3HIfnA==
+"@babel/helper-compilation-targets@^7.20.7", "@babel/helper-compilation-targets@^7.22.6", "@babel/helper-compilation-targets@^7.24.7", "@babel/helper-compilation-targets@^7.24.8", "@babel/helper-compilation-targets@^7.27.2":
+ version "7.27.2"
+ resolved "https://registry.yarnpkg.com/@babel/helper-compilation-targets/-/helper-compilation-targets-7.27.2.tgz#46a0f6efab808d51d29ce96858dd10ce8732733d"
+ integrity sha512-2+1thGUUWWjLTYTHZWK1n8Yga0ijBz1XAhUXcKy81rd5g6yh7hGqMp45v7cadSbEHc9G3OTv45SyneRN3ps4DQ==
dependencies:
- "@babel/compat-data" "^7.26.5"
- "@babel/helper-validator-option" "^7.25.9"
+ "@babel/compat-data" "^7.27.2"
+ "@babel/helper-validator-option" "^7.27.1"
browserslist "^4.24.0"
lru-cache "^5.1.1"
semver "^6.3.1"
@@ -193,6 +193,11 @@
"@babel/template" "^7.24.7"
"@babel/types" "^7.24.7"
+"@babel/helper-globals@^7.28.0":
+ version "7.28.0"
+ resolved "https://registry.yarnpkg.com/@babel/helper-globals/-/helper-globals-7.28.0.tgz#b9430df2aa4e17bc28665eadeae8aa1d985e6674"
+ integrity sha512-+W6cISkXFa1jXsDEdYA8HeevQT/FULhxzR99pxphltZcVaugps53THCeiWA8SguxxpSp3gKPiuYfSWopkLQ4hw==
+
"@babel/helper-hoist-variables@^7.24.7":
version "7.24.7"
resolved "https://registry.yarnpkg.com/@babel/helper-hoist-variables/-/helper-hoist-variables-7.24.7.tgz#b4ede1cde2fd89436397f30dc9376ee06b0f25ee"
@@ -208,22 +213,22 @@
"@babel/traverse" "^7.24.8"
"@babel/types" "^7.24.8"
-"@babel/helper-module-imports@^7.16.7", "@babel/helper-module-imports@^7.22.15", "@babel/helper-module-imports@^7.24.7", "@babel/helper-module-imports@^7.25.9":
- version "7.25.9"
- resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.25.9.tgz#e7f8d20602ebdbf9ebbea0a0751fb0f2a4141715"
- integrity sha512-tnUA4RsrmflIM6W6RFTLFSXITtl0wKjgpnLgXyowocVPrbYrLUXSBXDgTs8BlbmIzIdlBySRQjINYs2BAkiLtw==
+"@babel/helper-module-imports@^7.16.7", "@babel/helper-module-imports@^7.22.15", "@babel/helper-module-imports@^7.24.7", "@babel/helper-module-imports@^7.27.1":
+ version "7.27.1"
+ resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.27.1.tgz#7ef769a323e2655e126673bb6d2d6913bbead204"
+ integrity sha512-0gSFWUPNXNopqtIPQvlD5WgXYI5GY2kP2cCvoT8kczjbfcfuIljTbcWrulD1CIPIX2gt1wghbDy08yE1p+/r3w==
dependencies:
- "@babel/traverse" "^7.25.9"
- "@babel/types" "^7.25.9"
+ "@babel/traverse" "^7.27.1"
+ "@babel/types" "^7.27.1"
-"@babel/helper-module-transforms@^7.24.7", "@babel/helper-module-transforms@^7.24.8", "@babel/helper-module-transforms@^7.26.0":
- version "7.26.0"
- resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.26.0.tgz#8ce54ec9d592695e58d84cd884b7b5c6a2fdeeae"
- integrity sha512-xO+xu6B5K2czEnQye6BHA7DolFFmS3LB7stHZFaOLb1pAwO1HWLS8fXA+eh0A2yIvltPVmx3eNNDBJA2SLHXFw==
+"@babel/helper-module-transforms@^7.24.7", "@babel/helper-module-transforms@^7.24.8", "@babel/helper-module-transforms@^7.27.3":
+ version "7.27.3"
+ resolved "https://registry.yarnpkg.com/@babel/helper-module-transforms/-/helper-module-transforms-7.27.3.tgz#db0bbcfba5802f9ef7870705a7ef8788508ede02"
+ integrity sha512-dSOvYwvyLsWBeIRyOeHXp5vPj5l1I011r52FM1+r1jCERv+aFXYk4whgQccYEGYxK2H3ZAIA8nuPkQ0HaUo3qg==
dependencies:
- "@babel/helper-module-imports" "^7.25.9"
- "@babel/helper-validator-identifier" "^7.25.9"
- "@babel/traverse" "^7.25.9"
+ "@babel/helper-module-imports" "^7.27.1"
+ "@babel/helper-validator-identifier" "^7.27.1"
+ "@babel/traverse" "^7.27.3"
"@babel/helper-optimise-call-expression@^7.24.7":
version "7.24.7"
@@ -233,9 +238,9 @@
"@babel/types" "^7.24.7"
"@babel/helper-plugin-utils@^7.0.0", "@babel/helper-plugin-utils@^7.10.4", "@babel/helper-plugin-utils@^7.12.13", "@babel/helper-plugin-utils@^7.14.5", "@babel/helper-plugin-utils@^7.18.6", "@babel/helper-plugin-utils@^7.20.2", "@babel/helper-plugin-utils@^7.21.5", "@babel/helper-plugin-utils@^7.22.5", "@babel/helper-plugin-utils@^7.24.7", "@babel/helper-plugin-utils@^7.24.8", "@babel/helper-plugin-utils@^7.8.0", "@babel/helper-plugin-utils@^7.8.3":
- version "7.24.8"
- resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.24.8.tgz#94ee67e8ec0e5d44ea7baeb51e571bd26af07878"
- integrity sha512-FFWx5142D8h2Mgr/iPVGH5G7w6jDn4jUSpZTyDnQO0Yn7Ks2Kuz6Pci8H6MPCoUJegd/UZQ3tAvfLCxQSnWWwg==
+ version "7.27.1"
+ resolved "https://registry.yarnpkg.com/@babel/helper-plugin-utils/-/helper-plugin-utils-7.27.1.tgz#ddb2f876534ff8013e6c2b299bf4d39b3c51d44c"
+ integrity sha512-1gn1Up5YXka3YYAHGKpbideQ5Yjf1tDa9qYcgysz+cNCXukyLl6DjPXhD3VRwSb8c0J9tA4b2+rHEZtc6R0tlw==
"@babel/helper-remap-async-to-generator@^7.24.7":
version "7.24.7"
@@ -278,20 +283,20 @@
dependencies:
"@babel/types" "^7.24.7"
-"@babel/helper-string-parser@^7.25.9":
- version "7.25.9"
- resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.25.9.tgz#1aabb72ee72ed35789b4bbcad3ca2862ce614e8c"
- integrity sha512-4A/SCr/2KLd5jrtOMFzaKjVtAei3+2r/NChoBNoZ3EyP/+GlhoaEGoWOZUmFmoITP7zOJyHIMm+DYRd8o3PvHA==
+"@babel/helper-string-parser@^7.27.1":
+ version "7.27.1"
+ resolved "https://registry.yarnpkg.com/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz#54da796097ab19ce67ed9f88b47bb2ec49367687"
+ integrity sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==
-"@babel/helper-validator-identifier@^7.24.7", "@babel/helper-validator-identifier@^7.25.9":
- version "7.25.9"
- resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.25.9.tgz#24b64e2c3ec7cd3b3c547729b8d16871f22cbdc7"
- integrity sha512-Ed61U6XJc3CVRfkERJWDz4dJwKe7iLmmJsbOGu9wSloNSFttHV0I8g6UAgb7qnK5ly5bGLPd4oXZlxCdANBOWQ==
+"@babel/helper-validator-identifier@^7.24.7", "@babel/helper-validator-identifier@^7.27.1":
+ version "7.27.1"
+ resolved "https://registry.yarnpkg.com/@babel/helper-validator-identifier/-/helper-validator-identifier-7.27.1.tgz#a7054dcc145a967dd4dc8fee845a57c1316c9df8"
+ integrity sha512-D2hP9eA+Sqx1kBZgzxZh0y1trbuU+JoDkiEwqhQ36nodYqJwyEIhPSdMNd7lOm/4io72luTPWH20Yda0xOuUow==
-"@babel/helper-validator-option@^7.22.15", "@babel/helper-validator-option@^7.24.7", "@babel/helper-validator-option@^7.24.8", "@babel/helper-validator-option@^7.25.9":
- version "7.25.9"
- resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.25.9.tgz#86e45bd8a49ab7e03f276577f96179653d41da72"
- integrity sha512-e/zv1co8pp55dNdEcCynfj9X7nyUKUXoUEwfXqaZt0omVOmDe9oOTdKStH4GmAw6zxMFs50ZayuMfHDKlO7Tfw==
+"@babel/helper-validator-option@^7.22.15", "@babel/helper-validator-option@^7.24.7", "@babel/helper-validator-option@^7.24.8", "@babel/helper-validator-option@^7.27.1":
+ version "7.27.1"
+ resolved "https://registry.yarnpkg.com/@babel/helper-validator-option/-/helper-validator-option-7.27.1.tgz#fa52f5b1e7db1ab049445b421c4471303897702f"
+ integrity sha512-YvjJow9FxbhFFKDSuFnVCe2WxXk1zWc22fFePVNEaWJEu8IrZVlda6N0uHwzZrUM1il7NC9Mlp4MaJYbYd9JSg==
"@babel/helper-wrap-function@^7.24.7":
version "7.24.7"
@@ -303,13 +308,13 @@
"@babel/traverse" "^7.24.7"
"@babel/types" "^7.24.7"
-"@babel/helpers@^7.26.0":
- version "7.26.0"
- resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.26.0.tgz#30e621f1eba5aa45fe6f4868d2e9154d884119a4"
- integrity sha512-tbhNuIxNcVb21pInl3ZSjksLCvgdZy9KwJ8brv993QtIVKJBBkYXz4q4ZbAv31GdnC+R90np23L5FbEBlthAEw==
+"@babel/helpers@^7.27.6":
+ version "7.28.2"
+ resolved "https://registry.yarnpkg.com/@babel/helpers/-/helpers-7.28.2.tgz#80f0918fecbfebea9af856c419763230040ee850"
+ integrity sha512-/V9771t+EgXz62aCcyofnQhGM8DQACbRhvzKFsXKC9QM+5MadF8ZmIm0crDMaz3+o0h0zXfJnd4EhbYbxsrcFw==
dependencies:
- "@babel/template" "^7.25.9"
- "@babel/types" "^7.26.0"
+ "@babel/template" "^7.27.2"
+ "@babel/types" "^7.28.2"
"@babel/highlight@^7.10.4":
version "7.24.7"
@@ -333,12 +338,12 @@
regenerator-runtime "^0.14.0"
v8flags "^3.1.1"
-"@babel/parser@^7.1.0", "@babel/parser@^7.14.7", "@babel/parser@^7.16.5", "@babel/parser@^7.20.7", "@babel/parser@^7.23.9", "@babel/parser@^7.24.4", "@babel/parser@^7.24.7", "@babel/parser@^7.25.3", "@babel/parser@^7.25.9", "@babel/parser@^7.26.0", "@babel/parser@^7.26.5", "@babel/parser@^7.7.0":
- version "7.26.5"
- resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.26.5.tgz#6fec9aebddef25ca57a935c86dbb915ae2da3e1f"
- integrity sha512-SRJ4jYmXRqV1/Xc+TIVG84WjHBXKlxO9sHQnA2Pf12QQEAp1LOh6kDzNHXcUnbH1QI0FDoPPVOt+vyUDucxpaw==
+"@babel/parser@^7.1.0", "@babel/parser@^7.14.7", "@babel/parser@^7.16.5", "@babel/parser@^7.20.7", "@babel/parser@^7.23.9", "@babel/parser@^7.24.4", "@babel/parser@^7.24.7", "@babel/parser@^7.25.3", "@babel/parser@^7.27.2", "@babel/parser@^7.28.0", "@babel/parser@^7.7.0":
+ version "7.28.0"
+ resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.28.0.tgz#979829fbab51a29e13901e5a80713dbcb840825e"
+ integrity sha512-jVZGvOxOuNSsuQuLRTh13nU0AogFlw32w/MT+LV6D3sP5WdbW61E77RnkbaO2dUvmPAYrBDJXGn5gGS6tH4j8g==
dependencies:
- "@babel/types" "^7.26.5"
+ "@babel/types" "^7.28.0"
"@babel/plugin-bugfix-firefox-class-in-computed-class-key@^7.24.7":
version "7.24.7"
@@ -1093,14 +1098,14 @@
"@babel/plugin-transform-typescript" "^7.24.7"
"@babel/register@^7.22.15":
- version "7.22.15"
- resolved "https://registry.yarnpkg.com/@babel/register/-/register-7.22.15.tgz#c2c294a361d59f5fa7bcc8b97ef7319c32ecaec7"
- integrity sha512-V3Q3EqoQdn65RCgTLwauZaTfd1ShhwPmbBv+1dkZV/HpCGMKVyn6oFcRlI7RaKqiDQjX2Qd3AuoEguBgdjIKlg==
+ version "7.27.1"
+ resolved "https://registry.yarnpkg.com/@babel/register/-/register-7.27.1.tgz#ea4d701649d788d7cb8a064b7540fd21083147f1"
+ integrity sha512-K13lQpoV54LATKkzBpBAEu1GGSIRzxR9f4IN4V8DCDgiUMo2UDGagEZr3lPeVNJPLkWUi5JE4hCHKneVTwQlYQ==
dependencies:
clone-deep "^4.0.1"
find-cache-dir "^2.0.0"
make-dir "^2.1.0"
- pirates "^4.0.5"
+ pirates "^4.0.6"
source-map-support "^0.5.16"
"@babel/regjsgen@^0.8.0":
@@ -1108,42 +1113,42 @@
resolved "https://registry.yarnpkg.com/@babel/regjsgen/-/regjsgen-0.8.0.tgz#f0ba69b075e1f05fb2825b7fad991e7adbb18310"
integrity sha512-x/rqGMdzj+fWZvCOYForTghzbtqPDZ5gPwaoNGHdgDfF2QA/XZbCBp4Moo5scrkAMPhB7z26XM/AaHuIJdgauA==
-"@babel/runtime@^7.0.0", "@babel/runtime@^7.1.2", "@babel/runtime@^7.12.5", "@babel/runtime@^7.13.10", "@babel/runtime@^7.14.6", "@babel/runtime@^7.15.4", "@babel/runtime@^7.16.3", "@babel/runtime@^7.17.8", "@babel/runtime@^7.18.3", "@babel/runtime@^7.18.6", "@babel/runtime@^7.20.13", "@babel/runtime@^7.21.0", "@babel/runtime@^7.26.7", "@babel/runtime@^7.5.5", "@babel/runtime@^7.7.2", "@babel/runtime@^7.8.4", "@babel/runtime@^7.8.7", "@babel/runtime@^7.9.2":
+"@babel/runtime@^7.1.2", "@babel/runtime@^7.12.5", "@babel/runtime@^7.13.10", "@babel/runtime@^7.14.6", "@babel/runtime@^7.15.4", "@babel/runtime@^7.16.3", "@babel/runtime@^7.17.8", "@babel/runtime@^7.18.3", "@babel/runtime@^7.18.6", "@babel/runtime@^7.20.13", "@babel/runtime@^7.21.0", "@babel/runtime@^7.26.7", "@babel/runtime@^7.5.5", "@babel/runtime@^7.7.2", "@babel/runtime@^7.8.4", "@babel/runtime@^7.8.7", "@babel/runtime@^7.9.2":
version "7.26.10"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.26.10.tgz#a07b4d8fa27af131a633d7b3524db803eb4764c2"
integrity sha512-2WJMeRQPHKSPemqk/awGrAiuFfzBmOIPXKizAsVhWH9YJqLZ0H+HS4c8loHGgW6utJ3E/ejXQUsiGaQy2NZ9Fw==
dependencies:
regenerator-runtime "^0.14.0"
-"@babel/template@^7.10.4", "@babel/template@^7.24.7", "@babel/template@^7.25.9", "@babel/template@^7.3.3":
- version "7.25.9"
- resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.25.9.tgz#ecb62d81a8a6f5dc5fe8abfc3901fc52ddf15016"
- integrity sha512-9DGttpmPvIxBb/2uwpVo3dqJ+O6RooAFOS+lB+xDqoE2PVCE8nfoHMdZLpfCQRLwvohzXISPZcgxt80xLfsuwg==
- dependencies:
- "@babel/code-frame" "^7.25.9"
- "@babel/parser" "^7.25.9"
- "@babel/types" "^7.25.9"
-
-"@babel/traverse@^7.18.9", "@babel/traverse@^7.24.7", "@babel/traverse@^7.24.8", "@babel/traverse@^7.25.9", "@babel/traverse@^7.7.0":
- version "7.26.5"
- resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.26.5.tgz#6d0be3e772ff786456c1a37538208286f6e79021"
- integrity sha512-rkOSPOw+AXbgtwUga3U4u8RpoK9FEFWBNAlTpcnkLFjL5CT+oyHNuUUC/xx6XefEJ16r38r8Bc/lfp6rYuHeJQ==
- dependencies:
- "@babel/code-frame" "^7.26.2"
- "@babel/generator" "^7.26.5"
- "@babel/parser" "^7.26.5"
- "@babel/template" "^7.25.9"
- "@babel/types" "^7.26.5"
+"@babel/template@^7.10.4", "@babel/template@^7.24.7", "@babel/template@^7.27.2", "@babel/template@^7.3.3":
+ version "7.27.2"
+ resolved "https://registry.yarnpkg.com/@babel/template/-/template-7.27.2.tgz#fa78ceed3c4e7b63ebf6cb39e5852fca45f6809d"
+ integrity sha512-LPDZ85aEJyYSd18/DkjNh4/y1ntkE5KwUHWTiqgRxruuZL2F1yuHligVHLvcHY2vMHXttKFpJn6LwfI7cw7ODw==
+ dependencies:
+ "@babel/code-frame" "^7.27.1"
+ "@babel/parser" "^7.27.2"
+ "@babel/types" "^7.27.1"
+
+"@babel/traverse@^7.18.9", "@babel/traverse@^7.24.7", "@babel/traverse@^7.24.8", "@babel/traverse@^7.27.1", "@babel/traverse@^7.27.3", "@babel/traverse@^7.28.0", "@babel/traverse@^7.7.0":
+ version "7.28.0"
+ resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.28.0.tgz#518aa113359b062042379e333db18380b537e34b"
+ integrity sha512-mGe7UK5wWyh0bKRfupsUchrQGqvDbZDbKJw+kcRGSmdHVYrv+ltd0pnpDTVpiTqnaBru9iEvA8pz8W46v0Amwg==
+ dependencies:
+ "@babel/code-frame" "^7.27.1"
+ "@babel/generator" "^7.28.0"
+ "@babel/helper-globals" "^7.28.0"
+ "@babel/parser" "^7.28.0"
+ "@babel/template" "^7.27.2"
+ "@babel/types" "^7.28.0"
debug "^4.3.1"
- globals "^11.1.0"
-"@babel/types@^7.0.0", "@babel/types@^7.12.6", "@babel/types@^7.18.9", "@babel/types@^7.20.7", "@babel/types@^7.21.3", "@babel/types@^7.23.4", "@babel/types@^7.24.7", "@babel/types@^7.24.8", "@babel/types@^7.25.9", "@babel/types@^7.26.0", "@babel/types@^7.26.5", "@babel/types@^7.3.0", "@babel/types@^7.3.3", "@babel/types@^7.4.4", "@babel/types@^7.7.0":
- version "7.26.5"
- resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.26.5.tgz#7a1e1c01d28e26d1fe7f8ec9567b3b92b9d07747"
- integrity sha512-L6mZmwFDK6Cjh1nRCLXpa6no13ZIioJDz7mdkzHv399pThrTa/k0nUlNaenOeh2kWu/iaOQYElEpKPUswUa9Vg==
+"@babel/types@^7.0.0", "@babel/types@^7.12.6", "@babel/types@^7.18.9", "@babel/types@^7.20.7", "@babel/types@^7.21.3", "@babel/types@^7.23.4", "@babel/types@^7.24.7", "@babel/types@^7.24.8", "@babel/types@^7.27.1", "@babel/types@^7.28.0", "@babel/types@^7.28.2", "@babel/types@^7.3.0", "@babel/types@^7.3.3", "@babel/types@^7.4.4", "@babel/types@^7.7.0":
+ version "7.28.2"
+ resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.28.2.tgz#da9db0856a9a88e0a13b019881d7513588cf712b"
+ integrity sha512-ruv7Ae4J5dUYULmeXw1gmb7rYRz57OWCPM57pHojnLq/3Z1CK2lNSLTCVjxVk1F/TZHwOZZrOWi0ur95BbLxNQ==
dependencies:
- "@babel/helper-string-parser" "^7.25.9"
- "@babel/helper-validator-identifier" "^7.25.9"
+ "@babel/helper-string-parser" "^7.27.1"
+ "@babel/helper-validator-identifier" "^7.27.1"
"@bahmutov/cypress-esbuild-preprocessor@^2.2.0":
version "2.2.0"
@@ -2432,13 +2437,12 @@
"@jridgewell/sourcemap-codec" "^1.4.10"
"@jridgewell/trace-mapping" "^0.3.9"
-"@jridgewell/gen-mapping@^0.3.5":
- version "0.3.5"
- resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz#dcce6aff74bdf6dad1a95802b69b04a2fcb1fb36"
- integrity sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg==
+"@jridgewell/gen-mapping@^0.3.12":
+ version "0.3.12"
+ resolved "https://registry.yarnpkg.com/@jridgewell/gen-mapping/-/gen-mapping-0.3.12.tgz#2234ce26c62889f03db3d7fea43c1932ab3e927b"
+ integrity sha512-OuLGC46TjB5BbN1dH8JULVVZY4WTdkF7tV9Ys6wLL1rubZnCMstOhNHueU5bLCrnRuDhKPDM4g6sw4Bel5Gzqg==
dependencies:
- "@jridgewell/set-array" "^1.2.1"
- "@jridgewell/sourcemap-codec" "^1.4.10"
+ "@jridgewell/sourcemap-codec" "^1.5.0"
"@jridgewell/trace-mapping" "^0.3.24"
"@jridgewell/[email protected]":
@@ -2461,11 +2465,6 @@
resolved "https://registry.yarnpkg.com/@jridgewell/set-array/-/set-array-1.1.1.tgz#36a6acc93987adcf0ba50c66908bd0b70de8afea"
integrity sha512-Ct5MqZkLGEXTVmQYbGtx9SVqD2fqwvdubdps5D3djjAkgkKwT918VNOz65pEHFaYTeWcukmJmH5SwsA9Tn2ObQ==
-"@jridgewell/set-array@^1.2.1":
- version "1.2.1"
- resolved "https://registry.yarnpkg.com/@jridgewell/set-array/-/set-array-1.2.1.tgz#558fb6472ed16a4c850b889530e6b36438c49280"
- integrity sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==
-
"@jridgewell/source-map@^0.3.3":
version "0.3.5"
resolved "https://registry.yarnpkg.com/@jridgewell/source-map/-/source-map-0.3.5.tgz#a3bb4d5c6825aab0d281268f47f6ad5853431e91"
@@ -2510,6 +2509,14 @@
"@jridgewell/resolve-uri" "^3.1.0"
"@jridgewell/sourcemap-codec" "^1.4.14"
+"@jridgewell/trace-mapping@^0.3.28":
+ version "0.3.29"
+ resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.29.tgz#a58d31eaadaf92c6695680b2e1d464a9b8fbf7fc"
+ integrity sha512-uw6guiW/gcAGPDhLmd77/6lW8QLeiV5RUTsAX46Db6oLhGaVj4lhnPwb184s1bkc8kdVg/+h988dro8GRDpmYQ==
+ dependencies:
+ "@jridgewell/resolve-uri" "^3.1.0"
+ "@jridgewell/sourcemap-codec" "^1.4.14"
+
"@jridgewell/trace-mapping@^0.3.9":
version "0.3.13"
resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.13.tgz#dcfe3e95f224c8fe97a87a5235defec999aa92ea"
@@ -4578,6 +4585,11 @@
resolved "https://registry.yarnpkg.com/@types/geojson/-/geojson-7946.0.16.tgz#8ebe53d69efada7044454e3305c19017d97ced2a"
integrity sha512-6C8nqWur3j98U6+lXDfTUWIfgvZU+EumvpHKcYjujKH7woYyLj2sUmff0tRhrqM7BohUw7Pz3ZB1jj2gW9Fvmg==
+"@types/glob-to-regexp@^0.4.4":
+ version "0.4.4"
+ resolved "https://registry.yarnpkg.com/@types/glob-to-regexp/-/glob-to-regexp-0.4.4.tgz#409e71290253203185b1ea8a3d6ea406a4bdc902"
+ integrity sha512-nDKoaKJYbnn1MZxUY0cA1bPmmgZbg0cTq7Rh13d0KWYNOiKbqoR+2d89SnRPszGh7ROzSwZ/GOjZ4jPbmmZ6Eg==
+
"@types/glob@^7.1.4":
version "7.1.4"
resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.1.4.tgz#ea59e21d2ee5c517914cb4bc8e4153b99e566672"
@@ -8121,11 +8133,6 @@ core-js-pure@^3.23.3:
resolved "https://registry.yarnpkg.com/core-js-pure/-/core-js-pure-3.26.1.tgz#653f4d7130c427820dcecd3168b594e8bb095a33"
integrity sha512-VVXcDpp/xJ21KdULRq/lXdLzQAtX7+37LzpyfFM973il0tWSsDEoyzG38G14AjTpK9VTfiNM9jnFauq/CpaWGQ==
-core-js@^3.0.0:
- version "3.28.0"
- resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.28.0.tgz#ed8b9e99c273879fdfff0edfc77ee709a5800e4a"
- integrity sha512-GiZn9D4Z/rSYvTeg1ljAIsEqFm0LaN9gVtwDCrKL80zHtS31p9BAjmTxVqTQDMpwlMolJZOFntUG2uwyj7DAqw==
-
core-js@^3.30.2:
version "3.33.2"
resolved "https://registry.yarnpkg.com/core-js/-/core-js-3.33.2.tgz#312bbf6996a3a517c04c99b9909cdd27138d1ceb"
@@ -10783,21 +10790,15 @@ fdir@^6.4.2:
resolved "https://registry.yarnpkg.com/fdir/-/fdir-6.4.2.tgz#ddaa7ce1831b161bc3657bb99cb36e1622702689"
integrity sha512-KnhMXsKSPZlAhp7+IjUkRZKPb4fUyccpDrdFXbi4QL1qkmFh9kVY09Yox+n4MaOb3lHZ1Tv829C3oaaXoMYPDQ==
-fetch-mock@^9.11.0:
- version "9.11.0"
- resolved "https://registry.yarnpkg.com/fetch-mock/-/fetch-mock-9.11.0.tgz#371c6fb7d45584d2ae4a18ee6824e7ad4b637a3f"
- integrity sha512-PG1XUv+x7iag5p/iNHD4/jdpxL9FtVSqRMUQhPab4hVDt80T1MH5ehzVrL2IdXO9Q2iBggArFvPqjUbHFuI58Q==
+fetch-mock@^12.0.0:
+ version "12.5.3"
+ resolved "https://registry.yarnpkg.com/fetch-mock/-/fetch-mock-12.5.3.tgz#dd8a652973e76278d9d097923ef75e3caf0de33d"
+ integrity sha512-SiqPv1IXvDjNjLWCvfFUltba3VeiYucxjyynoVW8Ft07GLFQRitlzjYZI/f5wZpeQFRIVZ84fmMgJfjwb/dAEA==
dependencies:
- "@babel/core" "^7.0.0"
- "@babel/runtime" "^7.0.0"
- core-js "^3.0.0"
- debug "^4.1.1"
- glob-to-regexp "^0.4.0"
- is-subset "^0.1.1"
- lodash.isequal "^4.5.0"
- path-to-regexp "^2.2.1"
- querystring "^0.2.0"
- whatwg-url "^6.5.0"
+ "@types/glob-to-regexp" "^0.4.4"
+ dequal "^2.0.3"
+ glob-to-regexp "^0.4.1"
+ regexparam "^3.0.0"
fflate@^0.8.1:
version "0.8.2"
@@ -11460,7 +11461,7 @@ glob-parent@^5.1.2, glob-parent@~5.1.2:
dependencies:
is-glob "^4.0.1"
-glob-to-regexp@^0.4.0, glob-to-regexp@^0.4.1:
+glob-to-regexp@^0.4.1:
version "0.4.1"
resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz#c75297087c851b9a578bd217dd59a92f59fe546e"
integrity sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==
@@ -12969,11 +12970,6 @@ is-string@^1.0.7:
dependencies:
has-tostringtag "^1.0.0"
-is-subset@^0.1.1:
- version "0.1.1"
- resolved "https://registry.yarnpkg.com/is-subset/-/is-subset-0.1.1.tgz#8a59117d932de1de00f245fcdd39ce43f1e939a6"
- integrity sha512-6Ybun0IkarhmEqxXCNw/C0bna6Zb/TkfUX9UbwJtK6ObwAVCxmAP308WWTHviM/zAqXk05cdhYsUsZeGQh99iw==
-
is-symbol@^1.0.2, is-symbol@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.3.tgz#38e1014b9e6329be0de9d24a414fd7441ec61937"
@@ -14237,11 +14233,6 @@ lodash.isempty@^4.4.0:
resolved "https://registry.yarnpkg.com/lodash.isempty/-/lodash.isempty-4.4.0.tgz#6f86cbedd8be4ec987be9aaf33c9684db1b31e7e"
integrity sha512-oKMuF3xEeqDltrGMfDxAPGIVMSSRv8tbRSODbrs4KGsRRLEhrW8N8Rd4DRgB2+621hY8A8XwwrTVhXWpxFvMzg==
-lodash.isequal@^4.5.0:
- version "4.5.0"
- resolved "https://registry.yarnpkg.com/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0"
- integrity sha1-QVxEePK8wwEgwizhDtMib30+GOA=
-
lodash.isfunction@^3.0.9:
version "3.0.9"
resolved "https://registry.yarnpkg.com/lodash.isfunction/-/lodash.isfunction-3.0.9.tgz#06de25df4db327ac931981d1bdb067e5af68d051"
@@ -14277,11 +14268,6 @@ lodash.orderby@^4.6.0:
resolved "https://registry.yarnpkg.com/lodash.orderby/-/lodash.orderby-4.6.0.tgz#e697f04ce5d78522f54d9338b32b81a3393e4eb3"
integrity sha512-T0rZxKmghOOf5YPnn8EY5iLYeWCpZq8G41FfqoVHH5QDTAFaghJRmAdLiadEDq+ztgM2q5PjA+Z1fOwGrLgmtg==
-lodash.sortby@^4.7.0:
- version "4.7.0"
- resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"
- integrity sha512-HDWXG8isMntAyRF5vZ7xKuEvOhT4AhlRt/3czTSjvGUxjYCBVRQY48ViDHyfYz9VIoBkW4TMGQNapx+l3RUwdA==
-
lodash.truncate@^4.4.2:
version "4.4.2"
resolved "https://registry.yarnpkg.com/lodash.truncate/-/lodash.truncate-4.4.2.tgz#5a350da0b1113b837ecfffd5812cbe58d6eae193"
@@ -16343,7 +16329,7 @@ [email protected]:
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.12.tgz#d5e1a12e478a976d432ef3c58d534b9923164bb7"
integrity sha512-RA1GjUVMnvYFxuqovrEqZoxxW5NUZqbwKtYz/Tt7nXerk0LbLblQmrsgdeOxV5SFHf0UDggjS/bSeOZwt1pmEQ==
[email protected], path-to-regexp@^2.2.1:
version "3.3.0"
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-3.3.0.tgz#f7f31d32e8518c2660862b644414b6d5c63a611b"
integrity sha512-qyCH421YQPS2WFDxDjftfc1ZR5WKQzVzqsp4n9M2kQhVOo/ByahFoUNJfl58kOcEGfQ//7weFTDhm+ss8Ecxgw==
@@ -16525,10 +16511,10 @@ pirates@^4.0.4:
resolved "https://registry.yarnpkg.com/pirates/-/pirates-4.0.5.tgz#feec352ea5c3268fb23a37c702ab1699f35a5f3b"
integrity sha512-8V9+HQPupnaXMA23c5hvl69zXvTwTzyAYasnkb0Tts4XvO4CliqONMOnvlq26rkhLC3nWDFBJf73LU1e1VZLaQ==
-pirates@^4.0.5:
- version "4.0.6"
- resolved "https://registry.yarnpkg.com/pirates/-/pirates-4.0.6.tgz#3018ae32ecfcff6c29ba2267cbf21166ac1f36b9"
- integrity sha512-saLsH7WeYYPiD25LDuLRRY/i+6HaPYr6G1OUlN39otzkSTxKnubR9RTxS3/Kk50s1g2JTgFwWQDQyplC5/SHZg==
+pirates@^4.0.6:
+ version "4.0.7"
+ resolved "https://registry.yarnpkg.com/pirates/-/pirates-4.0.7.tgz#643b4a18c4257c8a65104b73f3049ce9a0a15e22"
+ integrity sha512-TfySrs/5nm8fQJDcBDuUng3VOUKsd7S+zqvbOTiGXHfxX4wK31ard+hoNuvkicM/2YFzlpDgABOevKSsB4G/FA==
pixelmatch@^5.2.0, pixelmatch@^5.2.1:
version "5.3.0"
@@ -17463,11 +17449,6 @@ [email protected]:
resolved "https://registry.yarnpkg.com/querystring/-/querystring-0.2.0.tgz#b209849203bb25df820da756e747005878521620"
integrity sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=
-querystring@^0.2.0:
- version "0.2.1"
- resolved "https://registry.yarnpkg.com/querystring/-/querystring-0.2.1.tgz#40d77615bb09d16902a85c3e38aa8b5ed761c2dd"
- integrity sha512-wkvS7mL/JMugcup3/rMitHmd9ecIGd2lhFhK9N3UUQ450h66d1r3Y9nvXzQAW1Lq+wyx61k/1pfKS5KuKiyEbg==
-
querystringify@^2.1.1:
version "2.2.0"
resolved "https://registry.yarnpkg.com/querystringify/-/querystringify-2.2.0.tgz#3345941b4153cb9d082d8eee4cda2016a9aef7f6"
@@ -18289,6 +18270,11 @@ regexp.prototype.flags@^1.5.1, regexp.prototype.flags@^1.5.2:
es-errors "^1.3.0"
set-function-name "^2.0.1"
+regexparam@^3.0.0:
+ version "3.0.0"
+ resolved "https://registry.yarnpkg.com/regexparam/-/regexparam-3.0.0.tgz#1673e09d41cb7fd41eaafd4040a6aa90daa0a21a"
+ integrity sha512-RSYAtP31mvYLkAHrOlh25pCNQ5hWnT106VukGaaFfuJrZFkGRX5GhUAdPqpSDXxOhA2c4akmRuplv1mRqnBn6Q==
+
regexpp@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/regexpp/-/regexpp-3.1.0.tgz#206d0ad0a5648cffbdb8ae46438f3dc51c9f78e2"
@@ -20490,13 +20476,6 @@ tough-cookie@^5.0.0:
dependencies:
tldts "^6.1.32"
-tr46@^1.0.1:
- version "1.0.1"
- resolved "https://registry.yarnpkg.com/tr46/-/tr46-1.0.1.tgz#a8b13fd6bfd2489519674ccde55ba3693b706d09"
- integrity sha512-dTpowEjclQ7Kgx5SdBkqRzVhERQXov8/l9Ft9dVM9fmg0W0KQSVaXX9T4i6twCPNtYiZM53lpSSUAwJbFPOHxA==
- dependencies:
- punycode "^2.1.0"
-
tr46@^4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/tr46/-/tr46-4.1.1.tgz#281a758dcc82aeb4fe38c7dfe4d11a395aac8469"
@@ -21551,11 +21530,6 @@ webidl-conversions@^3.0.0:
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871"
integrity sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=
-webidl-conversions@^4.0.2:
- version "4.0.2"
- resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-4.0.2.tgz#a855980b1f0b6b359ba1d5d9fb39ae941faa63ad"
- integrity sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg==
-
webidl-conversions@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-7.0.0.tgz#256b4e1882be7debbf01d05f0aa2039778ea080a"
@@ -21802,15 +21776,6 @@ whatwg-url@^5.0.0:
tr46 "~0.0.3"
webidl-conversions "^3.0.0"
-whatwg-url@^6.5.0:
- version "6.5.0"
- resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-6.5.0.tgz#f2df02bff176fd65070df74ad5ccbb5a199965a8"
- integrity sha512-rhRZRqx/TLJQWUpQ6bmrt2UV4f0HCQ463yQuONJqC6fO2VoEb1pTYddbe59SkYq87aoM5A3bdhMZiUiVws+fzQ==
- dependencies:
- lodash.sortby "^4.7.0"
- tr46 "^1.0.1"
- webidl-conversions "^4.0.2"
-
which-boxed-primitive@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz#13757bc89b209b049fe5d86430e21cf40a89a8e6"