From 4e445b7b8da7a5b4ccf529d73f298ee1c193b028 Mon Sep 17 00:00:00 2001
From: Anton Kulyk <kuliks.anton@gmail.com>
Date: Fri, 29 Oct 2021 16:27:31 +0300
Subject: [PATCH] Add helper to run jest tests in enterprise environment
 (#18529)

* Move UI mocks into separate file

* Mock ace and Google Analytics by default

* Add helper to run a test in EE environment

* Add test ID to CacheTTLField

* Migrate tests to new EE helper
---
 .../CacheTTLField/CacheTTLField.jsx           |  3 +-
 .../containers/DatabaseEditApp.unit.spec.js   | 20 +++++------
 .../CollectionsList.unit.spec.js              | 21 ++----------
 .../CreateDashboardModal.unit.spec.js         | 25 ++++++++------
 .../DashboardDetailsModal.unit.spec.js        | 28 +++++++---------
 .../view/EditQuestionInfoModal.unit.spec.js   | 33 ++++++++++++-------
 .../components/SearchResult.unit.spec.js      | 20 ++---------
 frontend/test/__support__/enterprise.js       |  7 ++++
 frontend/test/__support__/mocks.js            | 24 --------------
 frontend/test/__support__/ui-mocks.js         | 21 ++++++++++++
 frontend/test/jest-setup.js                   |  1 +
 .../containers/SaveQuestionModal.unit.spec.js | 25 ++++++++------
 .../getCollectionIcon.unit.spec.js            | 22 ++-----------
 .../filters/FilterPopover.unit.spec.js        |  2 +-
 .../LineAreaBarRenderer-bar.unit.spec.js      |  2 +-
 .../LineAreaBarRenderer-scatter.unit.spec.js  |  2 +-
 ...LineAreaBarRenderer-waterfall.unit.spec.js |  2 +-
 .../LineAreaBarRenderer.tz.unit.spec.js       |  2 +-
 .../LineAreaBarRenderer.unit.spec.js          |  2 +-
 .../components/RowRenderer.unit.spec.js       |  2 +-
 20 files changed, 118 insertions(+), 146 deletions(-)
 create mode 100644 frontend/test/__support__/enterprise.js
 create mode 100644 frontend/test/__support__/ui-mocks.js

diff --git a/enterprise/frontend/src/metabase-enterprise/caching/components/CacheTTLField/CacheTTLField.jsx b/enterprise/frontend/src/metabase-enterprise/caching/components/CacheTTLField/CacheTTLField.jsx
index e9ceac8762c..1c00d2a11c9 100644
--- a/enterprise/frontend/src/metabase-enterprise/caching/components/CacheTTLField/CacheTTLField.jsx
+++ b/enterprise/frontend/src/metabase-enterprise/caching/components/CacheTTLField/CacheTTLField.jsx
@@ -20,7 +20,7 @@ const propTypes = {
 export function CacheTTLField({ field, message, ...props }) {
   const hasError = !!field.error;
   return (
-    <CacheTTLFieldContainer {...props}>
+    <CacheTTLFieldContainer {...props} data-testid="cache-ttl-field">
       {message && (
         <FieldText margin="right" hasError={hasError}>
           {message}
@@ -32,6 +32,7 @@ export function CacheTTLField({ field, message, ...props }) {
         value={field.value}
         placeholder="24"
         hasError={hasError}
+        data-testid="cache-ttl-input"
       />
       <FieldText margin="left" hasError={hasError}>{t`hours`}</FieldText>
     </CacheTTLFieldContainer>
diff --git a/frontend/src/metabase/admin/databases/containers/DatabaseEditApp.unit.spec.js b/frontend/src/metabase/admin/databases/containers/DatabaseEditApp.unit.spec.js
index 545051340be..34e8f6f3c0b 100644
--- a/frontend/src/metabase/admin/databases/containers/DatabaseEditApp.unit.spec.js
+++ b/frontend/src/metabase/admin/databases/containers/DatabaseEditApp.unit.spec.js
@@ -6,7 +6,7 @@ import {
 } from "__support__/ui";
 import admin from "metabase/admin/admin";
 import MetabaseSettings from "metabase/lib/settings";
-import { PLUGIN_CACHING } from "metabase/plugins";
+import { setupEnterpriseTest } from "__support__/enterprise";
 import DatabaseEditApp from "./DatabaseEditApp";
 
 const ENGINES_MOCK = {
@@ -27,6 +27,7 @@ const ENGINES_MOCK = {
 };
 
 function mockSettings({ cachingEnabled = false }) {
+  const original = MetabaseSettings.get.bind(MetabaseSettings);
   const spy = jest.spyOn(MetabaseSettings, "get");
   spy.mockImplementation(key => {
     if (key === "engines") {
@@ -38,6 +39,13 @@ function mockSettings({ cachingEnabled = false }) {
     if (key === "site-url") {
       return "http://localhost:3333";
     }
+    if (key === "application-name") {
+      return "Metabase Test";
+    }
+    if (key === "is-hosted?") {
+      return false;
+    }
+    return original(key);
   });
 }
 
@@ -64,15 +72,7 @@ describe("DatabaseEditApp", () => {
 
     describe("EE", () => {
       beforeEach(() => {
-        PLUGIN_CACHING.databaseCacheTTLFormField = {
-          name: "cache_ttl",
-          type: "integer",
-          title: "Default result cache duration",
-        };
-      });
-
-      afterEach(() => {
-        PLUGIN_CACHING.databaseCacheTTLFormField = null;
+        setupEnterpriseTest();
       });
 
       it("is visible", async () => {
diff --git a/frontend/src/metabase/collections/containers/CollectionSidebar/Collections/CollectionsList/CollectionsList.unit.spec.js b/frontend/src/metabase/collections/containers/CollectionSidebar/Collections/CollectionsList/CollectionsList.unit.spec.js
index a490cee7f04..9b7221b9e78 100644
--- a/frontend/src/metabase/collections/containers/CollectionSidebar/Collections/CollectionsList/CollectionsList.unit.spec.js
+++ b/frontend/src/metabase/collections/containers/CollectionSidebar/Collections/CollectionsList/CollectionsList.unit.spec.js
@@ -1,7 +1,7 @@
 import React from "react";
 import { renderWithProviders, screen } from "__support__/ui";
 import userEvent from "@testing-library/user-event";
-import { PLUGIN_COLLECTIONS } from "metabase/plugins";
+import { setupEnterpriseTest } from "__support__/enterprise";
 import CollectionsList from "./CollectionsList";
 
 describe("CollectionsList", () => {
@@ -90,25 +90,8 @@ describe("CollectionsList", () => {
     });
 
     describe("EE", () => {
-      const ORIGINAL_COLLECTIONS_PLUGIN = {
-        ...PLUGIN_COLLECTIONS,
-      };
-
       beforeAll(() => {
-        PLUGIN_COLLECTIONS.isRegularCollection = c => !c.authority_level;
-        PLUGIN_COLLECTIONS.AUTHORITY_LEVEL = {
-          ...ORIGINAL_COLLECTIONS_PLUGIN,
-          official: {
-            icon: "badge",
-          },
-        };
-      });
-
-      afterAll(() => {
-        PLUGIN_COLLECTIONS.isRegularCollection =
-          ORIGINAL_COLLECTIONS_PLUGIN.isRegularCollection;
-        PLUGIN_COLLECTIONS.AUTHORITY_LEVEL =
-          ORIGINAL_COLLECTIONS_PLUGIN.AUTHORITY_LEVEL;
+        setupEnterpriseTest();
       });
 
       it("displays folder icon for regular collections", () => {
diff --git a/frontend/src/metabase/components/CreateDashboardModal.unit.spec.js b/frontend/src/metabase/components/CreateDashboardModal.unit.spec.js
index 13f56e73bad..fc821c252e1 100644
--- a/frontend/src/metabase/components/CreateDashboardModal.unit.spec.js
+++ b/frontend/src/metabase/components/CreateDashboardModal.unit.spec.js
@@ -2,17 +2,29 @@ import React from "react";
 import { fireEvent, renderWithProviders, screen } from "__support__/ui";
 import userEvent from "@testing-library/user-event";
 import xhrMock from "xhr-mock";
+import { setupEnterpriseTest } from "__support__/enterprise";
 import MetabaseSettings from "metabase/lib/settings";
-import { PLUGIN_CACHING } from "metabase/plugins";
 import CreateDashboardModal from "./CreateDashboardModal";
 
 function mockCachingEnabled(enabled = true) {
-  const original = MetabaseSettings.get;
+  const original = MetabaseSettings.get.bind(MetabaseSettings);
   const spy = jest.spyOn(MetabaseSettings, "get");
   spy.mockImplementation(key => {
     if (key === "enable-query-caching") {
       return enabled;
     }
+    if (key === "application-name") {
+      return "Metabase Test";
+    }
+    if (key === "version") {
+      return { tag: "" };
+    }
+    if (key === "is-hosted?") {
+      return false;
+    }
+    if (key === "enable-enhancements?") {
+      return false;
+    }
     return original(key);
   });
 }
@@ -141,14 +153,7 @@ describe("CreateDashboardModal", () => {
 
     describe("EE", () => {
       beforeEach(() => {
-        PLUGIN_CACHING.cacheTTLFormField = {
-          name: "cache_ttl",
-          type: "integer",
-        };
-      });
-
-      afterEach(() => {
-        PLUGIN_CACHING.cacheTTLFormField = null;
+        setupEnterpriseTest();
       });
 
       it("is not shown", () => {
diff --git a/frontend/src/metabase/dashboard/components/DashboardDetailsModal.unit.spec.js b/frontend/src/metabase/dashboard/components/DashboardDetailsModal.unit.spec.js
index 65438b7ed4f..f57f7eed303 100644
--- a/frontend/src/metabase/dashboard/components/DashboardDetailsModal.unit.spec.js
+++ b/frontend/src/metabase/dashboard/components/DashboardDetailsModal.unit.spec.js
@@ -3,9 +3,8 @@ import _ from "underscore";
 import { fireEvent, renderWithProviders, screen } from "__support__/ui";
 import userEvent from "@testing-library/user-event";
 import xhrMock from "xhr-mock";
+import { setupEnterpriseTest } from "__support__/enterprise";
 import MetabaseSettings from "metabase/lib/settings";
-import { PLUGIN_CACHING, PLUGIN_FORM_WIDGETS } from "metabase/plugins";
-import NumericFormField from "metabase/components/form/widgets/FormNumericInputWidget";
 import DashboardDetailsModal from "./DashboardDetailsModal";
 
 const DASHBOARD = {
@@ -19,12 +18,15 @@ const DASHBOARD = {
 };
 
 function mockCachingEnabled(enabled = true) {
-  const original = MetabaseSettings.get;
+  const original = MetabaseSettings.get.bind(MetabaseSettings);
   const spy = jest.spyOn(MetabaseSettings, "get");
   spy.mockImplementation(key => {
     if (key === "enable-query-caching") {
       return enabled;
     }
+    if (key === "application-name") {
+      return "Test Metabase";
+    }
     return original(key);
   });
 }
@@ -93,7 +95,7 @@ function fillForm({ name, description, cache_ttl } = {}) {
     nextDashboardState.description = description;
   }
   if (cache_ttl) {
-    const input = screen.getByLabelText("Cache TTL");
+    const input = screen.getByTestId("cache-ttl-input");
     userEvent.clear(input);
     userEvent.type(input, String(cache_ttl));
     input.blur();
@@ -182,16 +184,7 @@ describe("DashboardDetailsModal", () => {
 
     describe("EE", () => {
       beforeEach(() => {
-        PLUGIN_CACHING.cacheTTLFormField = {
-          name: "cache_ttl",
-          title: "Cache TTL",
-        };
-        PLUGIN_FORM_WIDGETS.dashboardCacheTTL = NumericFormField;
-      });
-
-      afterEach(() => {
-        PLUGIN_CACHING.cacheTTLFormField = null;
-        PLUGIN_FORM_WIDGETS.dashboardCacheTTL = null;
+        setupEnterpriseTest();
       });
 
       describe("caching enabled", () => {
@@ -202,7 +195,7 @@ describe("DashboardDetailsModal", () => {
         it("is shown", () => {
           setup();
           fireEvent.click(screen.queryByText("More options"));
-          expect(screen.queryByLabelText("Cache TTL")).toHaveValue("0");
+          expect(screen.queryByTestId("cache-ttl-input")).toHaveValue("0");
         });
 
         it("can be changed", done => {
@@ -220,8 +213,11 @@ describe("DashboardDetailsModal", () => {
       });
 
       describe("caching disabled", () => {
-        it("is not shown if caching is disabled", () => {
+        beforeEach(() => {
           mockCachingEnabled(false);
+        });
+
+        it("is not shown if caching is disabled", () => {
           setup();
           expect(screen.queryByText("More options")).not.toBeInTheDocument();
           expect(
diff --git a/frontend/src/metabase/query_builder/components/view/EditQuestionInfoModal.unit.spec.js b/frontend/src/metabase/query_builder/components/view/EditQuestionInfoModal.unit.spec.js
index d517edf9613..1f214829d0d 100644
--- a/frontend/src/metabase/query_builder/components/view/EditQuestionInfoModal.unit.spec.js
+++ b/frontend/src/metabase/query_builder/components/view/EditQuestionInfoModal.unit.spec.js
@@ -2,8 +2,7 @@ import React from "react";
 import { fireEvent, renderWithProviders, screen } from "__support__/ui";
 import userEvent from "@testing-library/user-event";
 import xhrMock from "xhr-mock";
-import { PLUGIN_CACHING, PLUGIN_FORM_WIDGETS } from "metabase/plugins";
-import NumericFormField from "metabase/components/form/widgets/FormNumericInputWidget";
+import { setupEnterpriseTest } from "__support__/enterprise";
 import MetabaseSettings from "metabase/lib/settings";
 import EditQuestionInfoModal from "./EditQuestionInfoModal";
 
@@ -17,11 +16,28 @@ const QUESTION = {
 };
 
 function mockCachingSettings({ enabled = true } = {}) {
+  const original = MetabaseSettings.get.bind(MetabaseSettings);
   const spy = jest.spyOn(MetabaseSettings, "get");
   spy.mockImplementation(key => {
     if (key === "enable-query-caching") {
       return enabled;
     }
+    if (key === "query-caching-min-ttl") {
+      return 10000;
+    }
+    if (key === "application-name") {
+      return "Metabase Test";
+    }
+    if (key === "version") {
+      return { tag: "" };
+    }
+    if (key === "is-hosted?") {
+      return false;
+    }
+    if (key === "enable-enhancements?") {
+      return false;
+    }
+    return original(key);
   });
 }
 
@@ -35,6 +51,9 @@ function setup({ cachingEnabled = true } = {}) {
 
   const question = {
     card: () => QUESTION,
+    database: () => ({
+      cache_ttl: null,
+    }),
   };
 
   renderWithProviders(
@@ -154,15 +173,7 @@ describe("EditQuestionInfoModal", () => {
 
     describe("EE", () => {
       beforeEach(() => {
-        PLUGIN_CACHING.cacheTTLFormField = {
-          name: "cache_ttl",
-        };
-        PLUGIN_FORM_WIDGETS.questionCacheTTL = NumericFormField;
-      });
-
-      afterEach(() => {
-        PLUGIN_CACHING.cacheTTLFormField = null;
-        PLUGIN_FORM_WIDGETS.questionCacheTTL = null;
+        setupEnterpriseTest();
       });
 
       describe("caching enabled", () => {
diff --git a/frontend/src/metabase/search/components/SearchResult.unit.spec.js b/frontend/src/metabase/search/components/SearchResult.unit.spec.js
index 4ee2148b19f..9ae1cd839da 100644
--- a/frontend/src/metabase/search/components/SearchResult.unit.spec.js
+++ b/frontend/src/metabase/search/components/SearchResult.unit.spec.js
@@ -1,7 +1,7 @@
 /* eslint-disable react/prop-types */
 import React from "react";
 import { render, screen } from "@testing-library/react";
-import { PLUGIN_COLLECTIONS } from "metabase/plugins";
+import { setupEnterpriseTest } from "__support__/enterprise";
 import SearchResult from "./SearchResult";
 
 function collection({
@@ -56,24 +56,8 @@ describe("SearchResult > Collections", () => {
       getIcon: () => ({ name: "badge" }),
     });
 
-    const ORIGINAL_COLLECTIONS_PLUGIN = { ...PLUGIN_COLLECTIONS };
-
     beforeAll(() => {
-      PLUGIN_COLLECTIONS.isRegularCollection = c => !c.authority_level;
-      PLUGIN_COLLECTIONS.AUTHORITY_LEVEL = {
-        ...ORIGINAL_COLLECTIONS_PLUGIN.AUTHORITY_LEVEL,
-        official: {
-          name: "Official",
-          icon: "badge",
-        },
-      };
-    });
-
-    afterAll(() => {
-      PLUGIN_COLLECTIONS.isRegularCollection =
-        ORIGINAL_COLLECTIONS_PLUGIN.isRegularCollection;
-      PLUGIN_COLLECTIONS.AUTHORITY_LEVEL =
-        ORIGINAL_COLLECTIONS_PLUGIN.AUTHORITY_LEVEL;
+      setupEnterpriseTest();
     });
 
     it("renders regular collection correctly", () => {
diff --git a/frontend/test/__support__/enterprise.js b/frontend/test/__support__/enterprise.js
new file mode 100644
index 00000000000..e28e6514798
--- /dev/null
+++ b/frontend/test/__support__/enterprise.js
@@ -0,0 +1,7 @@
+export function setupEnterpriseTest() {
+  jest.mock("metabase-enterprise/settings", () => ({
+    hasPremiumFeature: jest.fn().mockReturnValue(true),
+  }));
+
+  require("metabase-enterprise/plugins");
+}
diff --git a/frontend/test/__support__/mocks.js b/frontend/test/__support__/mocks.js
index f85aa87319a..ca452750df1 100644
--- a/frontend/test/__support__/mocks.js
+++ b/frontend/test/__support__/mocks.js
@@ -1,5 +1,3 @@
-/* eslint-disable no-import-assign*/
-
 global.ga = () => {};
 global.snowplow = () => {};
 global.ace.define = () => {};
@@ -10,10 +8,8 @@ global.window.matchMedia = () => ({
   removeListener: () => {},
 });
 
-// Disable analytics
 jest.mock("metabase/lib/analytics");
 
-// Suppress ace import errors
 jest.mock("ace/ace", () => {}, { virtual: true });
 jest.mock("ace/mode-plain_text", () => {}, { virtual: true });
 jest.mock("ace/mode-javascript", () => {}, { virtual: true });
@@ -34,23 +30,3 @@ jest.mock("ace/snippets/sqlserver", () => {}, { virtual: true });
 jest.mock("ace/snippets/json", () => {}, { virtual: true });
 jest.mock("ace/snippets/json", () => {}, { virtual: true });
 jest.mock("ace/ext-language_tools", () => {}, { virtual: true });
-
-jest.mock("metabase/components/Popover");
-
-// Replace addEventListener with a test implementation which collects all event listeners to `eventListeners` map
-export const eventListeners = {};
-const testAddEventListener = jest.fn((event, listener) => {
-  eventListeners[event] = eventListeners[event]
-    ? [...eventListeners[event], listener]
-    : [listener];
-});
-const testRemoveEventListener = jest.fn((event, listener) => {
-  eventListeners[event] = (eventListeners[event] || []).filter(
-    l => l !== listener,
-  );
-});
-
-global.document.addEventListener = testAddEventListener;
-global.window.addEventListener = testAddEventListener;
-global.document.removeEventListener = testRemoveEventListener;
-global.window.removeEventListener = testRemoveEventListener;
diff --git a/frontend/test/__support__/ui-mocks.js b/frontend/test/__support__/ui-mocks.js
new file mode 100644
index 00000000000..dc8f42cf418
--- /dev/null
+++ b/frontend/test/__support__/ui-mocks.js
@@ -0,0 +1,21 @@
+jest.mock("metabase/components/Popover");
+
+// Replace addEventListener with a test implementation which collects all event listeners to `eventListeners` map
+export const eventListeners = {};
+
+const testAddEventListener = jest.fn((event, listener) => {
+  eventListeners[event] = eventListeners[event]
+    ? [...eventListeners[event], listener]
+    : [listener];
+});
+
+const testRemoveEventListener = jest.fn((event, listener) => {
+  eventListeners[event] = (eventListeners[event] || []).filter(
+    l => l !== listener,
+  );
+});
+
+global.document.addEventListener = testAddEventListener;
+global.window.addEventListener = testAddEventListener;
+global.document.removeEventListener = testRemoveEventListener;
+global.window.removeEventListener = testRemoveEventListener;
diff --git a/frontend/test/jest-setup.js b/frontend/test/jest-setup.js
index 19129b645c6..08cf36fc643 100644
--- a/frontend/test/jest-setup.js
+++ b/frontend/test/jest-setup.js
@@ -1,5 +1,6 @@
 import "raf/polyfill";
 import "jest-localstorage-mock";
+import "__support__/mocks";
 
 // NOTE: this is needed because sometimes asynchronous code tries to access
 // window.location or similar jsdom properties after the tests have ended and
diff --git a/frontend/test/metabase/containers/SaveQuestionModal.unit.spec.js b/frontend/test/metabase/containers/SaveQuestionModal.unit.spec.js
index 8d56a97e0ad..85a62564343 100644
--- a/frontend/test/metabase/containers/SaveQuestionModal.unit.spec.js
+++ b/frontend/test/metabase/containers/SaveQuestionModal.unit.spec.js
@@ -6,21 +6,33 @@ import mock from "xhr-mock";
 import SaveQuestionModal from "metabase/containers/SaveQuestionModal";
 import Question from "metabase-lib/lib/Question";
 import MetabaseSettings from "metabase/lib/settings";
-import { PLUGIN_CACHING } from "metabase/plugins";
 
 import {
   SAMPLE_DATASET,
   ORDERS,
   metadata,
 } from "__support__/sample_dataset_fixture";
+import { setupEnterpriseTest } from "__support__/enterprise";
 
 function mockCachingEnabled(enabled = true) {
-  const original = MetabaseSettings.get;
+  const original = MetabaseSettings.get.bind(MetabaseSettings);
   const spy = jest.spyOn(MetabaseSettings, "get");
   spy.mockImplementation(key => {
     if (key === "enable-query-caching") {
       return enabled;
     }
+    if (key === "application-name") {
+      return "Metabase Test";
+    }
+    if (key === "version") {
+      return { tag: "" };
+    }
+    if (key === "is-hosted?") {
+      return false;
+    }
+    if (key === "enable-enhancements?") {
+      return false;
+    }
     return original(key);
   });
 }
@@ -496,14 +508,7 @@ describe("SaveQuestionModal", () => {
 
     describe("EE", () => {
       beforeEach(() => {
-        PLUGIN_CACHING.cacheTTLFormField = {
-          name: "cache_ttl",
-          type: "integer",
-        };
-      });
-
-      afterEach(() => {
-        PLUGIN_CACHING.cacheTTLFormField = null;
+        setupEnterpriseTest();
       });
 
       it("is not shown", () => {
diff --git a/frontend/test/metabase/entities/collections/getCollectionIcon.unit.spec.js b/frontend/test/metabase/entities/collections/getCollectionIcon.unit.spec.js
index b64d31d0282..a17cceb8d41 100644
--- a/frontend/test/metabase/entities/collections/getCollectionIcon.unit.spec.js
+++ b/frontend/test/metabase/entities/collections/getCollectionIcon.unit.spec.js
@@ -1,4 +1,4 @@
-import { PLUGIN_COLLECTIONS } from "metabase/plugins";
+import { setupEnterpriseTest } from "__support__/enterprise";
 import {
   getCollectionIcon,
   ROOT_COLLECTION,
@@ -6,10 +6,6 @@ import {
 } from "metabase/entities/collections";
 
 describe("getCollectionIcon", () => {
-  const ORIGINAL_AUTHORITY_LEVELS = {
-    ...PLUGIN_COLLECTIONS.AUTHORITY_LEVEL,
-  };
-
   function collection({
     id = 10,
     personal_owner_id = null,
@@ -78,21 +74,7 @@ describe("getCollectionIcon", () => {
 
   describe("EE", () => {
     beforeEach(() => {
-      PLUGIN_COLLECTIONS.AUTHORITY_LEVEL = {
-        ...ORIGINAL_AUTHORITY_LEVELS,
-        official: {
-          type: "official",
-          icon: "badge",
-          color: "yellow",
-          tooltips: {
-            default: "Official Collection",
-          },
-        },
-      };
-    });
-
-    afterEach(() => {
-      PLUGIN_COLLECTIONS.AUTHORITY_LEVEL = ORIGINAL_AUTHORITY_LEVELS;
+      setupEnterpriseTest();
     });
 
     testCasesEE.forEach(testCase => {
diff --git a/frontend/test/metabase/query_builder/components/filters/FilterPopover.unit.spec.js b/frontend/test/metabase/query_builder/components/filters/FilterPopover.unit.spec.js
index 2840ee797b2..3132ddbca99 100644
--- a/frontend/test/metabase/query_builder/components/filters/FilterPopover.unit.spec.js
+++ b/frontend/test/metabase/query_builder/components/filters/FilterPopover.unit.spec.js
@@ -1,4 +1,4 @@
-import "__support__/mocks";
+import "__support__/ui-mocks";
 import React from "react";
 
 import { fireEvent, render, screen } from "@testing-library/react";
diff --git a/frontend/test/metabase/visualizations/components/LineAreaBarRenderer-bar.unit.spec.js b/frontend/test/metabase/visualizations/components/LineAreaBarRenderer-bar.unit.spec.js
index 621c444cca7..dbda0c5b8df 100644
--- a/frontend/test/metabase/visualizations/components/LineAreaBarRenderer-bar.unit.spec.js
+++ b/frontend/test/metabase/visualizations/components/LineAreaBarRenderer-bar.unit.spec.js
@@ -1,4 +1,4 @@
-import "__support__/mocks"; // included explicitly whereas with e2e tests it comes with __support__/e2e
+import "__support__/ui-mocks"; // included explicitly whereas with e2e tests it comes with __support__/e2e
 
 import {
   NumberColumn,
diff --git a/frontend/test/metabase/visualizations/components/LineAreaBarRenderer-scatter.unit.spec.js b/frontend/test/metabase/visualizations/components/LineAreaBarRenderer-scatter.unit.spec.js
index 5d5bbcea410..242deab19b7 100644
--- a/frontend/test/metabase/visualizations/components/LineAreaBarRenderer-scatter.unit.spec.js
+++ b/frontend/test/metabase/visualizations/components/LineAreaBarRenderer-scatter.unit.spec.js
@@ -1,4 +1,4 @@
-import "__support__/mocks"; // included explicitly whereas with e2e tests it comes with __support__/e2e
+import "__support__/ui-mocks"; // included explicitly whereas with e2e tests it comes with __support__/e2e
 
 import {
   NumberColumn,
diff --git a/frontend/test/metabase/visualizations/components/LineAreaBarRenderer-waterfall.unit.spec.js b/frontend/test/metabase/visualizations/components/LineAreaBarRenderer-waterfall.unit.spec.js
index f6976daaa27..522b9b3cf5f 100644
--- a/frontend/test/metabase/visualizations/components/LineAreaBarRenderer-waterfall.unit.spec.js
+++ b/frontend/test/metabase/visualizations/components/LineAreaBarRenderer-waterfall.unit.spec.js
@@ -1,4 +1,4 @@
-import "__support__/mocks"; // included explicitly whereas with e2e tests it comes with __support__/e2e
+import "__support__/ui-mocks"; // included explicitly whereas with e2e tests it comes with __support__/e2e
 
 import {
   NumberColumn,
diff --git a/frontend/test/metabase/visualizations/components/LineAreaBarRenderer.tz.unit.spec.js b/frontend/test/metabase/visualizations/components/LineAreaBarRenderer.tz.unit.spec.js
index f8ff8ed01a7..8194a0db1c2 100644
--- a/frontend/test/metabase/visualizations/components/LineAreaBarRenderer.tz.unit.spec.js
+++ b/frontend/test/metabase/visualizations/components/LineAreaBarRenderer.tz.unit.spec.js
@@ -1,4 +1,4 @@
-import "__support__/mocks"; // included explicitly whereas with integrated tests it comes with __support__/integrated_tests
+import "__support__/ui-mocks"; // included explicitly whereas with integrated tests it comes with __support__/integrated_tests
 import testAcrossTimezones from "__support__/timezones";
 
 import _ from "underscore";
diff --git a/frontend/test/metabase/visualizations/components/LineAreaBarRenderer.unit.spec.js b/frontend/test/metabase/visualizations/components/LineAreaBarRenderer.unit.spec.js
index bba6350b7b9..b3ee5d8bf3f 100644
--- a/frontend/test/metabase/visualizations/components/LineAreaBarRenderer.unit.spec.js
+++ b/frontend/test/metabase/visualizations/components/LineAreaBarRenderer.unit.spec.js
@@ -1,4 +1,4 @@
-import "__support__/mocks"; // included explicitly whereas with e2e tests it comes with __support__/e2e
+import "__support__/ui-mocks"; // included explicitly whereas with e2e tests it comes with __support__/e2e
 
 import {
   NumberColumn,
diff --git a/frontend/test/metabase/visualizations/components/RowRenderer.unit.spec.js b/frontend/test/metabase/visualizations/components/RowRenderer.unit.spec.js
index d82d1ec925e..ee15a8f4d4f 100644
--- a/frontend/test/metabase/visualizations/components/RowRenderer.unit.spec.js
+++ b/frontend/test/metabase/visualizations/components/RowRenderer.unit.spec.js
@@ -1,4 +1,4 @@
-import "__support__/mocks";
+import "__support__/ui-mocks";
 
 import {
   createFixture,
-- 
GitLab