Skip to content

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

Only import the needed plugins in unit tests (#66751)

Sébastienae13d817bf4d
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 2bdf79c845a..d19ada4de60 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
@@ -18,7 +18,7 @@ import { createMockTokenFeatures } from "metabase-types/api/mocks";
function setup(opts: SetupOpts = {}) {
baseSetup({
- hasEnterprisePlugins: true,
+ enterprisePlugins: "*", // TODO be more granular about this
tokenFeatures: createMockTokenFeatures({ cache_granular_controls: true }),
...opts,
});
diff --git a/enterprise/frontend/src/metabase-enterprise/content_translation/tests/other-hooks.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/content_translation/tests/other-hooks.unit.spec.tsx
index 217b538e64c..d690cf83712 100644
--- a/enterprise/frontend/src/metabase-enterprise/content_translation/tests/other-hooks.unit.spec.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/content_translation/tests/other-hooks.unit.spec.tsx
@@ -54,7 +54,7 @@ describe("Content translation hooks (other than useTranslateContent)", () => {
};
setupForContentTranslationTest({
localeCode: "en",
- hasEnterprisePlugins: true,
+ enterprisePlugins: ["content_translation"],
tokenFeatures: { content_translation: true },
dictionary: [
{ locale: "en", msgid: "Column 1", msgstr: "translation of Column 1" },
@@ -128,7 +128,7 @@ describe("Content translation hooks (other than useTranslateContent)", () => {
};
setupForContentTranslationTest({
localeCode: "en",
- hasEnterprisePlugins: true,
+ enterprisePlugins: ["content_translation"],
tokenFeatures: { content_translation: true },
dictionary: [
{ locale: "en", msgid: "Column 1", msgstr: "translation of Column 1" },
@@ -212,7 +212,7 @@ describe("Content translation hooks (other than useTranslateContent)", () => {
};
setupForContentTranslationTest({
localeCode: "en",
- hasEnterprisePlugins: true,
+ enterprisePlugins: ["content_translation"],
tokenFeatures: { content_translation: true },
dictionary: [
{ locale: "en", msgid: "Column 1", msgstr: "translation of Column 1" },
@@ -268,7 +268,7 @@ describe("Content translation hooks (other than useTranslateContent)", () => {
setupForContentTranslationTest({
localeCode: "en",
- hasEnterprisePlugins: true,
+ enterprisePlugins: ["content_translation"],
tokenFeatures: { content_translation: true },
dictionary: [
{ locale: "en", msgid: "Zebra", msgstr: "A-Animal" },
diff --git a/enterprise/frontend/src/metabase-enterprise/content_translation/tests/use-translate-content.common.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/content_translation/tests/use-translate-content.common.unit.spec.tsx
index b3a092aeef9..8e98b3462fc 100644
--- a/enterprise/frontend/src/metabase-enterprise/content_translation/tests/use-translate-content.common.unit.spec.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/content_translation/tests/use-translate-content.common.unit.spec.tsx
@@ -13,7 +13,7 @@ describe("useTranslateContent (OSS)", () => {
dictionary: [
{ locale: "es", msgid: "Hello World", msgstr: "Hola Mundo" },
],
- hasEnterprisePlugins: false,
+ enterprisePlugins: ["content_translation"],
tokenFeatures: { content_translation: false },
staticallyEmbedded: false,
});
diff --git a/enterprise/frontend/src/metabase-enterprise/content_translation/tests/use-translate-content.enterprise.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/content_translation/tests/use-translate-content.enterprise.unit.spec.tsx
index a85c989f042..eb13179d0a5 100644
--- a/enterprise/frontend/src/metabase-enterprise/content_translation/tests/use-translate-content.enterprise.unit.spec.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/content_translation/tests/use-translate-content.enterprise.unit.spec.tsx
@@ -13,7 +13,7 @@ describe("useTranslateContent (EE without token)", () => {
dictionary: [
{ locale: "es", msgid: "Hello World", msgstr: "Hola Mundo" },
],
- hasEnterprisePlugins: true,
+ enterprisePlugins: ["content_translation"],
tokenFeatures: { content_translation: false },
staticallyEmbedded: false,
});
diff --git a/enterprise/frontend/src/metabase-enterprise/content_translation/tests/use-translate-content.premium.unit.spec.tsx b/enterprise/frontend/src/metabase-enterprise/content_translation/tests/use-translate-content.premium.unit.spec.tsx
index 4ac97fb37d5..f1e3a7a6138 100644
--- a/enterprise/frontend/src/metabase-enterprise/content_translation/tests/use-translate-content.premium.unit.spec.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/content_translation/tests/use-translate-content.premium.unit.spec.tsx
@@ -13,7 +13,7 @@ describe("useTranslateContent (EE with token, in static embedding)", () => {
dictionary: [
{ locale: "es", msgid: "Hello World", msgstr: "Hola Mundo" },
],
- hasEnterprisePlugins: true,
+ enterprisePlugins: ["content_translation"],
tokenFeatures: { content_translation: true },
staticallyEmbedded: true,
});
diff --git a/enterprise/frontend/src/metabase-enterprise/resource_downloads/tests/common.unit.spec.ts b/enterprise/frontend/src/metabase-enterprise/resource_downloads/tests/common.unit.spec.ts
index bcba5c7c6c7..39ceae709c2 100644
--- a/enterprise/frontend/src/metabase-enterprise/resource_downloads/tests/common.unit.spec.ts
+++ b/enterprise/frontend/src/metabase-enterprise/resource_downloads/tests/common.unit.spec.ts
@@ -4,7 +4,7 @@ import { downloadsEnabledTestData, setup } from "./setup";
describe("[OSS] resource downloads plugin", () => {
beforeAll(() => {
- setup({ hasEnterprisePlugins: false });
+ setup({});
});
describe("areDownloadsEnabled - should always return true on OSS", () => {
diff --git a/enterprise/frontend/src/metabase-enterprise/resource_downloads/tests/enterprise.unit.spec.ts b/enterprise/frontend/src/metabase-enterprise/resource_downloads/tests/enterprise.unit.spec.ts
index f58b4b7109c..bb2f4370ba7 100644
--- a/enterprise/frontend/src/metabase-enterprise/resource_downloads/tests/enterprise.unit.spec.ts
+++ b/enterprise/frontend/src/metabase-enterprise/resource_downloads/tests/enterprise.unit.spec.ts
@@ -4,7 +4,7 @@ import { downloadsEnabledTestData, setup } from "./setup";
describe("[EE - no features] resource downloads plugin", () => {
beforeAll(() => {
- setup({ hasEnterprisePlugins: false });
+ setup({});
});
describe("areDownloadsEnabled - should always return true if we don't have the whitelabel feature", () => {
diff --git a/enterprise/frontend/src/metabase-enterprise/resource_downloads/tests/premium.unit.spec.ts b/enterprise/frontend/src/metabase-enterprise/resource_downloads/tests/premium.unit.spec.ts
index c71c704565d..21407f8d119 100644
--- a/enterprise/frontend/src/metabase-enterprise/resource_downloads/tests/premium.unit.spec.ts
+++ b/enterprise/frontend/src/metabase-enterprise/resource_downloads/tests/premium.unit.spec.ts
@@ -7,8 +7,8 @@ describe("[EE - with token features] resource downloads plugin", () => {
describe("areDownloadsEnabled", () => {
beforeEach(() => {
setup({
- hasEnterprisePlugins: true,
tokenFeatures: createMockTokenFeatures({ whitelabel: true }),
+ enterprisePlugins: ["resource_downloads"],
});
});
diff --git a/enterprise/frontend/src/metabase-enterprise/resource_downloads/tests/setup.ts b/enterprise/frontend/src/metabase-enterprise/resource_downloads/tests/setup.ts
index 64c537d55ea..240b982cdb6 100644
--- a/enterprise/frontend/src/metabase-enterprise/resource_downloads/tests/setup.ts
+++ b/enterprise/frontend/src/metabase-enterprise/resource_downloads/tests/setup.ts
@@ -1,4 +1,4 @@
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import { mockSettings } from "__support__/settings";
import type { EmbedResourceDownloadOptions } from "metabase/public/lib/types";
import type { TokenFeatures } from "metabase-types/api";
@@ -6,17 +6,19 @@ import { createMockTokenFeatures } from "metabase-types/api/mocks";
export interface SetupOpts {
tokenFeatures?: TokenFeatures;
- hasEnterprisePlugins?: boolean;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
}
export const setup = ({
tokenFeatures = createMockTokenFeatures(),
- hasEnterprisePlugins = false,
+ enterprisePlugins,
}: SetupOpts = {}) => {
mockSettings({ "token-features": tokenFeatures });
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
+ if (enterprisePlugins) {
+ enterprisePlugins.forEach((plugin) => {
+ setupEnterpriseOnlyPlugin(plugin);
+ });
}
};
diff --git a/frontend/src/metabase/account/profile/containers/UserProfileApp/tests/enterprise.unit.spec.tsx b/frontend/src/metabase/account/profile/containers/UserProfileApp/tests/enterprise.unit.spec.tsx
index 279119c3bd0..9fcb3bd06af 100644
--- a/frontend/src/metabase/account/profile/containers/UserProfileApp/tests/enterprise.unit.spec.tsx
+++ b/frontend/src/metabase/account/profile/containers/UserProfileApp/tests/enterprise.unit.spec.tsx
@@ -4,7 +4,7 @@ import { setup } from "./setup";
describe("UserProfileApp (EE)", () => {
it("should show all form fields, even when password login is disabled", () => {
- setup({ isPasswordLoginEnabled: false, hasEnterprisePlugins: true });
+ setup({ isPasswordLoginEnabled: false, enterprisePlugins: ["auth"] });
expect(screen.getByText(/first name/i)).toBeInTheDocument();
expect(screen.getByText(/last name/i)).toBeInTheDocument();
diff --git a/frontend/src/metabase/account/profile/containers/UserProfileApp/tests/premium.unit.spec.tsx b/frontend/src/metabase/account/profile/containers/UserProfileApp/tests/premium.unit.spec.tsx
index b501b83defc..1bfb5093e73 100644
--- a/frontend/src/metabase/account/profile/containers/UserProfileApp/tests/premium.unit.spec.tsx
+++ b/frontend/src/metabase/account/profile/containers/UserProfileApp/tests/premium.unit.spec.tsx
@@ -6,7 +6,7 @@ describe("UserProfileApp (EE with token)", () => {
it("should show only show language field for an SSO user", () => {
setup({
isPasswordLoginEnabled: false,
- hasEnterprisePlugins: true,
+ enterprisePlugins: ["auth"],
tokenFeatures: { disable_password_login: true },
});
diff --git a/frontend/src/metabase/account/profile/containers/UserProfileApp/tests/setup.tsx b/frontend/src/metabase/account/profile/containers/UserProfileApp/tests/setup.tsx
index dbfee2d6cda..de8b526e2ce 100644
--- a/frontend/src/metabase/account/profile/containers/UserProfileApp/tests/setup.tsx
+++ b/frontend/src/metabase/account/profile/containers/UserProfileApp/tests/setup.tsx
@@ -1,4 +1,4 @@
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import { mockSettings } from "__support__/settings";
import { renderWithProviders } from "__support__/ui";
import type { TokenFeatures } from "metabase-types/api";
@@ -9,11 +9,11 @@ import UserProfileApp from "../UserProfileApp";
export function setup({
isPasswordLoginEnabled = true,
- hasEnterprisePlugins = false,
+ enterprisePlugins,
tokenFeatures = {},
}: {
isPasswordLoginEnabled?: boolean;
- hasEnterprisePlugins?: boolean;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
tokenFeatures?: Partial<TokenFeatures>;
} = {}) {
const state = createMockState({
@@ -23,8 +23,10 @@ export function setup({
}),
});
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
+ if (enterprisePlugins) {
+ enterprisePlugins.forEach((plugin) => {
+ setupEnterpriseOnlyPlugin(plugin);
+ });
}
renderWithProviders(<UserProfileApp />, { storeInitialState: state });
diff --git a/frontend/src/metabase/actions/components/ActionViz/ExplainerText/tests/enterprise.unit.spec.ts b/frontend/src/metabase/actions/components/ActionViz/ExplainerText/tests/enterprise.unit.spec.ts
index 110b14e9fea..0b6431511e7 100644
--- a/frontend/src/metabase/actions/components/ActionViz/ExplainerText/tests/enterprise.unit.spec.ts
+++ b/frontend/src/metabase/actions/components/ActionViz/ExplainerText/tests/enterprise.unit.spec.ts
@@ -4,7 +4,7 @@ import type { SetupOpts } from "./setup";
import { setup as baseSetup } from "./setup";
function setup(opts: SetupOpts) {
- baseSetup({ hasEnterprisePlugins: true, ...opts });
+ baseSetup({ ...opts });
}
describe("ExplainerText (EE without token)", () => {
diff --git a/frontend/src/metabase/actions/components/ActionViz/ExplainerText/tests/premium.unit.spec.ts b/frontend/src/metabase/actions/components/ActionViz/ExplainerText/tests/premium.unit.spec.ts
index 90330b61aca..f1af8f6f268 100644
--- a/frontend/src/metabase/actions/components/ActionViz/ExplainerText/tests/premium.unit.spec.ts
+++ b/frontend/src/metabase/actions/components/ActionViz/ExplainerText/tests/premium.unit.spec.ts
@@ -5,8 +5,8 @@ import { setup as baseSetup } from "./setup";
function setup(opts: SetupOpts) {
baseSetup({
- hasEnterprisePlugins: true,
tokenFeatures: { whitelabel: true },
+ enterprisePlugins: ["whitelabel"],
...opts,
});
}
diff --git a/frontend/src/metabase/actions/components/ActionViz/ExplainerText/tests/setup.tsx b/frontend/src/metabase/actions/components/ActionViz/ExplainerText/tests/setup.tsx
index 71e8fec738d..8a2f269b493 100644
--- a/frontend/src/metabase/actions/components/ActionViz/ExplainerText/tests/setup.tsx
+++ b/frontend/src/metabase/actions/components/ActionViz/ExplainerText/tests/setup.tsx
@@ -1,4 +1,4 @@
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import { mockSettings } from "__support__/settings";
import { renderWithProviders } from "__support__/ui";
import type { TokenFeatures } from "metabase-types/api";
@@ -9,14 +9,14 @@ import { ExplainerText } from "../ExplainerText";
export interface SetupOpts {
showMetabaseLinks?: boolean;
- hasEnterprisePlugins?: boolean;
tokenFeatures?: Partial<TokenFeatures>;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
}
export const setup = ({
showMetabaseLinks = true,
- hasEnterprisePlugins,
tokenFeatures = {},
+ enterprisePlugins = [],
}: SetupOpts = {}) => {
const state = createMockState({
settings: mockSettings({
@@ -25,9 +25,9 @@ export const setup = ({
}),
});
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
- }
+ enterprisePlugins.forEach((plugin) => {
+ setupEnterpriseOnlyPlugin(plugin);
+ });
renderWithProviders(<ExplainerText />, { storeInitialState: state });
};
diff --git a/frontend/src/metabase/actions/containers/ActionCreator/FormCreator/Description/test/enterprise.unit.spec.ts b/frontend/src/metabase/actions/containers/ActionCreator/FormCreator/Description/test/enterprise.unit.spec.ts
index baaf2c0d7eb..cfc283165df 100644
--- a/frontend/src/metabase/actions/containers/ActionCreator/FormCreator/Description/test/enterprise.unit.spec.ts
+++ b/frontend/src/metabase/actions/containers/ActionCreator/FormCreator/Description/test/enterprise.unit.spec.ts
@@ -5,7 +5,6 @@ import { setup as baseSetup } from "./setup";
function setup(opts: SetupOpts) {
return baseSetup({
- hasEnterprisePlugins: true,
...opts,
});
}
diff --git a/frontend/src/metabase/actions/containers/ActionCreator/FormCreator/Description/test/premium.unit.spec.ts b/frontend/src/metabase/actions/containers/ActionCreator/FormCreator/Description/test/premium.unit.spec.ts
index 0594762b236..36be43cff98 100644
--- a/frontend/src/metabase/actions/containers/ActionCreator/FormCreator/Description/test/premium.unit.spec.ts
+++ b/frontend/src/metabase/actions/containers/ActionCreator/FormCreator/Description/test/premium.unit.spec.ts
@@ -5,8 +5,8 @@ import { setup as baseSetup } from "./setup";
function setup(opts: SetupOpts) {
return baseSetup({
- hasEnterprisePlugins: true,
tokenFeatures: { whitelabel: true },
+ enterprisePlugins: ["whitelabel"],
...opts,
});
}
diff --git a/frontend/src/metabase/actions/containers/ActionCreator/FormCreator/Description/test/setup.tsx b/frontend/src/metabase/actions/containers/ActionCreator/FormCreator/Description/test/setup.tsx
index 2710d271daa..44a6985e662 100644
--- a/frontend/src/metabase/actions/containers/ActionCreator/FormCreator/Description/test/setup.tsx
+++ b/frontend/src/metabase/actions/containers/ActionCreator/FormCreator/Description/test/setup.tsx
@@ -1,4 +1,4 @@
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import { mockSettings } from "__support__/settings";
import { renderWithProviders } from "__support__/ui";
import type { TokenFeatures } from "metabase-types/api";
@@ -9,14 +9,14 @@ import { Description } from "../Description";
export interface SetupOpts {
showMetabaseLinks?: boolean;
- hasEnterprisePlugins?: boolean;
tokenFeatures?: Partial<TokenFeatures>;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
}
export const setup = ({
showMetabaseLinks = true,
- hasEnterprisePlugins,
tokenFeatures = {},
+ enterprisePlugins = [],
}: SetupOpts = {}) => {
const state = createMockState({
settings: mockSettings({
@@ -25,9 +25,9 @@ export const setup = ({
}),
});
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
- }
+ enterprisePlugins.forEach((plugin) => {
+ setupEnterpriseOnlyPlugin(plugin);
+ });
renderWithProviders(<Description />, { storeInitialState: state });
};
diff --git a/frontend/src/metabase/actions/containers/ActionCreator/FormCreator/EmptyFormPlaceholder/tests/enterprise.unit.spec.ts b/frontend/src/metabase/actions/containers/ActionCreator/FormCreator/EmptyFormPlaceholder/tests/enterprise.unit.spec.ts
index 96d2a59bea4..5f4acb2dd30 100644
--- a/frontend/src/metabase/actions/containers/ActionCreator/FormCreator/EmptyFormPlaceholder/tests/enterprise.unit.spec.ts
+++ b/frontend/src/metabase/actions/containers/ActionCreator/FormCreator/EmptyFormPlaceholder/tests/enterprise.unit.spec.ts
@@ -5,7 +5,6 @@ import { setup as baseSetup } from "./setup";
function setup(opts: SetupOpts) {
baseSetup({
- hasEnterprisePlugins: true,
...opts,
});
}
diff --git a/frontend/src/metabase/actions/containers/ActionCreator/FormCreator/EmptyFormPlaceholder/tests/premium.unit.spec.ts b/frontend/src/metabase/actions/containers/ActionCreator/FormCreator/EmptyFormPlaceholder/tests/premium.unit.spec.ts
index 25a027614ef..b7b5f48bad1 100644
--- a/frontend/src/metabase/actions/containers/ActionCreator/FormCreator/EmptyFormPlaceholder/tests/premium.unit.spec.ts
+++ b/frontend/src/metabase/actions/containers/ActionCreator/FormCreator/EmptyFormPlaceholder/tests/premium.unit.spec.ts
@@ -5,7 +5,7 @@ import { setup as baseSetup } from "./setup";
function setup(opts: SetupOpts) {
baseSetup({
- hasEnterprisePlugins: true,
+ enterprisePlugins: ["whitelabel"],
tokenFeatures: {
whitelabel: true,
},
diff --git a/frontend/src/metabase/actions/containers/ActionCreator/FormCreator/EmptyFormPlaceholder/tests/setup.tsx b/frontend/src/metabase/actions/containers/ActionCreator/FormCreator/EmptyFormPlaceholder/tests/setup.tsx
index 1737cb76833..9faa1338349 100644
--- a/frontend/src/metabase/actions/containers/ActionCreator/FormCreator/EmptyFormPlaceholder/tests/setup.tsx
+++ b/frontend/src/metabase/actions/containers/ActionCreator/FormCreator/EmptyFormPlaceholder/tests/setup.tsx
@@ -1,4 +1,4 @@
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import { mockSettings } from "__support__/settings";
import { renderWithProviders } from "__support__/ui";
import type { TokenFeatures } from "metabase-types/api";
@@ -10,13 +10,13 @@ import { EmptyFormPlaceholder } from "../EmptyFormPlaceholder";
export interface SetupOpts {
applicationName?: string;
showMetabaseLinks?: boolean;
- hasEnterprisePlugins?: boolean;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
tokenFeatures?: Partial<TokenFeatures>;
}
export const setup = ({
showMetabaseLinks = true,
- hasEnterprisePlugins,
+ enterprisePlugins,
tokenFeatures = {},
}: SetupOpts = {}) => {
const state = createMockState({
@@ -26,8 +26,8 @@ export const setup = ({
}),
});
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
+ if (enterprisePlugins) {
+ enterprisePlugins.forEach(setupEnterpriseOnlyPlugin);
}
renderWithProviders(<EmptyFormPlaceholder />, { storeInitialState: state });
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 2a87a71652b..b8c21e9951b 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
@@ -7,7 +7,10 @@ import { defaultUser, setup } from "./setup";
describe("EditUserModal - enterprise", () => {
it("can add a user attribute", async () => {
- setup({ userData: defaultUser, hasEnterprisePlugins: true });
+ setup({
+ userData: defaultUser,
+ enterprisePlugins: ["sandboxes"],
+ });
const submitButton = await screen.findByText("Update");
const addAttributeButton = await screen.findByText("Add an attribute");
@@ -48,7 +51,7 @@ describe("EditUserModal - enterprise", () => {
first_name: null,
last_name: null,
},
- hasEnterprisePlugins: true,
+ enterprisePlugins: ["sandboxes"],
});
const submitButton = await screen.findByText("Update");
diff --git a/frontend/src/metabase/admin/people/containers/EditUserModal/test/setup.tsx b/frontend/src/metabase/admin/people/containers/EditUserModal/test/setup.tsx
index f793eec0c85..c3efa45d8d3 100644
--- a/frontend/src/metabase/admin/people/containers/EditUserModal/test/setup.tsx
+++ b/frontend/src/metabase/admin/people/containers/EditUserModal/test/setup.tsx
@@ -1,6 +1,6 @@
import fetchMock from "fetch-mock";
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import { setupUserEndpoints } from "__support__/server-mocks";
import { mockSettings } from "__support__/settings";
import { createMockEntitiesState } from "__support__/store";
@@ -25,10 +25,10 @@ export const defaultUser = createMockUser({
export const setup = ({
userData,
- hasEnterprisePlugins = false,
+ enterprisePlugins,
}: {
userData: Partial<User>;
- hasEnterprisePlugins?: boolean;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
}) => {
setupUserEndpoints(createMockUser(userData) as unknown as UserListResult);
@@ -44,8 +44,8 @@ export const setup = ({
),
});
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
+ if (enterprisePlugins) {
+ enterprisePlugins.forEach(setupEnterpriseOnlyPlugin);
}
fetchMock.get("path:/api/permissions/group", []);
diff --git a/frontend/src/metabase/admin/people/forms/UserForm.unit.spec.tsx b/frontend/src/metabase/admin/people/forms/UserForm.unit.spec.tsx
index fbbf2871325..8271544c5dd 100644
--- a/frontend/src/metabase/admin/people/forms/UserForm.unit.spec.tsx
+++ b/frontend/src/metabase/admin/people/forms/UserForm.unit.spec.tsx
@@ -1,7 +1,7 @@
import userEvent from "@testing-library/user-event";
import fetchMock from "fetch-mock";
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import { setupTenantEntpoints } from "__support__/server-mocks";
import { mockSettings } from "__support__/settings";
import { renderWithProviders, screen, waitFor } from "__support__/ui";
@@ -34,12 +34,19 @@ const USER = createMockUser({
],
});
+interface SetupOpts {
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
+ initialValues?: typeof USER;
+ external?: boolean;
+ tenants?: Tenant[];
+}
+
const setup = ({
- hasEnterprisePlugins = false,
+ enterprisePlugins,
initialValues = USER,
external = false,
tenants = [] as Tenant[],
-} = {}) => {
+}: SetupOpts = {}) => {
const onSubmit = jest.fn();
const onCancel = jest.fn();
@@ -56,8 +63,10 @@ const setup = ({
}),
});
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
+ if (enterprisePlugins) {
+ enterprisePlugins.forEach((plugin) => {
+ setupEnterpriseOnlyPlugin(plugin);
+ });
}
renderWithProviders(
@@ -185,7 +194,7 @@ describe("UserForm", () => {
it("should show login attributes widget", async () => {
setup({
- hasEnterprisePlugins: true,
+ enterprisePlugins: ["sandboxes", "tenants"],
initialValues: eeUser,
});
@@ -200,7 +209,7 @@ describe("UserForm", () => {
it("should allow you to add a login attribute", async () => {
const { onSubmit } = setup({
- hasEnterprisePlugins: true,
+ enterprisePlugins: ["sandboxes", "tenants"],
initialValues: eeUser,
});
@@ -235,7 +244,7 @@ describe("UserForm", () => {
it("should allow you to remove a login attribute", async () => {
const { onSubmit } = setup({
- hasEnterprisePlugins: true,
+ enterprisePlugins: ["sandboxes", "tenants"],
initialValues: eeUser,
});
@@ -258,7 +267,7 @@ describe("UserForm", () => {
it("should should not change the order of the inputs when working with numbers (#35316)", async () => {
setup({
- hasEnterprisePlugins: true,
+ enterprisePlugins: ["sandboxes", "tenants"],
initialValues: eeUser,
});
@@ -276,7 +285,7 @@ describe("UserForm", () => {
it("should show errors messages and disable form submit when 2 login attributes have the same key (#30196)", async () => {
setup({
- hasEnterprisePlugins: true,
+ enterprisePlugins: ["sandboxes", "tenants"],
initialValues: eeUser,
});
@@ -312,7 +321,7 @@ describe("UserForm", () => {
it("should require tenant_id for tenant users", async () => {
setup({
- hasEnterprisePlugins: true,
+ enterprisePlugins: ["sandboxes", "tenants"],
external: true,
tenants: TENANTS,
initialValues: {
@@ -330,7 +339,7 @@ describe("UserForm", () => {
it("should allow you to submit when tenant_id is selected", async () => {
const { onSubmit } = setup({
- hasEnterprisePlugins: true,
+ enterprisePlugins: ["sandboxes", "tenants"],
external: true,
tenants: TENANTS,
initialValues: {
diff --git a/frontend/src/metabase/admin/performance/components/test-utils.tsx b/frontend/src/metabase/admin/performance/components/test-utils.tsx
index 5f47ac80c01..14d497cc8dd 100644
--- a/frontend/src/metabase/admin/performance/components/test-utils.tsx
+++ b/frontend/src/metabase/admin/performance/components/test-utils.tsx
@@ -1,6 +1,9 @@
import { Route } from "react-router";
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import {
+ setupEnterpriseOnlyPlugin,
+ setupEnterprisePlugins,
+} from "__support__/enterprise";
import {
setupDatabasesEndpoints,
setupTokenStatusEndpoint,
@@ -25,12 +28,12 @@ import { createMockState } from "metabase-types/store/mocks";
import { StrategyEditorForDatabases } from "./StrategyEditorForDatabases";
export interface SetupOpts {
- hasEnterprisePlugins?: boolean;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][] | "*";
tokenFeatures?: Partial<TokenFeatures>;
}
export const setupStrategyEditorForDatabases = ({
- hasEnterprisePlugins = false,
+ enterprisePlugins,
tokenFeatures = {},
}: SetupOpts = {}) => {
const storeInitialState = createMockState({
@@ -42,10 +45,14 @@ export const setupStrategyEditorForDatabases = ({
),
});
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
+ if (enterprisePlugins) {
+ if (enterprisePlugins === "*") {
+ setupEnterprisePlugins();
+ } else {
+ enterprisePlugins.forEach(setupEnterpriseOnlyPlugin);
+ }
}
- setupTokenStatusEndpoint({ valid: hasEnterprisePlugins });
+ setupTokenStatusEndpoint({ valid: !!enterprisePlugins });
const cacheConfigs = [
createMockCacheConfigWithMultiplierStrategy({ model_id: 1 }),
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 29bb5865358..4ef9e5b379b 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
@@ -18,7 +18,11 @@ const tokenFeatures = { tenants: true, audit_app: true };
describe("Admin > CollectionPermissionsPage (enterprise)", () => {
describe("Tenant Collections Tab", () => {
it("shows the tab when tenants are enabled", async () => {
- setup({ tokenFeatures, settings: { "use-tenants": true } });
+ setup({
+ tokenFeatures,
+ enterprisePlugins: ["tenants", "audit_app"],
+ settings: { "use-tenants": true },
+ });
expect(
await screen.findByRole("radio", { name: "Tenant Collections" }),
@@ -26,7 +30,11 @@ describe("Admin > CollectionPermissionsPage (enterprise)", () => {
});
it("hides the tab when tenants are disabled", async () => {
- setup({ tokenFeatures, settings: { "use-tenants": false } });
+ setup({
+ tokenFeatures,
+ enterprisePlugins: ["tenants", "audit_app"],
+ settings: { "use-tenants": false },
+ });
expect(
screen.queryByRole("radio", { name: "Tenant Collections" }),
@@ -38,6 +46,7 @@ describe("Admin > CollectionPermissionsPage (enterprise)", () => {
it("should not be able get access to Our Analytics", async () => {
await setup({
tokenFeatures,
+ enterprisePlugins: ["tenants", "audit_app"],
initialRoute: "/admin/permissions/collections/root",
permissionGroups: defaultPermissionGroupsWithTenants,
permissionsGraph: defaultPermissionsGraphWithTenants,
@@ -53,6 +62,7 @@ describe("Admin > CollectionPermissionsPage (enterprise)", () => {
it("should not be able get access to normal collections", async () => {
await setup({
tokenFeatures,
+ enterprisePlugins: ["tenants", "audit_app"],
initialRoute: "/admin/permissions/collections/2",
permissionGroups: defaultPermissionGroupsWithTenants,
permissionsGraph: defaultPermissionsGraphWithTenants,
@@ -95,7 +105,8 @@ describe("Admin > CollectionPermissionsPage (enterprise)", () => {
collections: [...defaultCollections, iaCollection],
permissionsGraph: iaPermissionsGraph,
initialRoute: `/admin/permissions/collections/${iaCollection.id}`,
- tokenFeatures,
+ tokenFeatures: { audit_app: true },
+ enterprisePlugins: ["audit_app", "collections"],
});
await assertCollectionAccessForGroup("Administrators", "View");
@@ -113,7 +124,8 @@ describe("Admin > CollectionPermissionsPage (enterprise)", () => {
collections: [...defaultCollections, iaCollection],
permissionsGraph: iaPermissionsGraph,
initialRoute: `/admin/permissions/collections/${iaCollection.id}`,
- tokenFeatures,
+ tokenFeatures: { audit_app: true },
+ enterprisePlugins: ["audit_app", "collections"],
});
await assertCollectionAccessForGroup("Administrators", "View");
@@ -137,7 +149,8 @@ describe("Admin > CollectionPermissionsPage (enterprise)", () => {
collections: [...defaultCollections, iaCollection],
permissionsGraph: iaPermissionsGraph,
initialRoute: `/admin/permissions/collections/${iaCollection.id}`,
- tokenFeatures,
+ tokenFeatures: { audit_app: true },
+ enterprisePlugins: ["audit_app", "collections"],
});
// change all users users view to no access
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 c417a20c0d5..79dd054546a 100644
--- a/frontend/src/metabase/admin/permissions/pages/CollectionPermissionsPage/tests/setup.tsx
+++ b/frontend/src/metabase/admin/permissions/pages/CollectionPermissionsPage/tests/setup.tsx
@@ -1,6 +1,6 @@
import { Route } from "react-router";
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import {
setupCollectionPermissionsGraphEndpoint,
setupCollectionsEndpoints,
@@ -144,6 +144,7 @@ interface SetupOptions {
permissionGroups?: GroupInfo[];
tokenFeatures?: Partial<TokenFeatures>;
settings?: Partial<Settings>;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
}
export function setup({
@@ -154,6 +155,7 @@ export function setup({
permissionGroups = defaultPermissionGroups,
tokenFeatures,
settings = {},
+ enterprisePlugins = [],
}: Partial<SetupOptions> = {}) {
const initialState = createMockState({
settings: mockSettings({
@@ -163,9 +165,9 @@ export function setup({
}),
});
- if (tokenFeatures) {
- setupEnterprisePlugins();
- }
+ enterprisePlugins.forEach((plugin) => {
+ setupEnterpriseOnlyPlugin(plugin);
+ });
setupCollectionsEndpoints({
collections,
diff --git a/frontend/src/metabase/admin/settings/components/Email/SMTPConnectionCard/tests/enterprise.unit.spec.tsx b/frontend/src/metabase/admin/settings/components/Email/SMTPConnectionCard/tests/enterprise.unit.spec.tsx
index e50cf86950c..379b03803ef 100644
--- a/frontend/src/metabase/admin/settings/components/Email/SMTPConnectionCard/tests/enterprise.unit.spec.tsx
+++ b/frontend/src/metabase/admin/settings/components/Email/SMTPConnectionCard/tests/enterprise.unit.spec.tsx
@@ -4,7 +4,7 @@ import type { SetupOpts } from "./setup";
import { setup as baseSetup } from "./setup";
function setup(opts: SetupOpts = {}) {
- return baseSetup({ hasEnterprisePlugins: true, ...opts });
+ return baseSetup({ ...opts });
}
describe("SSMTPConnectionCard (EE without token)", () => {
diff --git a/frontend/src/metabase/admin/settings/components/Email/SMTPConnectionCard/tests/premium.unit.spec.tsx b/frontend/src/metabase/admin/settings/components/Email/SMTPConnectionCard/tests/premium.unit.spec.tsx
index a0aa8c0201c..857ee303502 100644
--- a/frontend/src/metabase/admin/settings/components/Email/SMTPConnectionCard/tests/premium.unit.spec.tsx
+++ b/frontend/src/metabase/admin/settings/components/Email/SMTPConnectionCard/tests/premium.unit.spec.tsx
@@ -4,7 +4,7 @@ import type { SetupOpts } from "./setup";
import { setup as baseSetup } from "./setup";
async function setup(opts: SetupOpts = {}) {
- return baseSetup({ hasEnterprisePlugins: true, ...opts });
+ return baseSetup({ enterprisePlugins: ["smtp-override"], ...opts });
}
describe("SMTPConnectionCard (EE with token)", () => {
diff --git a/frontend/src/metabase/admin/settings/components/Email/SMTPConnectionCard/tests/setup.tsx b/frontend/src/metabase/admin/settings/components/Email/SMTPConnectionCard/tests/setup.tsx
index 3bd9575870d..2d98f47c605 100644
--- a/frontend/src/metabase/admin/settings/components/Email/SMTPConnectionCard/tests/setup.tsx
+++ b/frontend/src/metabase/admin/settings/components/Email/SMTPConnectionCard/tests/setup.tsx
@@ -1,4 +1,4 @@
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import {
setupPropertiesEndpoints,
setupSettingsEndpoints,
@@ -16,14 +16,14 @@ import { createMockState } from "metabase-types/store/mocks";
export interface SetupOpts {
tokenFeatures?: Partial<TokenFeatures>;
- hasEnterprisePlugins?: boolean;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
isHosted?: boolean;
smtpOverrideEnabled?: boolean;
}
export function setup({
tokenFeatures = {},
- hasEnterprisePlugins = false,
+ enterprisePlugins,
isHosted = true,
smtpOverrideEnabled = false,
}: SetupOpts = {}) {
@@ -42,8 +42,8 @@ export function setup({
const state = createMockState({ settings: mockSettings(settings) });
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
+ if (enterprisePlugins) {
+ enterprisePlugins.forEach(setupEnterpriseOnlyPlugin);
}
renderWithProviders(<SMTPConnectionCard />, {
diff --git a/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSecuritySettings/tests/enterprise.unit.spec.tsx b/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSecuritySettings/tests/enterprise.unit.spec.tsx
index 16430c906f7..7444ae99301 100644
--- a/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSecuritySettings/tests/enterprise.unit.spec.tsx
+++ b/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSecuritySettings/tests/enterprise.unit.spec.tsx
@@ -20,10 +20,10 @@ const setup = async ({
}),
showSdkEmbedTerms,
isEmbeddingSdkEnabled,
- hasEnterprisePlugins: isEmbeddingSdkEnabled,
tokenFeatures: {
embedding_sdk: isEmbeddingSdkEnabled,
},
+ enterprisePlugins: isEmbeddingSdkEnabled ? ["embedding-sdk"] : [],
});
expect(await screen.findByText("Security")).toBeInTheDocument();
diff --git a/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSecuritySettings/tests/simple-embedding.unit.spec.tsx b/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSecuritySettings/tests/simple-embedding.unit.spec.tsx
index 73e6edb445a..ad25f8fefc8 100644
--- a/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSecuritySettings/tests/simple-embedding.unit.spec.tsx
+++ b/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSecuritySettings/tests/simple-embedding.unit.spec.tsx
@@ -20,11 +20,11 @@ const setup = async ({
showSdkEmbedTerms,
isEmbeddingSdkEnabled,
isEmbeddingSimpleEnabled,
- hasEnterprisePlugins: true,
tokenFeatures: {
embedding_sdk: true,
embedding_simple: true,
},
+ enterprisePlugins: ["embedding-sdk"],
});
expect(await screen.findByText("Security")).toBeInTheDocument();
diff --git a/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSettings/tests/common.unit.spec.tsx b/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSettings/tests/common.unit.spec.tsx
index feabcb973a1..44af1a4ab33 100644
--- a/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSettings/tests/common.unit.spec.tsx
+++ b/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSettings/tests/common.unit.spec.tsx
@@ -51,7 +51,9 @@ describe("EmbeddingSdkSettings (OSS)", () => {
});
it("does not show the modular embedding toggle when token features are missing", () => {
- setup({ tokenFeatures: { embedding_simple: false } });
+ setup({
+ tokenFeatures: { embedding_simple: false },
+ });
expect(
screen.queryByText("Enable modular embedding"),
diff --git a/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSettings/tests/enterprise.unit.spec.tsx b/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSettings/tests/enterprise.unit.spec.tsx
index d18cbb1c468..79d9f82e483 100644
--- a/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSettings/tests/enterprise.unit.spec.tsx
+++ b/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSettings/tests/enterprise.unit.spec.tsx
@@ -4,7 +4,6 @@ import { type SetupOpts, setup as baseSetup } from "./setup";
const setup = (opts: SetupOpts = {}) =>
baseSetup({
- hasEnterprisePlugins: true,
tokenFeatures: { embedding_sdk: opts.isEmbeddingSdkEnabled },
...opts,
});
@@ -15,6 +14,11 @@ describe("EmbeddingSdkSettings (EE)", () => {
isEmbeddingSdkEnabled: false,
showSdkEmbedTerms: false,
isHosted: true,
+ enterprisePlugins: [
+ "embedding-sdk",
+ "embedding_iframe_sdk",
+ "embedding_iframe_sdk_setup",
+ ],
});
expect(
screen.getByText(
@@ -34,8 +38,13 @@ describe("EmbeddingSdkSettings (EE)", () => {
it("should show Tenants in related settings when tenants feature is available", async () => {
await setup({
- hasEnterprisePlugins: true,
tokenFeatures: { tenants: true },
+ enterprisePlugins: [
+ "embedding-sdk",
+ "embedding_iframe_sdk",
+ "embedding_iframe_sdk_setup",
+ "tenants",
+ ],
});
expect(screen.getByText("Tenants")).toBeInTheDocument();
diff --git a/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSettings/tests/premium.unit.spec.tsx b/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSettings/tests/premium.unit.spec.tsx
index e6792e616d3..337e5be7479 100644
--- a/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSettings/tests/premium.unit.spec.tsx
+++ b/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSettings/tests/premium.unit.spec.tsx
@@ -4,7 +4,6 @@ import { type SetupOpts, setup as baseSetup } from "./setup";
const setup = (opts: SetupOpts = {}) =>
baseSetup({
- hasEnterprisePlugins: true,
tokenFeatures: { embedding_sdk: opts.isEmbeddingSdkEnabled },
...opts,
});
@@ -14,6 +13,11 @@ describe("EmbeddingSdkSettings (EE with Embedding SDK token)", () => {
await setup({
isEmbeddingSdkEnabled: true,
showSdkEmbedTerms: false,
+ enterprisePlugins: [
+ "embedding-sdk",
+ "embedding_iframe_sdk",
+ "embedding_iframe_sdk_setup",
+ ],
});
expect(
screen.getByText(
@@ -36,7 +40,16 @@ describe("EmbeddingSdkSettings (EE with Embedding SDK token)", () => {
describe("Version pinning", () => {
it("should offer users version pinning when they have a cloud instance", async () => {
- await setup({ isHosted: true });
+ await setup({
+ isEmbeddingSdkEnabled: true,
+ showSdkEmbedTerms: false,
+ isHosted: true,
+ enterprisePlugins: [
+ "embedding-sdk",
+ "embedding_iframe_sdk",
+ "embedding_iframe_sdk_setup",
+ ],
+ });
expect(screen.getByText("Version pinning")).toBeInTheDocument();
expect(
diff --git a/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSettings/tests/setup.tsx b/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSettings/tests/setup.tsx
index 43c75a94f98..e6e61bba143 100644
--- a/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSettings/tests/setup.tsx
+++ b/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSettings/tests/setup.tsx
@@ -10,6 +10,7 @@ export type SetupOpts = Omit<BaseSetupOpts, "renderCallback">;
export async function setup(setupOptions: SetupOpts = {}) {
baseSetup({
+ enterprisePlugins: [], // ensures PLUGIN_IS_EE_BUILD.isEEBuild is set to true
...setupOptions,
renderCallback: ({ state }) =>
renderWithProviders(<EmbeddingSettings />, { storeInitialState: state }),
diff --git a/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSettings/tests/simple-embedding.unit.spec.tsx b/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSettings/tests/simple-embedding.unit.spec.tsx
index 32f7d5fc9ae..48aac66b62a 100644
--- a/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSettings/tests/simple-embedding.unit.spec.tsx
+++ b/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSettings/tests/simple-embedding.unit.spec.tsx
@@ -7,11 +7,11 @@ import { type SetupOpts, setup as baseSetup } from "./setup";
const setup = (opts: SetupOpts = {}) =>
baseSetup({
- hasEnterprisePlugins: true,
tokenFeatures: {
embedding_sdk: true,
embedding_simple: true,
},
+ enterprisePlugins: ["embedding"],
...opts,
});
diff --git a/frontend/src/metabase/admin/settings/components/EmbeddingSettings/tests/setup.tsx b/frontend/src/metabase/admin/settings/components/EmbeddingSettings/tests/setup.tsx
index ab36c4bf6f3..22332c544e0 100644
--- a/frontend/src/metabase/admin/settings/components/EmbeddingSettings/tests/setup.tsx
+++ b/frontend/src/metabase/admin/settings/components/EmbeddingSettings/tests/setup.tsx
@@ -1,4 +1,4 @@
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import {
findRequests,
setupPropertiesEndpoints,
@@ -10,6 +10,7 @@ import {
} from "__support__/server-mocks";
import { mockSettings } from "__support__/settings";
import { waitFor } from "__support__/ui";
+import { PLUGIN_IS_EE_BUILD } from "metabase/plugins";
import type { Settings, TokenFeatures } from "metabase-types/api";
import {
createMockSettings,
@@ -24,8 +25,8 @@ export interface SetupOpts {
isEmbeddingSdkEnabled?: Settings["enable-embedding-sdk"];
isEmbeddingSimpleEnabled?: Settings["enable-embedding-simple"];
isHosted?: Settings["is-hosted?"];
- hasEnterprisePlugins?: boolean;
tokenFeatures?: Partial<TokenFeatures>;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
}
export async function setup({
@@ -34,8 +35,8 @@ export async function setup({
isEmbeddingSdkEnabled = false,
isEmbeddingSimpleEnabled = false,
isHosted = false,
- hasEnterprisePlugins = false,
tokenFeatures = {},
+ enterprisePlugins,
}: SetupOpts) {
const settings = createMockSettings({
"show-sdk-embed-terms": showSdkEmbedTerms,
@@ -49,8 +50,13 @@ export async function setup({
settings: mockSettings(settings),
});
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
+ if (enterprisePlugins?.length) {
+ PLUGIN_IS_EE_BUILD.isEEBuild = () => true;
+
+ enterprisePlugins.forEach((plugin) => {
+ setupEnterpriseOnlyPlugin(plugin);
+ });
+
setupTokenStatusEndpoint({ valid: true });
}
diff --git a/frontend/src/metabase/admin/settings/components/SettingsPages/test/AuthenticationSettingsPage.enterprise.unit.spec.tsx b/frontend/src/metabase/admin/settings/components/SettingsPages/test/AuthenticationSettingsPage.enterprise.unit.spec.tsx
index 41a96e5c832..a270b3f7cc5 100644
--- a/frontend/src/metabase/admin/settings/components/SettingsPages/test/AuthenticationSettingsPage.enterprise.unit.spec.tsx
+++ b/frontend/src/metabase/admin/settings/components/SettingsPages/test/AuthenticationSettingsPage.enterprise.unit.spec.tsx
@@ -1,4 +1,4 @@
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import { screen } from "__support__/ui";
import type { EnterpriseSettings } from "metabase-types/api";
@@ -8,7 +8,7 @@ const setup = async (
extraSettings?: Partial<EnterpriseSettings>,
tab = "authentication",
) => {
- setupEnterprisePlugins();
+ setupEnterpriseOnlyPlugin("auth");
return OSSSetup(extraSettings, true, tab);
};
diff --git a/frontend/src/metabase/admin/settings/tests/enterprise.unit.spec.tsx b/frontend/src/metabase/admin/settings/tests/enterprise.unit.spec.tsx
index b605679f3bf..1e5a1d5c015 100644
--- a/frontend/src/metabase/admin/settings/tests/enterprise.unit.spec.tsx
+++ b/frontend/src/metabase/admin/settings/tests/enterprise.unit.spec.tsx
@@ -10,11 +10,11 @@ import {
} from "./setup";
const setup = async ({ isAdmin = true, initialRoute = "" } = {}) => {
- return baseSetup({
- hasEnterprisePlugins: true,
+ await baseSetup({
hasTokenFeatures: false,
isAdmin,
initialRoute,
+ enterprisePlugins: "*", // means all enterprise plugins
});
};
diff --git a/frontend/src/metabase/admin/settings/tests/oss.unit.spec.tsx b/frontend/src/metabase/admin/settings/tests/oss.unit.spec.tsx
index 8c9a390df3a..1ff87103e9f 100644
--- a/frontend/src/metabase/admin/settings/tests/oss.unit.spec.tsx
+++ b/frontend/src/metabase/admin/settings/tests/oss.unit.spec.tsx
@@ -10,7 +10,7 @@ import {
const setup = async ({ isAdmin = true, initialRoute = "" } = {}) => {
return baseSetup({
- hasEnterprisePlugins: false,
+ enterprisePlugins: undefined,
hasTokenFeatures: false,
isAdmin,
initialRoute,
diff --git a/frontend/src/metabase/admin/settings/tests/premium.unit.spec.tsx b/frontend/src/metabase/admin/settings/tests/premium.unit.spec.tsx
index 01a133b9b0f..ed6cc8bf69b 100644
--- a/frontend/src/metabase/admin/settings/tests/premium.unit.spec.tsx
+++ b/frontend/src/metabase/admin/settings/tests/premium.unit.spec.tsx
@@ -14,12 +14,12 @@ const setup = async ({
initialRoute = "",
features = {},
} = {}) => {
- return baseSetup({
- hasEnterprisePlugins: true,
+ await baseSetup({
hasTokenFeatures: true,
isAdmin,
features,
initialRoute,
+ enterprisePlugins: "*", // means all enterprise plugins
});
};
diff --git a/frontend/src/metabase/admin/settings/tests/setup.tsx b/frontend/src/metabase/admin/settings/tests/setup.tsx
index fc6093bafc7..ad858791892 100644
--- a/frontend/src/metabase/admin/settings/tests/setup.tsx
+++ b/frontend/src/metabase/admin/settings/tests/setup.tsx
@@ -1,7 +1,10 @@
import fetchMock from "fetch-mock";
import { Route } from "react-router";
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import {
+ setupEnterpriseOnlyPlugin,
+ setupEnterprisePlugins,
+} from "__support__/enterprise";
import {
setupApiKeyEndpoints,
setupDatabasesEndpoints,
@@ -19,7 +22,7 @@ import { setupWebhookChannelsEndpoint } from "__support__/server-mocks/channel";
import { mockSettings } from "__support__/settings";
import { renderWithProviders, screen } from "__support__/ui";
import { getSettingsRoutes } from "metabase/admin/settingsRoutes";
-import type { TokenFeature } from "metabase-types/api";
+import type { TokenFeature, TokenFeatures } from "metabase-types/api";
import {
createMockSettings,
createMockTokenFeatures,
@@ -96,11 +99,17 @@ export const routeObjtoArray = (map: RouteMap) => {
};
export const setup = async ({
- hasEnterprisePlugins = false,
+ enterprisePlugins,
hasTokenFeatures = false,
isAdmin = true,
features = {},
initialRoute = "",
+}: {
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][] | "*";
+ hasTokenFeatures?: boolean;
+ isAdmin?: boolean;
+ features?: Partial<TokenFeatures>;
+ initialRoute?: string;
}) => {
const tokenFeatures = createMockTokenFeatures({});
if (hasTokenFeatures) {
@@ -146,8 +155,12 @@ export const setup = async ({
settings: mockSettings(settings),
});
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
+ if (enterprisePlugins) {
+ if (enterprisePlugins === "*") {
+ setupEnterprisePlugins();
+ } else {
+ enterprisePlugins.forEach(setupEnterpriseOnlyPlugin);
+ }
setupTokenStatusEndpoint({ valid: hasTokenFeatures });
}
diff --git a/frontend/src/metabase/auth/components/Login/tests/enterprise.unit.spec.tsx b/frontend/src/metabase/auth/components/Login/tests/enterprise.unit.spec.tsx
index b5bff05f2c2..14fc8a005ae 100644
--- a/frontend/src/metabase/auth/components/Login/tests/enterprise.unit.spec.tsx
+++ b/frontend/src/metabase/auth/components/Login/tests/enterprise.unit.spec.tsx
@@ -8,7 +8,6 @@ describe("Login", () => {
setup({
isPasswordLoginEnabled: false,
isGoogleAuthEnabled: true,
- hasEnterprisePlugins: true,
});
expect(screen.getByText("Sign in with email")).toBeInTheDocument();
diff --git a/frontend/src/metabase/auth/components/Login/tests/premium.unit.spec.tsx b/frontend/src/metabase/auth/components/Login/tests/premium.unit.spec.tsx
index a4ca1e47fd5..85aed6bc994 100644
--- a/frontend/src/metabase/auth/components/Login/tests/premium.unit.spec.tsx
+++ b/frontend/src/metabase/auth/components/Login/tests/premium.unit.spec.tsx
@@ -7,7 +7,6 @@ describe("Login", () => {
setup({
isPasswordLoginEnabled: false,
isGoogleAuthEnabled: true,
- hasEnterprisePlugins: true,
tokenFeatures: { disable_password_login: true },
});
diff --git a/frontend/src/metabase/auth/components/Login/tests/setup.tsx b/frontend/src/metabase/auth/components/Login/tests/setup.tsx
index c5784fea5bb..104f4c00395 100644
--- a/frontend/src/metabase/auth/components/Login/tests/setup.tsx
+++ b/frontend/src/metabase/auth/components/Login/tests/setup.tsx
@@ -1,6 +1,6 @@
import { Route } from "react-router";
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import { mockSettings } from "__support__/settings";
import { renderWithProviders } from "__support__/ui";
import type { TokenFeatures } from "metabase-types/api";
@@ -13,7 +13,7 @@ interface SetupOpts {
initialRoute?: string;
isPasswordLoginEnabled?: boolean;
isGoogleAuthEnabled?: boolean;
- hasEnterprisePlugins?: boolean;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
tokenFeatures?: Partial<TokenFeatures>;
}
@@ -21,7 +21,7 @@ export const setup = ({
initialRoute = "/auth/login",
isPasswordLoginEnabled = true,
isGoogleAuthEnabled = false,
- hasEnterprisePlugins = false,
+ enterprisePlugins,
tokenFeatures = {},
}: SetupOpts = {}) => {
const state = createMockState({
@@ -32,8 +32,8 @@ export const setup = ({
}),
});
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
+ if (enterprisePlugins) {
+ enterprisePlugins.forEach(setupEnterpriseOnlyPlugin);
}
renderWithProviders(
diff --git a/frontend/src/metabase/browse/metrics/tests/enterprise.unit.spec.tsx b/frontend/src/metabase/browse/metrics/tests/enterprise.unit.spec.tsx
index 3ae1ec77d96..ca2c8718e78 100644
--- a/frontend/src/metabase/browse/metrics/tests/enterprise.unit.spec.tsx
+++ b/frontend/src/metabase/browse/metrics/tests/enterprise.unit.spec.tsx
@@ -1,13 +1,6 @@
import { screen } from "__support__/ui";
-import { type SetupOpts, setup as baseSetup } from "./setup";
-
-function setup(opts: SetupOpts) {
- baseSetup({
- hasEnterprisePlugins: true,
- ...opts,
- });
-}
+import { setup } from "./setup";
describe("BrowseMetrics (EE without token)", () => {
it("displays a link to the metrics docs when show-metabase-links = true", async () => {
diff --git a/frontend/src/metabase/browse/metrics/tests/premium.unit.spec.tsx b/frontend/src/metabase/browse/metrics/tests/premium.unit.spec.tsx
index cf139c9dd5b..b8bf8972fba 100644
--- a/frontend/src/metabase/browse/metrics/tests/premium.unit.spec.tsx
+++ b/frontend/src/metabase/browse/metrics/tests/premium.unit.spec.tsx
@@ -4,8 +4,8 @@ import { type SetupOpts, setup as baseSetup } from "./setup";
function setup(opts: SetupOpts) {
baseSetup({
- hasEnterprisePlugins: true,
tokenFeatures: { whitelabel: true },
+ enterprisePlugins: ["whitelabel"],
...opts,
});
}
diff --git a/frontend/src/metabase/browse/metrics/tests/setup.tsx b/frontend/src/metabase/browse/metrics/tests/setup.tsx
index 69b61e27352..373a17ded86 100644
--- a/frontend/src/metabase/browse/metrics/tests/setup.tsx
+++ b/frontend/src/metabase/browse/metrics/tests/setup.tsx
@@ -1,6 +1,6 @@
import { Route } from "react-router";
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import {
setupCardEndpoints,
setupCardQueryEndpoints,
@@ -208,18 +208,18 @@ export type SetupOpts = {
metricCount?: number;
recentMetricCount?: number;
showMetabaseLinks?: boolean;
- hasEnterprisePlugins?: boolean;
tokenFeatures?: Partial<TokenFeatures>;
canCreateQueries?: boolean;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
};
export function setup({
metricCount = Infinity,
recentMetricCount = 5,
showMetabaseLinks = true,
- hasEnterprisePlugins,
tokenFeatures = {},
canCreateQueries = true,
+ enterprisePlugins = [],
}: SetupOpts = {}) {
const state = createMockState({
setup: createMockSetupState({
@@ -237,9 +237,9 @@ export function setup({
}),
});
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
- }
+ enterprisePlugins.forEach((plugin) => {
+ setupEnterpriseOnlyPlugin(plugin);
+ });
const mockMetricResults = mockMetrics.map(createMockMetricResult);
const mockRecentMetrics = mockMetrics.map((metric) =>
diff --git a/frontend/src/metabase/collections/components/CollectionHeader/tests/enterprise.unit.spec.tsx b/frontend/src/metabase/collections/components/CollectionHeader/tests/enterprise.unit.spec.tsx
index 65e33617f07..62be6be4a94 100644
--- a/frontend/src/metabase/collections/components/CollectionHeader/tests/enterprise.unit.spec.tsx
+++ b/frontend/src/metabase/collections/components/CollectionHeader/tests/enterprise.unit.spec.tsx
@@ -13,7 +13,7 @@ describe("Instance Analytics Collection Header", () => {
type: "instance-analytics" as CollectionType,
can_write: false,
},
- hasEnterprisePlugins: true,
+ enterprisePlugins: ["audit_app" as const, "collections" as const],
// 😬 this test needs the official_collections feature flag so that it
// doesn't cause the following test block to fail
tokenFeatures: { audit_app: true, official_collections: true },
@@ -76,7 +76,7 @@ describe("instance analytics custom reports collection", () => {
can_write: true,
entity_id: createMockEntityId("okNLSZKdSxaoG58JSQY54"),
},
- hasEnterprisePlugins: true,
+ enterprisePlugins: "*" as const, // TODO: specify exact plugins needed
// 😬 this test needs the official_collections feature flag so that it
// doesn't cause the following test block to fail
tokenFeatures: { audit_app: true, official_collections: true },
@@ -111,7 +111,7 @@ describe("Official Collections Header", () => {
name: "Rock Collection",
can_write: true,
},
- hasEnterprisePlugins: true,
+ enterprisePlugins: ["collections" as const, "audit_app" as const],
tokenFeatures: { official_collections: true },
isAdmin: true,
};
diff --git a/frontend/src/metabase/collections/components/CollectionHeader/tests/setup.tsx b/frontend/src/metabase/collections/components/CollectionHeader/tests/setup.tsx
index 4a8f7538014..56b918e1ed2 100644
--- a/frontend/src/metabase/collections/components/CollectionHeader/tests/setup.tsx
+++ b/frontend/src/metabase/collections/components/CollectionHeader/tests/setup.tsx
@@ -1,6 +1,9 @@
import { Route } from "react-router";
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import {
+ setupEnterpriseOnlyPlugin,
+ setupEnterprisePlugins,
+} from "__support__/enterprise";
import {
setupDashboardQuestionCandidatesEndpoint,
setupUserKeyValueEndpoints,
@@ -34,12 +37,12 @@ const getProps = (
export const setup = ({
collection,
- hasEnterprisePlugins = false,
+ enterprisePlugins,
tokenFeatures,
...otherProps
}: {
collection?: Partial<Collection>;
- hasEnterprisePlugins?: boolean;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][] | "*";
tokenFeatures?: Partial<TokenFeatures>;
} & Partial<Omit<CollectionHeaderProps, "collection">> = {}) => {
setupDashboardQuestionCandidatesEndpoint([]);
@@ -69,8 +72,12 @@ export const setup = ({
});
const state = createMockState({ settings });
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
+ if (enterprisePlugins) {
+ if (enterprisePlugins === "*") {
+ setupEnterprisePlugins();
+ } else {
+ enterprisePlugins.forEach(setupEnterpriseOnlyPlugin);
+ }
}
renderWithProviders(
diff --git a/frontend/src/metabase/collections/components/CollectionMenu/tests/enterprise.unit.spec.tsx b/frontend/src/metabase/collections/components/CollectionMenu/tests/enterprise.unit.spec.tsx
index d254dc8ebc5..29d6870cf8f 100644
--- a/frontend/src/metabase/collections/components/CollectionMenu/tests/enterprise.unit.spec.tsx
+++ b/frontend/src/metabase/collections/components/CollectionMenu/tests/enterprise.unit.spec.tsx
@@ -10,7 +10,10 @@ import type { SetupOpts } from "./setup";
import { setup } from "./setup";
const setupEnterprise = (opts?: SetupOpts) => {
- return setup({ ...opts, hasEnterprisePlugins: true });
+ return setup({
+ ...opts,
+ enterprisePlugins: ["advanced_permissions", "tenants"],
+ });
};
describe("CollectionMenu", () => {
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 16efa944cec..1c66fe2282f 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
@@ -17,7 +17,7 @@ const setupPremium = (opts?: SetupOpts) => {
official_collections: true,
collection_cleanup: true,
}),
- hasEnterprisePlugins: true,
+ enterprisePlugins: ["collections", "clean_up"],
});
};
diff --git a/frontend/src/metabase/collections/components/CollectionMenu/tests/setup.tsx b/frontend/src/metabase/collections/components/CollectionMenu/tests/setup.tsx
index 5760efd54bf..54ffe0c8a4d 100644
--- a/frontend/src/metabase/collections/components/CollectionMenu/tests/setup.tsx
+++ b/frontend/src/metabase/collections/components/CollectionMenu/tests/setup.tsx
@@ -2,7 +2,7 @@
import fetchMock from "fetch-mock";
import { Route } from "react-router";
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import {
setupDashboardQuestionCandidatesEndpoint,
setupStaleItemsEndpoint,
@@ -29,7 +29,7 @@ export interface SetupOpts {
tokenFeatures?: TokenFeatures;
isAdmin?: boolean;
isPersonalCollectionChild?: boolean;
- hasEnterprisePlugins?: boolean;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
dashboardQuestionCandidates?: DashboardQuestionCandidate[];
moveToDashboard?: boolean;
numberOfCollectionItems?: number;
@@ -40,7 +40,7 @@ export const setup = ({
collection = createMockCollection(),
tokenFeatures = createMockTokenFeatures(),
isAdmin = false,
- hasEnterprisePlugins = false,
+ enterprisePlugins,
dashboardQuestionCandidates = [],
moveToDashboard = false,
numberOfCollectionItems = 10,
@@ -77,9 +77,9 @@ export const setup = ({
const onUpdateCollection = jest.fn();
- if (hasEnterprisePlugins) {
+ if (enterprisePlugins) {
setupStaleItemsEndpoint(numberOfStaleItems);
- setupEnterprisePlugins();
+ enterprisePlugins.forEach((plugin) => setupEnterpriseOnlyPlugin(plugin));
}
renderWithProviders(
diff --git a/frontend/src/metabase/collections/components/CreateCollectionForm/tests/enterprise.unit.spec.tsx b/frontend/src/metabase/collections/components/CreateCollectionForm/tests/enterprise.unit.spec.tsx
index c65b4a902a7..e2451d7661c 100644
--- a/frontend/src/metabase/collections/components/CreateCollectionForm/tests/enterprise.unit.spec.tsx
+++ b/frontend/src/metabase/collections/components/CreateCollectionForm/tests/enterprise.unit.spec.tsx
@@ -1,18 +1,10 @@
import { screen } from "__support__/ui";
-import type { SetupOpts } from "./setup";
import { setup } from "./setup";
-const setupEnterprise = (opts?: SetupOpts) => {
- setup({
- ...opts,
- hasEnterprisePlugins: true,
- });
-};
-
describe("CreateCollectionForm", () => {
it("does not show authority level controls", () => {
- setupEnterprise();
+ setup();
expect(screen.queryByText("Collection type")).not.toBeInTheDocument();
});
});
diff --git a/frontend/src/metabase/collections/components/CreateCollectionForm/tests/premium.unit.spec.tsx b/frontend/src/metabase/collections/components/CreateCollectionForm/tests/premium.unit.spec.tsx
index 3378b1e0a0b..f31f0a3f230 100644
--- a/frontend/src/metabase/collections/components/CreateCollectionForm/tests/premium.unit.spec.tsx
+++ b/frontend/src/metabase/collections/components/CreateCollectionForm/tests/premium.unit.spec.tsx
@@ -11,7 +11,7 @@ const setupPremium = (opts?: SetupOpts) => {
setup({
...opts,
tokenFeatures: createMockTokenFeatures({ official_collections: true }),
- hasEnterprisePlugins: true,
+ enterprisePlugins: ["collections"],
});
};
diff --git a/frontend/src/metabase/collections/components/CreateCollectionForm/tests/setup.tsx b/frontend/src/metabase/collections/components/CreateCollectionForm/tests/setup.tsx
index 541fa1b8c47..1e3d4587064 100644
--- a/frontend/src/metabase/collections/components/CreateCollectionForm/tests/setup.tsx
+++ b/frontend/src/metabase/collections/components/CreateCollectionForm/tests/setup.tsx
@@ -1,5 +1,5 @@
/* istanbul ignore file */
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import { setupCollectionsEndpoints } from "__support__/server-mocks";
import { mockSettings } from "__support__/settings";
import { createMockEntitiesState } from "__support__/store";
@@ -23,21 +23,21 @@ const ROOT_COLLECTION = createMockCollection({
export interface SetupOpts {
user?: User;
tokenFeatures?: TokenFeatures;
- hasEnterprisePlugins?: boolean;
showAuthorityLevelPicker?: boolean;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
}
export const setup = ({
user = createMockUser({ is_superuser: true }),
tokenFeatures = createMockTokenFeatures(),
- hasEnterprisePlugins = false,
showAuthorityLevelPicker,
+ enterprisePlugins,
}: SetupOpts = {}) => {
const settings = mockSettings({ "token-features": tokenFeatures });
const onCancel = jest.fn();
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
+ if (enterprisePlugins) {
+ enterprisePlugins.forEach(setupEnterpriseOnlyPlugin);
}
setupCollectionsEndpoints({
collections: [],
diff --git a/frontend/src/metabase/collections/components/PinnedItemCard/PinnedItemCard-ee.unit.spec.tsx b/frontend/src/metabase/collections/components/PinnedItemCard/PinnedItemCard-ee.unit.spec.tsx
index 84fb532915d..0ab29d3e556 100644
--- a/frontend/src/metabase/collections/components/PinnedItemCard/PinnedItemCard-ee.unit.spec.tsx
+++ b/frontend/src/metabase/collections/components/PinnedItemCard/PinnedItemCard-ee.unit.spec.tsx
@@ -1,6 +1,6 @@
import { Route } from "react-router";
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import { mockSettings } from "__support__/settings";
import { renderWithProviders, screen } from "__support__/ui";
import type { Collection, CollectionItem } from "metabase-types/api";
@@ -35,7 +35,8 @@ function setup({
}),
});
- setupEnterprisePlugins();
+ setupEnterpriseOnlyPlugin("content_verification");
+ setupEnterpriseOnlyPlugin("moderation");
return renderWithProviders(
<Route
diff --git a/frontend/src/metabase/common/components/EntityPicker/components/ResultItem/ResultItem.unit.spec.tsx b/frontend/src/metabase/common/components/EntityPicker/components/ResultItem/ResultItem.unit.spec.tsx
index cd857e32671..0c162682ff2 100644
--- a/frontend/src/metabase/common/components/EntityPicker/components/ResultItem/ResultItem.unit.spec.tsx
+++ b/frontend/src/metabase/common/components/EntityPicker/components/ResultItem/ResultItem.unit.spec.tsx
@@ -1,4 +1,4 @@
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import { mockSettings } from "__support__/settings";
import {
getIcon,
@@ -41,7 +41,8 @@ function setup({
settings: mockSettings(settingValuesWithToken),
});
- setupEnterprisePlugins();
+ setupEnterpriseOnlyPlugin("collections");
+ setupEnterpriseOnlyPlugin("moderation");
return renderWithProviders(
<ResultItem item={item} isSelected={isSelected} onClick={onClick} />,
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 746ab0bc2db..264435c6bd8 100644
--- a/frontend/src/metabase/common/components/SaveQuestionForm/context.unit.spec.tsx
+++ b/frontend/src/metabase/common/components/SaveQuestionForm/context.unit.spec.tsx
@@ -1,4 +1,4 @@
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import {
defaultAuditInfo,
setupAuditInfoEndpoint,
@@ -63,7 +63,8 @@ const setup = ({
}),
});
- setupEnterprisePlugins();
+ setupEnterpriseOnlyPlugin("audit_app");
+ setupEnterpriseOnlyPlugin("collections");
renderWithProviders(
<SaveQuestionProvider
diff --git a/frontend/src/metabase/common/components/Schedule/test-utils.tsx b/frontend/src/metabase/common/components/Schedule/test-utils.tsx
index f1bd725f662..494419a97f1 100644
--- a/frontend/src/metabase/common/components/Schedule/test-utils.tsx
+++ b/frontend/src/metabase/common/components/Schedule/test-utils.tsx
@@ -1,4 +1,4 @@
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import { mockSettings } from "__support__/settings";
import { createMockEntitiesState } from "__support__/store";
import { renderWithProviders } from "__support__/ui";
@@ -12,7 +12,7 @@ import { createMockState } from "metabase-types/store/mocks";
import type { ScheduleProps } from "./Schedule";
import { Schedule } from "./Schedule";
export interface SetupOpts {
- hasEnterprisePlugins?: boolean;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
tokenFeatures?: Partial<TokenFeatures>;
}
@@ -29,7 +29,7 @@ const mockTimezone = "America/New_York";
const mockOnScheduleChange = jest.fn();
export const setup = ({
- hasEnterprisePlugins,
+ enterprisePlugins,
tokenFeatures = {},
...props
}: SetupOpts & Partial<ScheduleProps> = {}) => {
@@ -42,8 +42,8 @@ export const setup = ({
),
});
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
+ if (enterprisePlugins) {
+ enterprisePlugins.forEach(setupEnterpriseOnlyPlugin);
}
const propsWithDefaults = {
diff --git a/frontend/src/metabase/common/components/TitleAndDescription/i18n-tests/premium.unit.spec.tsx b/frontend/src/metabase/common/components/TitleAndDescription/i18n-tests/premium.unit.spec.tsx
index 8602f138e2d..1b974ce3079 100644
--- a/frontend/src/metabase/common/components/TitleAndDescription/i18n-tests/premium.unit.spec.tsx
+++ b/frontend/src/metabase/common/components/TitleAndDescription/i18n-tests/premium.unit.spec.tsx
@@ -11,7 +11,7 @@ describe("TitleAndDescription component", () => {
it("displays translated question title and description", async () => {
setup({
- hasEnterprisePlugins: true,
+ enterprisePlugins: ["content_translation"],
tokenFeatures: { content_translation: true },
staticallyEmbedded: true,
dictionary: [
diff --git a/frontend/src/metabase/dashboard/components/DashCard/DashCardParameterMapper/DisabledNativeCardHelpText/tests/enterprise.unit.spec.ts b/frontend/src/metabase/dashboard/components/DashCard/DashCardParameterMapper/DisabledNativeCardHelpText/tests/enterprise.unit.spec.ts
index 4bf9aa8d7e5..0341af57817 100644
--- a/frontend/src/metabase/dashboard/components/DashCard/DashCardParameterMapper/DisabledNativeCardHelpText/tests/enterprise.unit.spec.ts
+++ b/frontend/src/metabase/dashboard/components/DashCard/DashCardParameterMapper/DisabledNativeCardHelpText/tests/enterprise.unit.spec.ts
@@ -4,7 +4,7 @@ import type { SetupOpts } from "./setup";
import { setup as baseSetup } from "./setup";
function setup(opts: SetupOpts) {
- baseSetup({ hasEnterprisePlugins: true, ...opts });
+ baseSetup({ ...opts });
}
describe("DashCardParameterMapper > DisabledNativeCardHelpText (EE without token)", () => {
diff --git a/frontend/src/metabase/dashboard/components/DashCard/DashCardParameterMapper/DisabledNativeCardHelpText/tests/premium.unit.spec.ts b/frontend/src/metabase/dashboard/components/DashCard/DashCardParameterMapper/DisabledNativeCardHelpText/tests/premium.unit.spec.ts
index cee3fef7700..101c9fd433c 100644
--- a/frontend/src/metabase/dashboard/components/DashCard/DashCardParameterMapper/DisabledNativeCardHelpText/tests/premium.unit.spec.ts
+++ b/frontend/src/metabase/dashboard/components/DashCard/DashCardParameterMapper/DisabledNativeCardHelpText/tests/premium.unit.spec.ts
@@ -5,8 +5,8 @@ import { setup as baseSetup } from "./setup";
function setup(opts: SetupOpts) {
baseSetup({
- hasEnterprisePlugins: true,
tokenFeatures: { whitelabel: true },
+ enterprisePlugins: ["whitelabel"],
...opts,
});
}
diff --git a/frontend/src/metabase/dashboard/components/DashCard/DashCardParameterMapper/DisabledNativeCardHelpText/tests/setup.tsx b/frontend/src/metabase/dashboard/components/DashCard/DashCardParameterMapper/DisabledNativeCardHelpText/tests/setup.tsx
index 5468fa50730..ace8a68192d 100644
--- a/frontend/src/metabase/dashboard/components/DashCard/DashCardParameterMapper/DisabledNativeCardHelpText/tests/setup.tsx
+++ b/frontend/src/metabase/dashboard/components/DashCard/DashCardParameterMapper/DisabledNativeCardHelpText/tests/setup.tsx
@@ -1,4 +1,4 @@
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import { mockSettings } from "__support__/settings";
import { renderWithProviders } from "__support__/ui";
import { SAMPLE_METADATA } from "metabase-lib/test-helpers";
@@ -18,16 +18,16 @@ export interface SetupOpts {
cardType?: CardType;
isModel?: boolean;
showMetabaseLinks?: boolean;
- hasEnterprisePlugins?: boolean;
tokenFeatures?: Partial<TokenFeatures>;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
}
export const setup = ({
parameter = createMockParameter(),
cardType = "question",
showMetabaseLinks = true,
- hasEnterprisePlugins,
tokenFeatures = {},
+ enterprisePlugins = [],
}: SetupOpts = {}) => {
const state = createMockState({
settings: mockSettings({
@@ -40,9 +40,9 @@ export const setup = ({
SAMPLE_METADATA,
);
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
- }
+ enterprisePlugins.forEach((plugin) => {
+ setupEnterpriseOnlyPlugin(plugin);
+ });
renderWithProviders(
<DisabledNativeCardHelpText question={question} parameter={parameter} />,
diff --git a/frontend/src/metabase/dashboard/components/DashboardHeader/tests/enterprise.unit.spec.ts b/frontend/src/metabase/dashboard/components/DashboardHeader/tests/enterprise.unit.spec.ts
index 047f963738a..ca52ea79096 100644
--- a/frontend/src/metabase/dashboard/components/DashboardHeader/tests/enterprise.unit.spec.ts
+++ b/frontend/src/metabase/dashboard/components/DashboardHeader/tests/enterprise.unit.spec.ts
@@ -9,8 +9,8 @@ import { setup } from "./setup";
const setupEnterprise = (opts: any) => {
return setup({
...opts,
- hasEnterprisePlugins: true,
tokenFeatures: { audit_app: true },
+ enterprisePlugins: ["audit_app", "database_routing", "collections"],
});
};
@@ -39,7 +39,7 @@ describe("DashboardHeader - enterprise", () => {
).toBeInTheDocument();
expect(screen.getByText("Make a copy")).toBeInTheDocument();
- //Other buttons
+ // Other buttons
expect(
screen.getByRole("button", { name: /bookmark/i }),
).toBeInTheDocument();
diff --git a/frontend/src/metabase/dashboard/components/DashboardHeader/tests/setup.tsx b/frontend/src/metabase/dashboard/components/DashboardHeader/tests/setup.tsx
index 932427f9494..3ffd7fc6a16 100644
--- a/frontend/src/metabase/dashboard/components/DashboardHeader/tests/setup.tsx
+++ b/frontend/src/metabase/dashboard/components/DashboardHeader/tests/setup.tsx
@@ -1,6 +1,6 @@
import { Route } from "react-router";
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import {
setupBookmarksEndpoints,
setupCollectionByIdEndpoint,
@@ -12,6 +12,7 @@ import { renderWithProviders, waitForLoaderToBeRemoved } from "__support__/ui";
import { getDefaultTab } from "metabase/dashboard/actions";
import { DASHBOARD_APP_ACTIONS } from "metabase/dashboard/containers/DashboardApp/DashboardApp";
import { MockDashboardContext } from "metabase/public/containers/PublicOrEmbeddedDashboard/mock-context";
+import type { Collection, TokenFeatures } from "metabase-types/api";
import {
createMockDashboard,
createMockDashboardCard,
@@ -45,8 +46,16 @@ export const setup = async ({
email = false,
slack = false,
collections = [],
- hasEnterprisePlugins = false,
+ enterprisePlugins,
tokenFeatures = {},
+}: {
+ dashboard?: typeof TEST_DASHBOARD;
+ isAdmin?: boolean;
+ email?: boolean;
+ slack?: boolean;
+ collections?: Collection[];
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
+ tokenFeatures?: Partial<TokenFeatures>;
}) => {
setupCollectionsEndpoints({ collections });
setupCollectionByIdEndpoint({ collections });
@@ -56,8 +65,10 @@ export const setup = async ({
"token-features": createMockTokenFeatures(tokenFeatures),
});
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
+ if (enterprisePlugins) {
+ enterprisePlugins.forEach((plugin) => {
+ setupEnterpriseOnlyPlugin(plugin);
+ });
}
const channelData: {
diff --git a/frontend/src/metabase/dashboard/components/DashboardInfoSidebar/DashboardEntityIdCard/tests/enterprise.unit.spec.tsx b/frontend/src/metabase/dashboard/components/DashboardInfoSidebar/DashboardEntityIdCard/tests/enterprise.unit.spec.tsx
index 22866923209..f6e9d9b02ab 100644
--- a/frontend/src/metabase/dashboard/components/DashboardInfoSidebar/DashboardEntityIdCard/tests/enterprise.unit.spec.tsx
+++ b/frontend/src/metabase/dashboard/components/DashboardInfoSidebar/DashboardEntityIdCard/tests/enterprise.unit.spec.tsx
@@ -4,7 +4,7 @@ import { setup } from "./setup";
describe("DashboardEntityIdCard (EE without token)", () => {
it("should return null", async () => {
- setup({ hasEnterprisePlugins: true });
+ setup();
expect(screen.queryByRole("heading")).not.toBeInTheDocument();
});
});
diff --git a/frontend/src/metabase/dashboard/components/DashboardInfoSidebar/DashboardEntityIdCard/tests/setup.tsx b/frontend/src/metabase/dashboard/components/DashboardInfoSidebar/DashboardEntityIdCard/tests/setup.tsx
index 4682f6719df..2a29f8af914 100644
--- a/frontend/src/metabase/dashboard/components/DashboardInfoSidebar/DashboardEntityIdCard/tests/setup.tsx
+++ b/frontend/src/metabase/dashboard/components/DashboardInfoSidebar/DashboardEntityIdCard/tests/setup.tsx
@@ -1,4 +1,4 @@
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import { mockSettings } from "__support__/settings";
import {
type RenderWithProvidersOptions,
@@ -15,12 +15,12 @@ import { DashboardEntityIdCard } from "../DashboardEntityIdCard";
export const setup = ({
dashboard = createMockDashboard(),
- hasEnterprisePlugins,
+ enterprisePlugins,
enableSerialization = false,
...renderOptions
}: {
dashboard?: Dashboard;
- hasEnterprisePlugins?: boolean;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
enableSerialization?: boolean;
} & RenderWithProvidersOptions = {}) => {
const state = createMockState({
@@ -30,8 +30,8 @@ export const setup = ({
}),
}),
});
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
+ if (enterprisePlugins) {
+ enterprisePlugins.forEach(setupEnterpriseOnlyPlugin);
}
return renderWithProviders(<DashboardEntityIdCard dashboard={dashboard} />, {
...renderOptions,
diff --git a/frontend/src/metabase/dashboard/components/DashboardInfoSidebar/tests/enterprise.unit.spec.ts b/frontend/src/metabase/dashboard/components/DashboardInfoSidebar/tests/enterprise.unit.spec.ts
index ce5e6c66e2f..cb45062c851 100644
--- a/frontend/src/metabase/dashboard/components/DashboardInfoSidebar/tests/enterprise.unit.spec.ts
+++ b/frontend/src/metabase/dashboard/components/DashboardInfoSidebar/tests/enterprise.unit.spec.ts
@@ -8,7 +8,6 @@ import { setup } from "./setup";
const setupEnterprise = (opts: SetupOpts) => {
return setup({
...opts,
- hasEnterprisePlugins: true,
});
};
diff --git a/frontend/src/metabase/dashboard/components/DashboardInfoSidebar/tests/premium.unit.spec.ts b/frontend/src/metabase/dashboard/components/DashboardInfoSidebar/tests/premium.unit.spec.ts
index 93b945325dd..1fef1e043fd 100644
--- a/frontend/src/metabase/dashboard/components/DashboardInfoSidebar/tests/premium.unit.spec.ts
+++ b/frontend/src/metabase/dashboard/components/DashboardInfoSidebar/tests/premium.unit.spec.ts
@@ -20,7 +20,7 @@ const setupEnterprise = (opts: SetupOpts) => {
audit_app: true,
}),
}),
- hasEnterprisePlugins: true,
+ enterprisePlugins: ["collections"],
});
};
diff --git a/frontend/src/metabase/dashboard/components/DashboardInfoSidebar/tests/setup.tsx b/frontend/src/metabase/dashboard/components/DashboardInfoSidebar/tests/setup.tsx
index 8cc5a42716f..daea35e523d 100644
--- a/frontend/src/metabase/dashboard/components/DashboardInfoSidebar/tests/setup.tsx
+++ b/frontend/src/metabase/dashboard/components/DashboardInfoSidebar/tests/setup.tsx
@@ -1,6 +1,6 @@
import { Route } from "react-router";
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import {
setupAuditInfoEndpoint,
setupDashboardEndpoints,
@@ -27,13 +27,13 @@ import { DashboardInfoSidebar } from "../DashboardInfoSidebar";
export interface SetupOpts {
dashboard?: Dashboard;
settings?: Settings;
- hasEnterprisePlugins?: boolean;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
}
export async function setup({
dashboard = createMockDashboard(),
settings = createMockSettings(),
- hasEnterprisePlugins,
+ enterprisePlugins = [],
}: SetupOpts = {}) {
const setDashboardAttribute = jest.fn();
const onClose = jest.fn();
@@ -59,9 +59,9 @@ export async function setup({
}),
});
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
- }
+ enterprisePlugins.forEach((plugin) => {
+ setupEnterpriseOnlyPlugin(plugin);
+ });
renderWithProviders(
<Route
@@ -99,6 +99,5 @@ export const setupEnterprise = (
...tokenFeatures,
}),
}),
- hasEnterprisePlugins: true,
});
};
diff --git a/frontend/src/metabase/dashboard/components/DashboardSettingsSidebar/tests/enterprise.unit.spec.ts b/frontend/src/metabase/dashboard/components/DashboardSettingsSidebar/tests/enterprise.unit.spec.ts
index c18a63a3d97..aa21a83565c 100644
--- a/frontend/src/metabase/dashboard/components/DashboardSettingsSidebar/tests/enterprise.unit.spec.ts
+++ b/frontend/src/metabase/dashboard/components/DashboardSettingsSidebar/tests/enterprise.unit.spec.ts
@@ -1,17 +1,17 @@
import { screen } from "__support__/ui";
-import { setupEnterprise } from "./setup";
+import { setup } from "./setup";
describe("DashboardSettingsSidebar > enterprise", () => {
it("should render the component", async () => {
- await setupEnterprise();
+ await setup();
expect(screen.getByText("Dashboard settings")).toBeInTheDocument();
expect(screen.getByTestId("sidesheet")).toBeInTheDocument();
});
it("should not render caching section without caching feature", async () => {
- await setupEnterprise({}, { cache_granular_controls: false });
+ await setup();
expect(screen.queryByText("Caching")).not.toBeInTheDocument();
});
diff --git a/frontend/src/metabase/dashboard/components/DashboardSettingsSidebar/tests/premium.unit.spec.ts b/frontend/src/metabase/dashboard/components/DashboardSettingsSidebar/tests/premium.unit.spec.ts
index 2df4032a15d..db76566d439 100644
--- a/frontend/src/metabase/dashboard/components/DashboardSettingsSidebar/tests/premium.unit.spec.ts
+++ b/frontend/src/metabase/dashboard/components/DashboardSettingsSidebar/tests/premium.unit.spec.ts
@@ -4,9 +4,11 @@ import { screen } from "__support__/ui";
import {
createMockCollection,
createMockDashboard,
+ createMockSettings,
+ createMockTokenFeatures,
} from "metabase-types/api/mocks";
-import { setupEnterprise } from "./setup";
+import { setup } from "./setup";
const tokenFeatures = {
cache_granular_controls: true,
@@ -15,14 +17,24 @@ const tokenFeatures = {
describe("DashboardSettingsSidebar > premium enterprise", () => {
it("should render the component", async () => {
- await setupEnterprise({}, tokenFeatures);
+ await setup({
+ settings: createMockSettings({
+ "token-features": createMockTokenFeatures(tokenFeatures),
+ }),
+ enterprisePlugins: ["audit_app", "caching"],
+ });
expect(screen.getByText("Dashboard settings")).toBeInTheDocument();
expect(screen.getByTestId("sidesheet")).toBeInTheDocument();
});
it("should render caching section with caching feature", async () => {
- await setupEnterprise({}, tokenFeatures);
+ await setup({
+ settings: createMockSettings({
+ "token-features": createMockTokenFeatures(tokenFeatures),
+ }),
+ enterprisePlugins: ["audit_app", "caching"],
+ });
expect(await screen.findByText("Caching")).toBeInTheDocument();
expect(
@@ -31,7 +43,12 @@ describe("DashboardSettingsSidebar > premium enterprise", () => {
});
it("should show cache form when clicking on caching section", async () => {
- await setupEnterprise({}, tokenFeatures);
+ await setup({
+ settings: createMockSettings({
+ "token-features": createMockTokenFeatures(tokenFeatures),
+ }),
+ enterprisePlugins: ["audit_app", "caching"],
+ });
await userEvent.click(await screen.findByText("Use default"));
@@ -39,14 +56,15 @@ describe("DashboardSettingsSidebar > premium enterprise", () => {
});
it("should hide history for instance analytics dashboard", async () => {
- await setupEnterprise(
- {
- dashboard: createMockDashboard({
- collection: createMockCollection({ type: "instance-analytics" }),
- }),
- },
- tokenFeatures,
- );
+ await setup({
+ dashboard: createMockDashboard({
+ collection: createMockCollection({ type: "instance-analytics" }),
+ }),
+ settings: createMockSettings({
+ "token-features": createMockTokenFeatures(tokenFeatures),
+ }),
+ enterprisePlugins: ["audit_app", "caching"],
+ });
expect(screen.queryByText("History")).not.toBeInTheDocument();
});
diff --git a/frontend/src/metabase/dashboard/components/DashboardSettingsSidebar/tests/setup.tsx b/frontend/src/metabase/dashboard/components/DashboardSettingsSidebar/tests/setup.tsx
index 92c56b1f44e..bd4a5b889df 100644
--- a/frontend/src/metabase/dashboard/components/DashboardSettingsSidebar/tests/setup.tsx
+++ b/frontend/src/metabase/dashboard/components/DashboardSettingsSidebar/tests/setup.tsx
@@ -1,6 +1,6 @@
import { Route } from "react-router";
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import {
setupDashboardEndpoints,
setupPerformanceEndpoints,
@@ -11,7 +11,7 @@ import { mockSettings } from "__support__/settings";
import { createMockEntitiesState } from "__support__/store";
import { renderWithProviders, waitForLoaderToBeRemoved } from "__support__/ui";
import { MockDashboardContext } from "metabase/public/containers/PublicOrEmbeddedDashboard/mock-context";
-import type { Dashboard, Settings, TokenFeatures } from "metabase-types/api";
+import type { Dashboard, Settings } from "metabase-types/api";
import {
createMockDashboard,
createMockSettings,
@@ -26,13 +26,13 @@ import { DashboardSettingsSidebar } from "../DashboardSettingsSidebar";
export interface SetupOpts {
dashboard?: Dashboard;
settings?: Settings;
- hasEnterprisePlugins?: boolean;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
}
export async function setup({
dashboard = createMockDashboard(),
settings = createMockSettings(),
- hasEnterprisePlugins,
+ enterprisePlugins = [],
}: SetupOpts = {}) {
const setDashboardAttribute = jest.fn();
const onClose = jest.fn();
@@ -57,9 +57,9 @@ export async function setup({
}),
});
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
- }
+ enterprisePlugins.forEach((plugin) => {
+ setupEnterpriseOnlyPlugin(plugin);
+ });
const TestDashboardSettingsSidebar = () => (
<MockDashboardContext dashboard={dashboard} closeSidebar={onClose}>
@@ -79,19 +79,3 @@ export async function setup({
onClose,
};
}
-
-export const setupEnterprise = (
- opts: SetupOpts = {},
- tokenFeatures: Partial<TokenFeatures> = {},
-) => {
- return setup({
- ...opts,
- settings: createMockSettings({
- ...opts.settings,
- "token-features": createMockTokenFeatures({
- ...tokenFeatures,
- }),
- }),
- hasEnterprisePlugins: true,
- });
-};
diff --git a/frontend/src/metabase/databases/components/DatabaseForm/tests/setup.tsx b/frontend/src/metabase/databases/components/DatabaseForm/tests/setup.tsx
index b15b4d250c6..f0dab7c7ddc 100644
--- a/frontend/src/metabase/databases/components/DatabaseForm/tests/setup.tsx
+++ b/frontend/src/metabase/databases/components/DatabaseForm/tests/setup.tsx
@@ -1,4 +1,4 @@
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import { mockSettings } from "__support__/settings";
import { renderWithProviders } from "__support__/ui";
import type {
@@ -99,7 +99,7 @@ export const TEST_ENGINES: Record<string, Engine> = {
export interface SetupOpts {
settings?: Settings;
- hasEnterprisePlugins?: boolean;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
engines?: Record<string, Engine>;
initialValues?: Partial<DatabaseData> & { engine?: EngineKey };
isAdvanced?: boolean;
@@ -107,7 +107,7 @@ export interface SetupOpts {
export const setup = ({
settings,
- hasEnterprisePlugins,
+ enterprisePlugins,
engines = TEST_ENGINES,
initialValues = {},
isAdvanced = true,
@@ -116,8 +116,10 @@ export const setup = ({
settings: mockSettings({ ...settings, engines }),
});
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
+ if (enterprisePlugins) {
+ enterprisePlugins.forEach((plugin) => {
+ setupEnterpriseOnlyPlugin(plugin);
+ });
}
const onSubmit = jest.fn();
diff --git a/frontend/src/metabase/embedding/components/SharingMenu/test/setup.tsx b/frontend/src/metabase/embedding/components/SharingMenu/test/setup.tsx
index 39985787400..70ce026886e 100644
--- a/frontend/src/metabase/embedding/components/SharingMenu/test/setup.tsx
+++ b/frontend/src/metabase/embedding/components/SharingMenu/test/setup.tsx
@@ -2,7 +2,7 @@
import userEvent from "@testing-library/user-event";
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import {
setupNotificationChannelsEndpoints,
setupUserRecipientsEndpoint,
@@ -136,7 +136,9 @@ export function setupDashboardSharingMenu({
});
if (isEnterprise) {
- setupEnterprisePlugins();
+ setupEnterpriseOnlyPlugin("audit_app");
+ setupEnterpriseOnlyPlugin("application_permissions");
+ setupEnterpriseOnlyPlugin("collections");
}
renderWithProviders(
@@ -191,7 +193,9 @@ export function setupQuestionSharingMenu({
setupWebhookChannelsEndpoint();
if (isEnterprise) {
- setupEnterprisePlugins();
+ setupEnterpriseOnlyPlugin("audit_app");
+ setupEnterpriseOnlyPlugin("application_permissions");
+ setupEnterpriseOnlyPlugin("collections");
}
renderWithProviders(
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/tests/test-setup.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/tests/test-setup.tsx
index 3a2c80e33f6..6492f5b9b53 100644
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/tests/test-setup.tsx
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/components/tests/test-setup.tsx
@@ -1,4 +1,4 @@
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import {
findRequests,
setupDashboardEndpoints,
@@ -24,21 +24,23 @@ import { createMockState } from "metabase-types/store/mocks";
import { SdkIframeEmbedSetupModal } from "../SdkIframeEmbedSetupModal";
export const setup = (options?: {
- hasEnterprisePlugins?: boolean;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
simpleEmbeddingEnabled?: boolean;
showSimpleEmbedTerms?: boolean;
jwtReady?: boolean;
initialState?: SdkIframeEmbedSetupModalInitialState;
}) => {
- const { hasEnterprisePlugins = true } = options ?? {};
+ const { enterprisePlugins } = options ?? {};
const mockDatabase = createMockDatabase();
const mockDashboard = createMockDashboard({
enable_embedding: true,
});
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
+ if (enterprisePlugins) {
+ enterprisePlugins.forEach((plugin) => {
+ setupEnterpriseOnlyPlugin(plugin);
+ });
}
const tokenFeatures = createMockTokenFeatures({
diff --git a/frontend/src/metabase/entities/collections/utils.unit.spec.ts b/frontend/src/metabase/entities/collections/utils.unit.spec.ts
index f69dacd9b47..065c9e4319b 100644
--- a/frontend/src/metabase/entities/collections/utils.unit.spec.ts
+++ b/frontend/src/metabase/entities/collections/utils.unit.spec.ts
@@ -1,4 +1,4 @@
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import { mockSettings } from "__support__/settings";
import {
createMockCollection,
@@ -317,7 +317,7 @@ describe("entities > collections > utils", () => {
audit_app: true,
}),
});
- setupEnterprisePlugins();
+ setupEnterpriseOnlyPlugin("collections");
});
it("returns correct icon for official collections", () => {
@@ -402,7 +402,7 @@ describe("entities > collections > utils", () => {
audit_app: true,
}),
});
- setupEnterprisePlugins();
+ setupEnterpriseOnlyPlugin("collections");
});
testCasesEE.forEach((testCase) => {
diff --git a/frontend/src/metabase/home/components/EmbedHomepage/tests/setup.tsx b/frontend/src/metabase/home/components/EmbedHomepage/tests/setup.tsx
index 8a0057d07a3..dd29122340b 100644
--- a/frontend/src/metabase/home/components/EmbedHomepage/tests/setup.tsx
+++ b/frontend/src/metabase/home/components/EmbedHomepage/tests/setup.tsx
@@ -1,7 +1,7 @@
import fetchMock from "fetch-mock";
import { Route } from "react-router";
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import {
setupPropertiesEndpoints,
setupSettingsEndpoints,
@@ -22,14 +22,14 @@ import { EmbedHomepage } from "../EmbedHomepage";
export interface SetupOpts {
tokenFeatures?: Partial<TokenFeatures>;
- hasEnterprisePlugins?: boolean;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
settings?: Partial<Settings>;
isAdmin?: boolean;
}
export async function setup({
tokenFeatures = createMockTokenFeatures(),
- hasEnterprisePlugins = false,
+ enterprisePlugins,
settings = {},
isAdmin = false,
}: SetupOpts = {}) {
@@ -48,8 +48,10 @@ export async function setup({
}),
});
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
+ if (enterprisePlugins) {
+ enterprisePlugins.forEach((plugin) => {
+ setupEnterpriseOnlyPlugin(plugin);
+ });
}
renderWithProviders(
diff --git a/frontend/src/metabase/home/components/HomeHelpCard/tests/enterprise.unit.spec.tsx b/frontend/src/metabase/home/components/HomeHelpCard/tests/enterprise.unit.spec.tsx
index a5541836b90..45c85996288 100644
--- a/frontend/src/metabase/home/components/HomeHelpCard/tests/enterprise.unit.spec.tsx
+++ b/frontend/src/metabase/home/components/HomeHelpCard/tests/enterprise.unit.spec.tsx
@@ -4,7 +4,7 @@ import type { SetupOpts } from "./setup";
import { setup as baseSetup } from "./setup";
function setup(opts: SetupOpts = {}) {
- return baseSetup({ hasEnterprisePlugins: true, ...opts });
+ return baseSetup({ ...opts });
}
describe("HomeHelpCard (EE without token)", () => {
diff --git a/frontend/src/metabase/home/components/HomeHelpCard/tests/premium.unit.spec.tsx b/frontend/src/metabase/home/components/HomeHelpCard/tests/premium.unit.spec.tsx
index 3aecc4a9485..0ce532a54a0 100644
--- a/frontend/src/metabase/home/components/HomeHelpCard/tests/premium.unit.spec.tsx
+++ b/frontend/src/metabase/home/components/HomeHelpCard/tests/premium.unit.spec.tsx
@@ -5,9 +5,9 @@ import { setup as baseSetup } from "./setup";
function setup(opts: SetupOpts = {}) {
return baseSetup({
- hasEnterprisePlugins: true,
...opts,
tokenFeatures: { whitelabel: true },
+ enterprisePlugins: ["whitelabel"],
});
}
diff --git a/frontend/src/metabase/home/components/HomeHelpCard/tests/setup.tsx b/frontend/src/metabase/home/components/HomeHelpCard/tests/setup.tsx
index 9eabcd968b2..b9d8bdd6d3e 100644
--- a/frontend/src/metabase/home/components/HomeHelpCard/tests/setup.tsx
+++ b/frontend/src/metabase/home/components/HomeHelpCard/tests/setup.tsx
@@ -1,4 +1,4 @@
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import { mockSettings } from "__support__/settings";
import { renderWithProviders } from "__support__/ui";
import type { TokenFeatures } from "metabase-types/api";
@@ -10,15 +10,15 @@ import { HomeHelpCard } from "../HomeHelpCard";
export interface SetupOpts {
applicationName?: string;
showMetabaseLinks?: boolean;
- hasEnterprisePlugins?: boolean;
tokenFeatures?: Partial<TokenFeatures>;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
}
export const setup = ({
applicationName = "Metabase",
showMetabaseLinks = true,
- hasEnterprisePlugins,
tokenFeatures = {},
+ enterprisePlugins = [],
}: SetupOpts = {}) => {
const state = createMockState({
settings: mockSettings({
@@ -28,9 +28,9 @@ export const setup = ({
}),
});
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
- }
+ enterprisePlugins.forEach((plugin) => {
+ setupEnterpriseOnlyPlugin(plugin);
+ });
renderWithProviders(<HomeHelpCard />, { storeInitialState: state });
};
diff --git a/frontend/src/metabase/home/components/Onboarding/tests/enterprise.unit.spec.tsx b/frontend/src/metabase/home/components/Onboarding/tests/enterprise.unit.spec.tsx
index d9aa86e5da9..ba53592c41c 100644
--- a/frontend/src/metabase/home/components/Onboarding/tests/enterprise.unit.spec.tsx
+++ b/frontend/src/metabase/home/components/Onboarding/tests/enterprise.unit.spec.tsx
@@ -4,7 +4,6 @@ import { type SetupProps, setup as baseSetup } from "./setup";
function setup(opts?: SetupProps) {
baseSetup({
- hasEnterprisePlugins: true,
...opts,
});
}
diff --git a/frontend/src/metabase/home/components/Onboarding/tests/premium.unit.spec.tsx b/frontend/src/metabase/home/components/Onboarding/tests/premium.unit.spec.tsx
index e494a957297..0aa16d6597f 100644
--- a/frontend/src/metabase/home/components/Onboarding/tests/premium.unit.spec.tsx
+++ b/frontend/src/metabase/home/components/Onboarding/tests/premium.unit.spec.tsx
@@ -4,8 +4,8 @@ import { type SetupProps, setup as baseSetup } from "./setup";
function setup(opts?: SetupProps) {
baseSetup({
- hasEnterprisePlugins: true,
tokenFeatures: { whitelabel: true },
+ enterprisePlugins: ["whitelabel"],
...opts,
});
}
diff --git a/frontend/src/metabase/home/components/Onboarding/tests/setup.tsx b/frontend/src/metabase/home/components/Onboarding/tests/setup.tsx
index ad6c59a36a8..0c3a218f10a 100644
--- a/frontend/src/metabase/home/components/Onboarding/tests/setup.tsx
+++ b/frontend/src/metabase/home/components/Onboarding/tests/setup.tsx
@@ -1,6 +1,6 @@
import { Route } from "react-router";
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import {
setupBugReportingDetailsEndpoint,
setupPropertiesEndpoints,
@@ -26,24 +26,24 @@ export type SetupProps = {
isAdmin?: boolean;
applicationName?: string;
enableXrays?: boolean;
- hasEnterprisePlugins?: boolean;
hasExampleDashboard?: boolean;
isHosted?: boolean;
openItem?: ChecklistItemValue;
showMetabaseLinks?: boolean;
tokenFeatures?: Partial<TokenFeatures>;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
};
export const setup = ({
isAdmin = true,
applicationName,
enableXrays = true,
- hasEnterprisePlugins = false,
hasExampleDashboard = true,
isHosted = false,
openItem,
showMetabaseLinks = true,
tokenFeatures = {},
+ enterprisePlugins = [],
}: SetupProps = {}) => {
const hasTokenFeatures = Object.entries(tokenFeatures).length > 0;
setupPropertiesEndpoints(createMockSettings());
@@ -68,9 +68,9 @@ export const setup = ({
}),
});
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
- }
+ enterprisePlugins.forEach((plugin) => {
+ setupEnterpriseOnlyPlugin(plugin);
+ });
renderWithProviders(
<Route path="/getting-started" component={Onboarding} />,
diff --git a/frontend/src/metabase/i18n/test-utils.ts b/frontend/src/metabase/i18n/test-utils.ts
index 933d6e24d12..d724ebd2956 100644
--- a/frontend/src/metabase/i18n/test-utils.ts
+++ b/frontend/src/metabase/i18n/test-utils.ts
@@ -1,6 +1,6 @@
import type { ReactElement } from "react";
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import { setupContentTranslationEndpoints } from "__support__/server-mocks/content-translation";
import { mockSettings } from "__support__/settings";
import { renderWithProviders } from "__support__/ui";
@@ -14,7 +14,7 @@ import { createMockState } from "metabase-types/store/mocks";
export interface ContentTranslationTestSetupOptions {
localeCode?: string;
- hasEnterprisePlugins?: boolean;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
tokenFeatures?: Partial<TokenFeatures>;
dictionary?: DictionaryArray;
staticallyEmbedded?: boolean;
@@ -22,7 +22,7 @@ export interface ContentTranslationTestSetupOptions {
export const setupForContentTranslationTest = ({
localeCode = "en",
- hasEnterprisePlugins,
+ enterprisePlugins,
tokenFeatures = {},
dictionary,
staticallyEmbedded,
@@ -35,8 +35,8 @@ export const setupForContentTranslationTest = ({
currentUser: createMockUser({ locale: localeCode }),
});
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
+ if (enterprisePlugins) {
+ enterprisePlugins.forEach(setupEnterpriseOnlyPlugin);
}
setupContentTranslationEndpoints({ dictionary });
diff --git a/frontend/src/metabase/models/containers/NewModelOptions/tests/enterprise.unit.spec.tsx b/frontend/src/metabase/models/containers/NewModelOptions/tests/enterprise.unit.spec.tsx
index a94d261fd18..ca445c316cd 100644
--- a/frontend/src/metabase/models/containers/NewModelOptions/tests/enterprise.unit.spec.tsx
+++ b/frontend/src/metabase/models/containers/NewModelOptions/tests/enterprise.unit.spec.tsx
@@ -4,7 +4,7 @@ import type { SetupOpts } from "./setup";
import { setup as baseSetup } from "./setup";
function setup(opts: SetupOpts) {
- baseSetup({ hasEnterprisePlugins: true, ...opts });
+ baseSetup({ ...opts });
}
describe("NewModelOptions (EE without token)", () => {
diff --git a/frontend/src/metabase/models/containers/NewModelOptions/tests/premium.unit.spec.tsx b/frontend/src/metabase/models/containers/NewModelOptions/tests/premium.unit.spec.tsx
index a46df254f7c..8706337f340 100644
--- a/frontend/src/metabase/models/containers/NewModelOptions/tests/premium.unit.spec.tsx
+++ b/frontend/src/metabase/models/containers/NewModelOptions/tests/premium.unit.spec.tsx
@@ -5,8 +5,8 @@ import { setup as baseSetup } from "./setup";
function setup(opts: SetupOpts) {
baseSetup({
- hasEnterprisePlugins: true,
tokenFeatures: { whitelabel: true },
+ enterprisePlugins: ["whitelabel"],
...opts,
});
}
diff --git a/frontend/src/metabase/models/containers/NewModelOptions/tests/setup.tsx b/frontend/src/metabase/models/containers/NewModelOptions/tests/setup.tsx
index 6bd0706c7aa..4e618345b91 100644
--- a/frontend/src/metabase/models/containers/NewModelOptions/tests/setup.tsx
+++ b/frontend/src/metabase/models/containers/NewModelOptions/tests/setup.tsx
@@ -1,6 +1,6 @@
import { Route } from "react-router";
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import { mockSettings } from "__support__/settings";
import { renderWithProviders } from "__support__/ui";
import type { TokenFeatures } from "metabase-types/api";
@@ -17,16 +17,16 @@ export interface SetupOpts {
canCreateQueries?: boolean;
canCreateNativeQueries?: boolean;
showMetabaseLinks?: boolean;
- hasEnterprisePlugins?: boolean;
tokenFeatures?: Partial<TokenFeatures>;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
}
export function setup({
canCreateQueries = false,
canCreateNativeQueries = false,
showMetabaseLinks = true,
- hasEnterprisePlugins,
tokenFeatures = {},
+ enterprisePlugins = [],
}: SetupOpts) {
const state = createMockState({
currentUser: createMockUser({
@@ -41,9 +41,9 @@ export function setup({
}),
});
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
- }
+ enterprisePlugins.forEach((plugin) => {
+ setupEnterpriseOnlyPlugin(plugin);
+ });
renderWithProviders(<Route path="*" component={NewModelOptions}></Route>, {
withRouter: true,
diff --git a/frontend/src/metabase/nav/containers/MainNavbar/MainNavbarContainer/AddDataModal/tests/enterprise.unit.spec.tsx b/frontend/src/metabase/nav/containers/MainNavbar/MainNavbarContainer/AddDataModal/tests/enterprise.unit.spec.tsx
index acab75b20c7..1610c599098 100644
--- a/frontend/src/metabase/nav/containers/MainNavbar/MainNavbarContainer/AddDataModal/tests/enterprise.unit.spec.tsx
+++ b/frontend/src/metabase/nav/containers/MainNavbar/MainNavbarContainer/AddDataModal/tests/enterprise.unit.spec.tsx
@@ -5,7 +5,7 @@ import { setup } from "./setup";
describe("AddDataModal (Unactivated enterprise binary)", () => {
describe("Google Sheets panel", () => {
it("should not exist on self-hosted instances", async () => {
- setup({ hasEnterprisePlugins: true, isHosted: false });
+ setup({ isHosted: false });
expect(
screen.getByRole("tab", { name: /Database$/ }),
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 21f7a43e9e9..000a502d5e1 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
@@ -1,4 +1,4 @@
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import {
setupDatabaseListEndpoint,
setupGdriveGetFolderEndpoint,
@@ -28,7 +28,7 @@ interface SetupOpts {
canUpload?: boolean;
canManageSettings?: boolean;
isHosted?: boolean;
- hasEnterprisePlugins?: boolean;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
tokenFeatures?: Partial<TokenFeatures>;
enableGoogleSheets?: boolean;
status?: GdrivePayload["status"];
@@ -42,7 +42,7 @@ export const setup = ({
canUpload = true,
canManageSettings = false,
isHosted = false,
- hasEnterprisePlugins = false,
+ enterprisePlugins,
tokenFeatures = {},
enableGoogleSheets = false,
status,
@@ -93,8 +93,10 @@ export const setup = ({
}),
});
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
+ if (enterprisePlugins) {
+ enterprisePlugins.forEach((plugin) => {
+ setupEnterpriseOnlyPlugin(plugin);
+ });
}
setupTokenStatusEndpoint({ valid: true });
@@ -119,7 +121,7 @@ export const setup = ({
export const setupAdvancedPermissions = (opts: Partial<SetupOpts>) => {
return setup({
...opts,
- hasEnterprisePlugins: true,
+ enterprisePlugins: ["application_permissions"],
tokenFeatures: { advanced_permissions: true },
});
};
@@ -128,8 +130,8 @@ export const setupHostedInstance = (opts: Partial<SetupOpts>) => {
return setup({
...opts,
isHosted: true,
- hasEnterprisePlugins: true,
tokenFeatures: { hosting: true, ...opts.tokenFeatures },
+ enterprisePlugins: ["upload_management"],
});
};
diff --git a/frontend/src/metabase/nav/containers/MainNavbar/tests/premium-whitelabel.unit.spec.tsx b/frontend/src/metabase/nav/containers/MainNavbar/tests/premium-whitelabel.unit.spec.tsx
index 4ae6b96f727..953e3cd76f6 100644
--- a/frontend/src/metabase/nav/containers/MainNavbar/tests/premium-whitelabel.unit.spec.tsx
+++ b/frontend/src/metabase/nav/containers/MainNavbar/tests/premium-whitelabel.unit.spec.tsx
@@ -5,8 +5,8 @@ import { type SetupOpts, setup } from "./setup";
function setupWhitelabelled(opts: SetupOpts) {
return setup({
- hasEnterprisePlugins: true,
hasWhitelabelToken: true,
+ enterprisePlugins: ["whitelabel"],
...opts,
});
}
diff --git a/frontend/src/metabase/nav/containers/MainNavbar/tests/setup.tsx b/frontend/src/metabase/nav/containers/MainNavbar/tests/setup.tsx
index 66947e19171..25c92c1ddbe 100644
--- a/frontend/src/metabase/nav/containers/MainNavbar/tests/setup.tsx
+++ b/frontend/src/metabase/nav/containers/MainNavbar/tests/setup.tsx
@@ -2,7 +2,7 @@ import dayjs from "dayjs";
import fetchMock from "fetch-mock";
import { Route } from "react-router";
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import {
setupCardsEndpoints,
setupCollectionByIdEndpoint,
@@ -50,7 +50,7 @@ export type SetupOpts = {
models?: ModelResult[];
canCurateRootCollection?: boolean;
instanceCreationDate?: string;
- hasEnterprisePlugins?: boolean;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
hasDWHAttached?: boolean;
isEmbeddingIframe?: boolean;
hasWhitelabelToken?: boolean;
@@ -83,7 +83,7 @@ export async function setup({
withAdditionalDatabase = true,
canCurateRootCollection = false,
instanceCreationDate = dayjs().toISOString(),
- hasEnterprisePlugins = false,
+ enterprisePlugins,
hasDWHAttached = false,
isEmbeddingIframe,
hasWhitelabelToken,
@@ -201,8 +201,10 @@ export async function setup({
}),
});
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
+ if (enterprisePlugins) {
+ enterprisePlugins.forEach((plugin) => {
+ setupEnterpriseOnlyPlugin(plugin);
+ });
}
renderWithProviders(
diff --git a/frontend/src/metabase/notifications/AddEditSidebar/CaveatMessage/tests/enterprise.unit.spec.ts b/frontend/src/metabase/notifications/AddEditSidebar/CaveatMessage/tests/enterprise.unit.spec.ts
index 35a59bae2ad..771609679f6 100644
--- a/frontend/src/metabase/notifications/AddEditSidebar/CaveatMessage/tests/enterprise.unit.spec.ts
+++ b/frontend/src/metabase/notifications/AddEditSidebar/CaveatMessage/tests/enterprise.unit.spec.ts
@@ -4,7 +4,7 @@ import type { SetupOpts } from "./setup";
import { setup as baseSetup } from "./setup";
function setup(opts: SetupOpts) {
- baseSetup({ hasEnterprisePlugins: true, ...opts });
+ baseSetup({ ...opts });
}
describe("CaveatMessage (EE without token)", () => {
diff --git a/frontend/src/metabase/notifications/AddEditSidebar/CaveatMessage/tests/premium.unit.spec.ts b/frontend/src/metabase/notifications/AddEditSidebar/CaveatMessage/tests/premium.unit.spec.ts
index 5a3ec0eba91..c24878295d1 100644
--- a/frontend/src/metabase/notifications/AddEditSidebar/CaveatMessage/tests/premium.unit.spec.ts
+++ b/frontend/src/metabase/notifications/AddEditSidebar/CaveatMessage/tests/premium.unit.spec.ts
@@ -5,8 +5,8 @@ import { setup as baseSetup } from "./setup";
function setup(opts: SetupOpts) {
baseSetup({
- hasEnterprisePlugins: true,
tokenFeatures: { whitelabel: true },
+ enterprisePlugins: ["whitelabel"],
...opts,
});
}
diff --git a/frontend/src/metabase/notifications/AddEditSidebar/CaveatMessage/tests/setup.tsx b/frontend/src/metabase/notifications/AddEditSidebar/CaveatMessage/tests/setup.tsx
index 0d78f8519dc..c7ddfe615b5 100644
--- a/frontend/src/metabase/notifications/AddEditSidebar/CaveatMessage/tests/setup.tsx
+++ b/frontend/src/metabase/notifications/AddEditSidebar/CaveatMessage/tests/setup.tsx
@@ -1,4 +1,4 @@
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import { mockSettings } from "__support__/settings";
import { renderWithProviders } from "__support__/ui";
import type { TokenFeatures } from "metabase-types/api";
@@ -9,14 +9,14 @@ import { CaveatMessage } from "../CaveatMessage";
export interface SetupOpts {
showMetabaseLinks?: boolean;
- hasEnterprisePlugins?: boolean;
tokenFeatures?: Partial<TokenFeatures>;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
}
export const setup = ({
showMetabaseLinks = true,
- hasEnterprisePlugins,
tokenFeatures = {},
+ enterprisePlugins = [],
}: SetupOpts = {}) => {
const state = createMockState({
settings: mockSettings({
@@ -25,9 +25,9 @@ export const setup = ({
}),
});
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
- }
+ enterprisePlugins.forEach((plugin) => {
+ setupEnterpriseOnlyPlugin(plugin);
+ });
renderWithProviders(<CaveatMessage />, { storeInitialState: state });
};
diff --git a/frontend/src/metabase/notifications/DashboardSubscriptionsSidebar/tests/enterprise.unit.spec.ts b/frontend/src/metabase/notifications/DashboardSubscriptionsSidebar/tests/enterprise.unit.spec.ts
index d838206b5f4..2f297a27cac 100644
--- a/frontend/src/metabase/notifications/DashboardSubscriptionsSidebar/tests/enterprise.unit.spec.ts
+++ b/frontend/src/metabase/notifications/DashboardSubscriptionsSidebar/tests/enterprise.unit.spec.ts
@@ -7,7 +7,7 @@ import { hasBasicFilterOptions, setup } from "./setup";
describe("DashboardSubscriptionsSidebar Enterprise Bundle", () => {
describe("Email Subscription sidebar", () => {
it("should not show advanced filtering options without the feature flag", async () => {
- setup({ isAdmin: true, email: true, hasEnterprisePlugins: true });
+ setup({ isAdmin: true, email: true });
await userEvent.click(await screen.findByText("Email it"));
@@ -19,7 +19,7 @@ describe("DashboardSubscriptionsSidebar Enterprise Bundle", () => {
describe("Slack Subscription sidebar", () => {
it("should not show advanced filtering options without the feature flag", async () => {
- setup({ isAdmin: true, slack: true, hasEnterprisePlugins: true });
+ setup({ isAdmin: true, slack: true });
await userEvent.click(await screen.findByText("Send it to Slack"));
diff --git a/frontend/src/metabase/notifications/DashboardSubscriptionsSidebar/tests/premium.unit.spec.ts b/frontend/src/metabase/notifications/DashboardSubscriptionsSidebar/tests/premium.unit.spec.ts
index daa45f508a3..8573c6e995d 100644
--- a/frontend/src/metabase/notifications/DashboardSubscriptionsSidebar/tests/premium.unit.spec.ts
+++ b/frontend/src/metabase/notifications/DashboardSubscriptionsSidebar/tests/premium.unit.spec.ts
@@ -31,7 +31,7 @@ describe("DashboardSubscriptionsSidebar Premium Features", () => {
isAdmin: true,
[channel]: true,
tokenFeatures,
- hasEnterprisePlugins: true,
+ enterprisePlugins: ["sharing"],
dashcards: [
createMockDashboardCard({
parameter_mappings: [],
@@ -76,7 +76,7 @@ describe("DashboardSubscriptionsSidebar Premium Features", () => {
isAdmin: true,
[channel]: true,
tokenFeatures,
- hasEnterprisePlugins: true,
+ enterprisePlugins: ["sharing"],
parameters: [totalParameter, titleParameter],
dashcards: [
createMockDashboardCard({
@@ -157,7 +157,7 @@ describe("DashboardSubscriptionsSidebar Premium Features", () => {
isAdmin: true,
[channel]: true,
tokenFeatures,
- hasEnterprisePlugins: true,
+ enterprisePlugins: ["sharing"],
parameters: [totalParameter, titleParameter],
dashcards: [
createMockDashboardCard({
diff --git a/frontend/src/metabase/notifications/DashboardSubscriptionsSidebar/tests/setup.tsx b/frontend/src/metabase/notifications/DashboardSubscriptionsSidebar/tests/setup.tsx
index 9f23cbcb81e..977f2e38e9b 100644
--- a/frontend/src/metabase/notifications/DashboardSubscriptionsSidebar/tests/setup.tsx
+++ b/frontend/src/metabase/notifications/DashboardSubscriptionsSidebar/tests/setup.tsx
@@ -1,7 +1,7 @@
/* istanbul ignore file */
import fetchMock from "fetch-mock";
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import { setupUserRecipientsEndpoint } from "__support__/server-mocks";
import { setupNotificationChannelsEndpoints } from "__support__/server-mocks/pulse";
import { mockSettings } from "__support__/settings";
@@ -85,7 +85,7 @@ type SetupOpts = {
email?: boolean;
slack?: boolean;
tokenFeatures?: Partial<TokenFeatures>;
- hasEnterprisePlugins?: boolean;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
isAdmin?: boolean;
dashcards?: DashboardCard[];
parameters?: UiParameter[];
@@ -103,7 +103,7 @@ export function setup({
email = true,
slack = true,
tokenFeatures = {},
- hasEnterprisePlugins = false,
+ enterprisePlugins,
isAdmin = false,
dashcards = defaultDashcards,
parameters = defaultParameters,
@@ -184,8 +184,10 @@ export function setup({
const features = createMockTokenFeatures(tokenFeatures);
const storeSettings = mockSettings({ "token-features": features });
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
+ if (enterprisePlugins) {
+ enterprisePlugins.forEach((plugin) => {
+ setupEnterpriseOnlyPlugin(plugin);
+ });
}
renderWithProviders(
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 736bfd77dd5..03c2236c18b 100644
--- a/frontend/src/metabase/notifications/modals/CreateOrEditQuestionAlertModal/CreateOrEditQuestionAlertModal.unit.spec.tsx
+++ b/frontend/src/metabase/notifications/modals/CreateOrEditQuestionAlertModal/CreateOrEditQuestionAlertModal.unit.spec.tsx
@@ -1,7 +1,7 @@
import userEvent from "@testing-library/user-event";
import fetchMock from "fetch-mock";
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import {
setupNotificationChannelsEndpoints,
setupUserRecipientsEndpoint,
@@ -407,7 +407,8 @@ function setup({
}),
});
- setupEnterprisePlugins();
+ setupEnterpriseOnlyPlugin("advanced_permissions");
+ setupEnterpriseOnlyPlugin("application_permissions");
const mockCard = createMockCard({
display: "line",
diff --git a/frontend/src/metabase/parameters/components/ParameterWidget/i18n-tests/premium.unit.spec.tsx b/frontend/src/metabase/parameters/components/ParameterWidget/i18n-tests/premium.unit.spec.tsx
index 321947ac90c..c258a684668 100644
--- a/frontend/src/metabase/parameters/components/ParameterWidget/i18n-tests/premium.unit.spec.tsx
+++ b/frontend/src/metabase/parameters/components/ParameterWidget/i18n-tests/premium.unit.spec.tsx
@@ -9,7 +9,7 @@ describe("ParameterWidget (EE with token, in static embedding)", () => {
it("should translate legend", async () => {
setup({
- hasEnterprisePlugins: true,
+ enterprisePlugins: ["content_translation"],
tokenFeatures: { content_translation: true },
staticallyEmbedded: true,
localeCode: "de",
diff --git a/frontend/src/metabase/parameters/components/ValuesSourceModal/tests/premium.unit.spec.tsx b/frontend/src/metabase/parameters/components/ValuesSourceModal/tests/premium.unit.spec.tsx
index 71b6fd53dbc..5fc5368bf82 100644
--- a/frontend/src/metabase/parameters/components/ValuesSourceModal/tests/premium.unit.spec.tsx
+++ b/frontend/src/metabase/parameters/components/ValuesSourceModal/tests/premium.unit.spec.tsx
@@ -11,8 +11,8 @@ import { type SetupOpts, setup as baseSetup } from "./setup";
function setup(opts: Partial<SetupOpts> = {}) {
return baseSetup({
...opts,
- hasEnterprisePlugins: true,
tokenFeatures: { whitelabel: true },
+ enterprisePlugins: ["whitelabel"],
});
}
diff --git a/frontend/src/metabase/parameters/components/ValuesSourceModal/tests/setup.tsx b/frontend/src/metabase/parameters/components/ValuesSourceModal/tests/setup.tsx
index 92ce872fa4a..e910e5f558a 100644
--- a/frontend/src/metabase/parameters/components/ValuesSourceModal/tests/setup.tsx
+++ b/frontend/src/metabase/parameters/components/ValuesSourceModal/tests/setup.tsx
@@ -1,4 +1,4 @@
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import {
setupCardsEndpoints,
setupCollectionByIdEndpoint,
@@ -38,8 +38,8 @@ export interface SetupOpts {
hasCollectionAccess?: boolean;
hasParameterValuesError?: boolean;
showMetabaseLinks?: boolean;
- hasEnterprisePlugins?: boolean;
tokenFeatures?: Partial<TokenFeatures>;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
}
export const setup = async ({
@@ -49,8 +49,8 @@ export const setup = async ({
hasCollectionAccess = true,
hasParameterValuesError = false,
showMetabaseLinks = true,
- hasEnterprisePlugins = false,
tokenFeatures = {},
+ enterprisePlugins = [],
}: SetupOpts = {}) => {
const currentUser = createMockUser();
const databases = [createMockDatabase()];
@@ -106,9 +106,9 @@ export const setup = async ({
}),
});
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
- }
+ enterprisePlugins.forEach((plugin) => {
+ setupEnterpriseOnlyPlugin(plugin);
+ });
renderWithProviders(
<ValuesSourceModal
diff --git a/frontend/src/metabase/public/components/EmbedModal/StaticEmbedSetupPane/tests/enterprise.unit.spec.tsx b/frontend/src/metabase/public/components/EmbedModal/StaticEmbedSetupPane/tests/enterprise.unit.spec.tsx
index 3f7cd9bf460..828b86c73c8 100644
--- a/frontend/src/metabase/public/components/EmbedModal/StaticEmbedSetupPane/tests/enterprise.unit.spec.tsx
+++ b/frontend/src/metabase/public/components/EmbedModal/StaticEmbedSetupPane/tests/enterprise.unit.spec.tsx
@@ -18,7 +18,7 @@ describe("Static Embed Setup phase - EE, no token", () => {
resourceType,
},
activeTab: "Look and Feel",
- hasEnterprisePlugins: true,
+ enterprisePlugins: ["whitelabel"],
});
expect(
@@ -32,7 +32,7 @@ describe("Static Embed Setup phase - EE, no token", () => {
await setup({
props: {},
activeTab: "Look and Feel",
- hasEnterprisePlugins: true,
+ enterprisePlugins: ["whitelabel"],
});
expect(screen.getByText("Removing the banner")).toBeVisible();
diff --git a/frontend/src/metabase/public/components/EmbedModal/StaticEmbedSetupPane/tests/premium.unit.spec.tsx b/frontend/src/metabase/public/components/EmbedModal/StaticEmbedSetupPane/tests/premium.unit.spec.tsx
index 65014223ccf..4d5117d8e15 100644
--- a/frontend/src/metabase/public/components/EmbedModal/StaticEmbedSetupPane/tests/premium.unit.spec.tsx
+++ b/frontend/src/metabase/public/components/EmbedModal/StaticEmbedSetupPane/tests/premium.unit.spec.tsx
@@ -21,7 +21,7 @@ describe("Static Embed Setup phase - EE, with token", () => {
resourceType,
},
activeTab: "Overview",
- hasEnterprisePlugins: true,
+ enterprisePlugins: ["whitelabel"],
tokenFeatures: createMockTokenFeatures({ whitelabel: true }),
});
@@ -45,7 +45,7 @@ describe("Static Embed Setup phase - EE, with token", () => {
resourceType,
},
activeTab: "Look and Feel",
- hasEnterprisePlugins: true,
+ enterprisePlugins: ["whitelabel"],
tokenFeatures: createMockTokenFeatures({ whitelabel: true }),
});
@@ -74,7 +74,7 @@ describe("Static Embed Setup phase - EE, with token", () => {
resourceType,
},
activeTab: "Look and Feel",
- hasEnterprisePlugins: true,
+ enterprisePlugins: ["whitelabel"],
tokenFeatures: createMockTokenFeatures({ whitelabel: true }),
});
@@ -89,7 +89,7 @@ describe("Static Embed Setup phase - EE, with token", () => {
resourceType,
},
activeTab: "Look and Feel",
- hasEnterprisePlugins: true,
+ enterprisePlugins: ["whitelabel"],
tokenFeatures: createMockTokenFeatures({ whitelabel: true }),
});
@@ -112,7 +112,7 @@ describe("Static Embed Setup phase - EE, with token", () => {
resource: getMockResource(resourceType, true),
},
activeTab: "Look and Feel",
- hasEnterprisePlugins: true,
+ enterprisePlugins: ["whitelabel"],
tokenFeatures: createMockTokenFeatures({ whitelabel: true }),
});
@@ -139,7 +139,7 @@ describe("Static Embed Setup phase - EE, with token", () => {
resource: getMockResource(resourceType, true),
},
activeTab: "Look and Feel",
- hasEnterprisePlugins: true,
+ enterprisePlugins: ["whitelabel"],
tokenFeatures: createMockTokenFeatures({ whitelabel: 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 a0a29f8e669..cfda0d362d8 100644
--- a/frontend/src/metabase/public/components/EmbedModal/StaticEmbedSetupPane/tests/setup.tsx
+++ b/frontend/src/metabase/public/components/EmbedModal/StaticEmbedSetupPane/tests/setup.tsx
@@ -1,7 +1,7 @@
import { screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import {
setupParameterValuesEndpoints,
setupTokenStatusEndpoint,
@@ -57,7 +57,7 @@ export const FONTS_MOCK_VALUES = [
export interface SetupOpts {
props: Partial<StaticEmbedSetupPaneProps>;
activeTab?: "Overview" | "Parameters" | "Appearance";
- hasEnterprisePlugins?: boolean;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
}
export async function setup({
@@ -69,33 +69,35 @@ export async function setup({
onUpdateEnableEmbedding = jest.fn(),
} = {},
activeTab = "Overview",
- hasEnterprisePlugins = false,
+ enterprisePlugins,
tokenFeatures = createMockTokenFeatures(),
}: {
props: Partial<StaticEmbedSetupPaneProps>;
activeTab?: "Overview" | "Parameters" | "Look and Feel";
- hasEnterprisePlugins?: boolean;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
tokenFeatures?: TokenFeatures;
}) {
setupParameterValuesEndpoints({
values: [],
has_more_values: false,
});
- setupTokenStatusEndpoint({ valid: hasEnterprisePlugins });
+ setupTokenStatusEndpoint({ valid: !!enterprisePlugins });
const settings = mockSettings({
"enable-embedding": true,
"embedding-secret-key": "my_super_secret_key",
"token-features": tokenFeatures,
- "available-fonts": hasEnterprisePlugins ? FONTS_MOCK_VALUES : undefined,
+ "available-fonts": enterprisePlugins ? FONTS_MOCK_VALUES : undefined,
});
const state = createMockState({
currentUser: createMockUser({ is_superuser: true }),
settings: settings,
});
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
+ if (enterprisePlugins) {
+ enterprisePlugins.forEach((plugin) => {
+ setupEnterpriseOnlyPlugin(plugin);
+ });
}
const view = renderWithProviders(
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 8152001a1c6..71963cab885 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
@@ -12,7 +12,6 @@ const DASHBOARD_TITLE = '"My test dash"';
const setupEnterprise = async (opts?: Partial<SetupOpts>) => {
return await setup({
...opts,
- hasEnterprisePlugins: true,
dashboardTitle: DASHBOARD_TITLE,
});
};
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 8f5427463f1..f82e7696e34 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
@@ -13,11 +13,11 @@ const DASHBOARD_TITLE = '"My test dash"';
const setupPremium = async (opts?: Partial<SetupOpts>) => {
return await setup({
...opts,
+ enterprisePlugins: ["whitelabel", "resource_downloads"],
tokenFeatures: createMockTokenFeatures({
// the `whitelabel` feature is needed to test #downloads=false
whitelabel: true,
}),
- hasEnterprisePlugins: true,
dashboardTitle: DASHBOARD_TITLE,
});
};
diff --git a/frontend/src/metabase/public/containers/PublicOrEmbeddedDashboard/PublicOrEmbeddedDashboardPage/tests/setup.tsx b/frontend/src/metabase/public/containers/PublicOrEmbeddedDashboard/PublicOrEmbeddedDashboardPage/tests/setup.tsx
index bd405012a78..b731c73f164 100644
--- a/frontend/src/metabase/public/containers/PublicOrEmbeddedDashboard/PublicOrEmbeddedDashboardPage/tests/setup.tsx
+++ b/frontend/src/metabase/public/containers/PublicOrEmbeddedDashboard/PublicOrEmbeddedDashboardPage/tests/setup.tsx
@@ -2,7 +2,7 @@ import fetchMock from "fetch-mock";
import { Route } from "react-router";
import _ from "underscore";
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import { setupDatabasesEndpoints } from "__support__/server-mocks";
import { setupEmbedDashboardEndpoints } from "__support__/server-mocks/embed";
import { mockSettings } from "__support__/settings";
@@ -35,8 +35,8 @@ export type SetupOpts = {
queryString?: string;
numberOfTabs?: number;
tokenFeatures?: TokenFeatures;
- hasEnterprisePlugins?: boolean;
dashboardTitle: string;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
};
export async function setup(
@@ -45,8 +45,8 @@ export async function setup(
queryString = "",
numberOfTabs = 1,
tokenFeatures = createMockTokenFeatures(),
- hasEnterprisePlugins = false,
dashboardTitle,
+ enterprisePlugins,
}: SetupOpts = { dashboardTitle: "" },
) {
mockSettings({
@@ -54,8 +54,8 @@ export async function setup(
});
setupDatabasesEndpoints([createMockDatabase()]);
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
+ if (enterprisePlugins) {
+ enterprisePlugins.forEach(setupEnterpriseOnlyPlugin);
}
const tabs: DashboardTab[] = [];
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 cc7d7598478..477483d5c8c 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
@@ -13,7 +13,6 @@ const QUESTION_NAME = "Public question";
function setupEnterprise(opts?: Partial<SetupOpts>) {
return setup({
...opts,
- hasEnterprisePlugins: true,
questionName: QUESTION_NAME,
uuid: FAKE_UUID,
});
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 c54c5f8afec..2e053ae7bdd 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
@@ -13,11 +13,11 @@ const QUESTION_NAME = "Public question";
function setupPremium(opts?: Partial<SetupOpts>) {
return setup({
- ...opts,
- hasEnterprisePlugins: true,
tokenFeatures: createMockTokenFeatures({ whitelabel: true }),
+ enterprisePlugins: ["whitelabel"],
questionName: QUESTION_NAME,
uuid: FAKE_UUID,
+ ...opts,
});
}
@@ -40,7 +40,10 @@ describe("PublicOrEmbeddedQuestion", () => {
});
it("should not allow downloading results when downloads are disabled", async () => {
- await setupPremium({ hash: { downloads: "false" } });
+ await setupPremium({
+ hash: { downloads: "false" },
+ enterprisePlugins: ["resource_downloads"],
+ });
expect(queryIcon("download")).not.toBeInTheDocument();
});
diff --git a/frontend/src/metabase/public/containers/PublicOrEmbeddedQuestion/PublicOrEmbeddedQuestion/tests/setup.tsx b/frontend/src/metabase/public/containers/PublicOrEmbeddedQuestion/PublicOrEmbeddedQuestion/tests/setup.tsx
index 39dfffa24d3..52bc252f7ad 100644
--- a/frontend/src/metabase/public/containers/PublicOrEmbeddedQuestion/PublicOrEmbeddedQuestion/tests/setup.tsx
+++ b/frontend/src/metabase/public/containers/PublicOrEmbeddedQuestion/PublicOrEmbeddedQuestion/tests/setup.tsx
@@ -2,7 +2,7 @@ import fetchMock from "fetch-mock";
import { Route } from "react-router";
import _ from "underscore";
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import {
setupPublicCardQueryEndpoints,
setupPublicQuestionEndpoints,
@@ -64,28 +64,28 @@ jest.mock(
export type SetupOpts = {
hash?: Record<string, string>;
- hasEnterprisePlugins?: boolean;
tokenFeatures?: TokenFeatures;
questionName: string;
uuid: string;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
};
export async function setup(
{
hash = {},
- hasEnterprisePlugins,
tokenFeatures = createMockTokenFeatures(),
questionName,
uuid,
+ enterprisePlugins = [],
}: SetupOpts = { questionName: "", uuid: "" },
) {
const settings = mockSettings({
"token-features": tokenFeatures,
});
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
- }
+ enterprisePlugins.forEach((plugin) => {
+ setupEnterpriseOnlyPlugin(plugin);
+ });
setupPublicQuestionEndpoints(
uuid,
diff --git a/frontend/src/metabase/query_builder/components/ImpossibleToCreateModelModal/tests/enterprise.unit.spec.ts b/frontend/src/metabase/query_builder/components/ImpossibleToCreateModelModal/tests/enterprise.unit.spec.ts
index ac52df0c8b6..2f0100492e7 100644
--- a/frontend/src/metabase/query_builder/components/ImpossibleToCreateModelModal/tests/enterprise.unit.spec.ts
+++ b/frontend/src/metabase/query_builder/components/ImpossibleToCreateModelModal/tests/enterprise.unit.spec.ts
@@ -4,7 +4,7 @@ import type { SetupOpts } from "./setup";
import { setup as baseSetup } from "./setup";
function setup(opts: SetupOpts) {
- baseSetup({ hasEnterprisePlugins: true, ...opts });
+ baseSetup({ ...opts });
}
describe("ImpossibleToCreateModelModal (EE without token)", () => {
diff --git a/frontend/src/metabase/query_builder/components/ImpossibleToCreateModelModal/tests/premium.unit.spec.ts b/frontend/src/metabase/query_builder/components/ImpossibleToCreateModelModal/tests/premium.unit.spec.ts
index ed507d4c35c..10c201b783e 100644
--- a/frontend/src/metabase/query_builder/components/ImpossibleToCreateModelModal/tests/premium.unit.spec.ts
+++ b/frontend/src/metabase/query_builder/components/ImpossibleToCreateModelModal/tests/premium.unit.spec.ts
@@ -5,7 +5,7 @@ import { setup as baseSetup } from "./setup";
function setup(opts: SetupOpts) {
baseSetup({
- hasEnterprisePlugins: true,
+ enterprisePlugins: ["whitelabel"],
tokenFeatures: { whitelabel: true },
...opts,
});
diff --git a/frontend/src/metabase/query_builder/components/ImpossibleToCreateModelModal/tests/setup.tsx b/frontend/src/metabase/query_builder/components/ImpossibleToCreateModelModal/tests/setup.tsx
index 41b87a45d3a..80bebfebc2b 100644
--- a/frontend/src/metabase/query_builder/components/ImpossibleToCreateModelModal/tests/setup.tsx
+++ b/frontend/src/metabase/query_builder/components/ImpossibleToCreateModelModal/tests/setup.tsx
@@ -1,4 +1,4 @@
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import { mockSettings } from "__support__/settings";
import { renderWithProviders } from "__support__/ui";
import type { TokenFeatures } from "metabase-types/api";
@@ -9,13 +9,13 @@ import { ImpossibleToCreateModelModal } from "../ImpossibleToCreateModelModal";
export interface SetupOpts {
showMetabaseLinks: boolean;
- hasEnterprisePlugins?: boolean;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
tokenFeatures?: Partial<TokenFeatures>;
}
export const setup = ({
showMetabaseLinks = true,
- hasEnterprisePlugins,
+ enterprisePlugins,
tokenFeatures = {},
}: SetupOpts) => {
const state = createMockState({
@@ -25,8 +25,8 @@ export const setup = ({
}),
});
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
+ if (enterprisePlugins) {
+ enterprisePlugins.forEach(setupEnterpriseOnlyPlugin);
}
renderWithProviders(<ImpossibleToCreateModelModal onClose={jest.fn()} />, {
diff --git a/frontend/src/metabase/query_builder/components/SavedQuestionHeaderButton/SavedQuestionHeaderButton.unit.spec.js b/frontend/src/metabase/query_builder/components/SavedQuestionHeaderButton/SavedQuestionHeaderButton.unit.spec.js
index 94921c0a4fe..7ac3a70a800 100644
--- a/frontend/src/metabase/query_builder/components/SavedQuestionHeaderButton/SavedQuestionHeaderButton.unit.spec.js
+++ b/frontend/src/metabase/query_builder/components/SavedQuestionHeaderButton/SavedQuestionHeaderButton.unit.spec.js
@@ -1,6 +1,6 @@
import userEvent from "@testing-library/user-event";
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import { createMockMetadata } from "__support__/metadata";
import { mockSettings } from "__support__/settings";
import { getIcon, renderWithProviders, screen } from "__support__/ui";
@@ -18,7 +18,7 @@ const metadata = createMockMetadata({
databases: [createSampleDatabase()],
});
-function setup({ question, tokenFeatures = {}, hasEnterprisePlugins = false }) {
+function setup({ question, tokenFeatures = {}, enterprisePlugins }) {
const onSave = jest.fn();
const state = createMockState({
@@ -27,8 +27,8 @@ function setup({ question, tokenFeatures = {}, hasEnterprisePlugins = false }) {
}),
});
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
+ if (enterprisePlugins) {
+ enterprisePlugins.forEach(setupEnterpriseOnlyPlugin);
}
renderWithProviders(
@@ -98,10 +98,10 @@ describe("SavedQuestionHeaderButton", () => {
it("should have an additional icon to signify the question's moderation status", () => {
setup({
question,
- hasEnterprisePlugins: true,
tokenFeatures: {
content_verification: true,
},
+ enterprisePlugins: ["content-verification", "moderation"],
});
expect(getIcon("verified")).toBeInTheDocument();
});
@@ -122,8 +122,8 @@ describe("SavedQuestionHeaderButton", () => {
it("should have an additional icon to signify the question's collection type", () => {
setup({
question,
- hasEnterprisePlugins: true,
tokenFeatures: { audit_app: true },
+ enterprisePlugins: ["collections", "audit-app"],
});
expect(getIcon("audit")).toBeInTheDocument();
});
diff --git a/frontend/src/metabase/query_builder/components/VisualizationError/tests/enterprise.unit.spec.ts b/frontend/src/metabase/query_builder/components/VisualizationError/tests/enterprise.unit.spec.ts
index 2916792bf79..32ad3c2ffb8 100644
--- a/frontend/src/metabase/query_builder/components/VisualizationError/tests/enterprise.unit.spec.ts
+++ b/frontend/src/metabase/query_builder/components/VisualizationError/tests/enterprise.unit.spec.ts
@@ -5,7 +5,7 @@ import type { SetupOpts } from "./setup";
import { setup as baseSetup } from "./setup";
function setup(opts: SetupOpts) {
- baseSetup({ hasEnterprisePlugins: true, ...opts });
+ baseSetup({ ...opts });
}
describe("VisualizationError (EE without token)", () => {
diff --git a/frontend/src/metabase/query_builder/components/VisualizationError/tests/premium.unit.spec.ts b/frontend/src/metabase/query_builder/components/VisualizationError/tests/premium.unit.spec.ts
index 286e60dac84..de41ff97798 100644
--- a/frontend/src/metabase/query_builder/components/VisualizationError/tests/premium.unit.spec.ts
+++ b/frontend/src/metabase/query_builder/components/VisualizationError/tests/premium.unit.spec.ts
@@ -6,8 +6,8 @@ import { setup as baseSetup } from "./setup";
function setup(opts: SetupOpts) {
baseSetup({
- hasEnterprisePlugins: true,
tokenFeatures: { whitelabel: true },
+ enterprisePlugins: ["whitelabel"],
...opts,
});
}
diff --git a/frontend/src/metabase/query_builder/components/VisualizationError/tests/setup.tsx b/frontend/src/metabase/query_builder/components/VisualizationError/tests/setup.tsx
index 6663d135875..0d21c786c6d 100644
--- a/frontend/src/metabase/query_builder/components/VisualizationError/tests/setup.tsx
+++ b/frontend/src/metabase/query_builder/components/VisualizationError/tests/setup.tsx
@@ -1,4 +1,4 @@
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import { createMockMetadata } from "__support__/metadata";
import { mockSettings } from "__support__/settings";
import { createMockEntitiesState } from "__support__/store";
@@ -18,16 +18,16 @@ export interface SetupOpts {
database?: Database;
card?: Card;
showMetabaseLinks?: boolean;
- hasEnterprisePlugins?: boolean;
tokenFeatures?: Partial<TokenFeatures>;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
}
export const setup = ({
database = createMockDatabase(),
card = createMockCard(),
showMetabaseLinks = true,
- hasEnterprisePlugins,
tokenFeatures = {},
+ enterprisePlugins = [],
}: SetupOpts) => {
const state = createMockState({
entities: createMockEntitiesState({
@@ -40,9 +40,9 @@ export const setup = ({
}),
});
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
- }
+ enterprisePlugins.forEach((plugin) => {
+ setupEnterpriseOnlyPlugin(plugin);
+ });
const metadata = createMockMetadata({
questions: [card],
diff --git a/frontend/src/metabase/query_builder/components/expressions/Editor/HelpText/tests/enterprise.unit.spec.tsx b/frontend/src/metabase/query_builder/components/expressions/Editor/HelpText/tests/enterprise.unit.spec.tsx
index fdeaa31e533..9e5d6ddea24 100644
--- a/frontend/src/metabase/query_builder/components/expressions/Editor/HelpText/tests/enterprise.unit.spec.tsx
+++ b/frontend/src/metabase/query_builder/components/expressions/Editor/HelpText/tests/enterprise.unit.spec.tsx
@@ -4,7 +4,7 @@ import type { SetupOpts } from "./setup";
import { setup as baseSetup } from "./setup";
async function setup(opts: SetupOpts) {
- await baseSetup({ hasEnterprisePlugins: true, ...opts });
+ await baseSetup({ ...opts });
}
describe("ExpressionEditorHelpText (EE without token)", () => {
diff --git a/frontend/src/metabase/query_builder/components/expressions/Editor/HelpText/tests/premium.unit.spec.tsx b/frontend/src/metabase/query_builder/components/expressions/Editor/HelpText/tests/premium.unit.spec.tsx
index 5bd18e38401..c39b7f472af 100644
--- a/frontend/src/metabase/query_builder/components/expressions/Editor/HelpText/tests/premium.unit.spec.tsx
+++ b/frontend/src/metabase/query_builder/components/expressions/Editor/HelpText/tests/premium.unit.spec.tsx
@@ -5,7 +5,7 @@ import { setup as baseSetup } from "./setup";
async function setup(opts: SetupOpts) {
await baseSetup({
- hasEnterprisePlugins: true,
+ enterprisePlugins: ["whitelabel"],
tokenFeatures: { whitelabel: true },
...opts,
});
diff --git a/frontend/src/metabase/query_builder/components/expressions/Editor/HelpText/tests/setup.tsx b/frontend/src/metabase/query_builder/components/expressions/Editor/HelpText/tests/setup.tsx
index 85fea5f85ac..bef4ee51dd6 100644
--- a/frontend/src/metabase/query_builder/components/expressions/Editor/HelpText/tests/setup.tsx
+++ b/frontend/src/metabase/query_builder/components/expressions/Editor/HelpText/tests/setup.tsx
@@ -1,4 +1,4 @@
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import { createMockMetadata } from "__support__/metadata";
import { mockSettings } from "__support__/settings";
import { renderWithProviders } from "__support__/ui";
@@ -21,7 +21,7 @@ export interface SetupOpts {
reportTimezone?: string;
showMetabaseLinks?: boolean;
- hasEnterprisePlugins?: boolean;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
tokenFeatures?: Partial<TokenFeatures>;
expressionMode?: Lib.ExpressionMode;
}
@@ -30,7 +30,7 @@ export async function setup({
enclosingFunction,
reportTimezone = "America/Los_Angeles",
showMetabaseLinks = true,
- hasEnterprisePlugins,
+ enterprisePlugins,
tokenFeatures = {},
expressionMode = "expression",
}: SetupOpts) {
@@ -59,8 +59,8 @@ export async function setup({
expressionMode,
};
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
+ if (enterprisePlugins) {
+ enterprisePlugins.forEach(setupEnterpriseOnlyPlugin);
}
renderWithProviders(<HelpText {...props} />, {
diff --git a/frontend/src/metabase/query_builder/components/template_tags/SnippetSidebar/tests/enterprise.unit.spec.tsx b/frontend/src/metabase/query_builder/components/template_tags/SnippetSidebar/tests/enterprise.unit.spec.tsx
index c1ab6391d57..e6fb70bfa93 100644
--- a/frontend/src/metabase/query_builder/components/template_tags/SnippetSidebar/tests/enterprise.unit.spec.tsx
+++ b/frontend/src/metabase/query_builder/components/template_tags/SnippetSidebar/tests/enterprise.unit.spec.tsx
@@ -6,7 +6,7 @@ import { setup } from "./setup";
describe("SnippetSidebar (EE no token)", () => {
beforeEach(async () => {
- await setup({ hasEnterprisePlugins: true });
+ await setup({});
});
it("should not display the `Change permissions` menu", () => {
diff --git a/frontend/src/metabase/query_builder/components/template_tags/SnippetSidebar/tests/premium.unit.spec.tsx b/frontend/src/metabase/query_builder/components/template_tags/SnippetSidebar/tests/premium.unit.spec.tsx
index 2748a94df54..e628ce84c3e 100644
--- a/frontend/src/metabase/query_builder/components/template_tags/SnippetSidebar/tests/premium.unit.spec.tsx
+++ b/frontend/src/metabase/query_builder/components/template_tags/SnippetSidebar/tests/premium.unit.spec.tsx
@@ -11,7 +11,7 @@ import { setup as baseSetup } from "./setup";
async function setup(options: SetupOpts = {}) {
await baseSetup({
- hasEnterprisePlugins: true,
+ enterprisePlugins: ["snippets"],
tokenFeatures: { snippet_collections: true },
...options,
});
diff --git a/frontend/src/metabase/query_builder/components/template_tags/SnippetSidebar/tests/setup.tsx b/frontend/src/metabase/query_builder/components/template_tags/SnippetSidebar/tests/setup.tsx
index 5d5a65048b7..1a6a1251ed0 100644
--- a/frontend/src/metabase/query_builder/components/template_tags/SnippetSidebar/tests/setup.tsx
+++ b/frontend/src/metabase/query_builder/components/template_tags/SnippetSidebar/tests/setup.tsx
@@ -1,6 +1,6 @@
/* istanbul ignore file */
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import {
setupCollectionItemsEndpoint,
setupCollectionsEndpoints,
@@ -25,13 +25,13 @@ const MOCK_SNIPPET = createMockNativeQuerySnippet();
export interface SetupOpts {
tokenFeatures?: Partial<TokenFeatures>;
- hasEnterprisePlugins?: boolean;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
user?: Partial<User>;
}
export async function setup({
tokenFeatures = {},
- hasEnterprisePlugins = false,
+ enterprisePlugins,
user = { is_superuser: true },
}: SetupOpts = {}) {
setupNativeQuerySnippetEndpoints({ snippets: [MOCK_SNIPPET] });
@@ -50,8 +50,8 @@ export async function setup({
}),
});
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
+ if (enterprisePlugins) {
+ enterprisePlugins.forEach(setupEnterpriseOnlyPlugin);
}
renderWithProviders(
diff --git a/frontend/src/metabase/query_builder/components/template_tags/TagEditorHelp/tests/enterprise.unit.spec.ts b/frontend/src/metabase/query_builder/components/template_tags/TagEditorHelp/tests/enterprise.unit.spec.ts
index 67f629de24d..8980a64115f 100644
--- a/frontend/src/metabase/query_builder/components/template_tags/TagEditorHelp/tests/enterprise.unit.spec.ts
+++ b/frontend/src/metabase/query_builder/components/template_tags/TagEditorHelp/tests/enterprise.unit.spec.ts
@@ -5,7 +5,6 @@ import { setup as baseSetup } from "./setup";
function setup(opts: SetupOpts) {
baseSetup({
- hasEnterprisePlugins: true,
...opts,
});
}
diff --git a/frontend/src/metabase/query_builder/components/template_tags/TagEditorHelp/tests/premium.unit.spec.ts b/frontend/src/metabase/query_builder/components/template_tags/TagEditorHelp/tests/premium.unit.spec.ts
index d58e62f0ce2..f5ae641bec8 100644
--- a/frontend/src/metabase/query_builder/components/template_tags/TagEditorHelp/tests/premium.unit.spec.ts
+++ b/frontend/src/metabase/query_builder/components/template_tags/TagEditorHelp/tests/premium.unit.spec.ts
@@ -5,8 +5,8 @@ import { setup as baseSetup } from "./setup";
function setup(opts: SetupOpts) {
baseSetup({
- hasEnterprisePlugins: true,
tokenFeatures: { whitelabel: true },
+ enterprisePlugins: ["whitelabel"],
...opts,
});
}
diff --git a/frontend/src/metabase/query_builder/components/template_tags/TagEditorHelp/tests/setup.tsx b/frontend/src/metabase/query_builder/components/template_tags/TagEditorHelp/tests/setup.tsx
index 36dfb3ff35b..366f17e78ee 100644
--- a/frontend/src/metabase/query_builder/components/template_tags/TagEditorHelp/tests/setup.tsx
+++ b/frontend/src/metabase/query_builder/components/template_tags/TagEditorHelp/tests/setup.tsx
@@ -1,4 +1,4 @@
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import { mockSettings } from "__support__/settings";
import { renderWithProviders } from "__support__/ui";
import Database from "metabase-lib/v1/metadata/Database";
@@ -13,14 +13,14 @@ import { TagEditorHelp } from "../TagEditorHelp";
export interface SetupOpts {
showMetabaseLinks?: boolean;
- hasEnterprisePlugins?: boolean;
tokenFeatures?: Partial<TokenFeatures>;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
}
export const setup = ({
showMetabaseLinks = true,
- hasEnterprisePlugins,
tokenFeatures = {},
+ enterprisePlugins = [],
}: SetupOpts = {}) => {
const state = createMockState({
settings: mockSettings({
@@ -29,9 +29,9 @@ export const setup = ({
}),
});
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
- }
+ enterprisePlugins.forEach((plugin) => {
+ setupEnterpriseOnlyPlugin(plugin);
+ });
renderWithProviders(
<TagEditorHelp
diff --git a/frontend/src/metabase/query_builder/components/view/PreviewQueryModal/tests/enterprise.unit.spec.tsx b/frontend/src/metabase/query_builder/components/view/PreviewQueryModal/tests/enterprise.unit.spec.tsx
index b3ea1f5e03e..f7e7104d22b 100644
--- a/frontend/src/metabase/query_builder/components/view/PreviewQueryModal/tests/enterprise.unit.spec.tsx
+++ b/frontend/src/metabase/query_builder/components/view/PreviewQueryModal/tests/enterprise.unit.spec.tsx
@@ -4,7 +4,7 @@ import type { SetupOpts } from "./setup";
import { setup as baseSetup } from "./setup";
function setup(opts: SetupOpts) {
- baseSetup({ hasEnterprisePlugins: true, ...opts });
+ baseSetup({ ...opts });
}
describe("PreviewQueryModal (EE without token)", () => {
diff --git a/frontend/src/metabase/query_builder/components/view/PreviewQueryModal/tests/premium.unit.spec.tsx b/frontend/src/metabase/query_builder/components/view/PreviewQueryModal/tests/premium.unit.spec.tsx
index a9c9a0cc003..0c6a8b73ccd 100644
--- a/frontend/src/metabase/query_builder/components/view/PreviewQueryModal/tests/premium.unit.spec.tsx
+++ b/frontend/src/metabase/query_builder/components/view/PreviewQueryModal/tests/premium.unit.spec.tsx
@@ -5,8 +5,8 @@ import { setup as baseSetup } from "./setup";
function setup(opts: SetupOpts) {
baseSetup({
- hasEnterprisePlugins: true,
tokenFeatures: { whitelabel: true },
+ enterprisePlugins: ["whitelabel"],
...opts,
});
}
diff --git a/frontend/src/metabase/query_builder/components/view/PreviewQueryModal/tests/setup.tsx b/frontend/src/metabase/query_builder/components/view/PreviewQueryModal/tests/setup.tsx
index f8f75d4fb39..f543ed990eb 100644
--- a/frontend/src/metabase/query_builder/components/view/PreviewQueryModal/tests/setup.tsx
+++ b/frontend/src/metabase/query_builder/components/view/PreviewQueryModal/tests/setup.tsx
@@ -1,6 +1,6 @@
import fetchMock from "fetch-mock";
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import { mockSettings } from "__support__/settings";
import { createMockEntitiesState } from "__support__/store";
import { renderWithProviders } from "__support__/ui";
@@ -19,14 +19,14 @@ import { PreviewQueryModal } from "..";
export interface SetupOpts {
showMetabaseLinks?: boolean;
- hasEnterprisePlugins?: boolean;
tokenFeatures?: Partial<TokenFeatures>;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
}
export const setup = ({
showMetabaseLinks = true,
- hasEnterprisePlugins,
tokenFeatures = {},
+ enterprisePlugins = [],
}: SetupOpts = {}) => {
const card = createMockNativeCard();
const state = createMockState({
@@ -41,9 +41,9 @@ export const setup = ({
}),
});
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
- }
+ enterprisePlugins.forEach((plugin) => {
+ setupEnterpriseOnlyPlugin(plugin);
+ });
fetchMock.post("path:/api/dataset/native", {
status: 500,
diff --git a/frontend/src/metabase/query_builder/components/view/sidebars/QuestionInfoSidebar/tests/content-verification.unit.spec.tsx b/frontend/src/metabase/query_builder/components/view/sidebars/QuestionInfoSidebar/tests/content-verification.unit.spec.tsx
index 62054b0b237..d3a1c185746 100644
--- a/frontend/src/metabase/query_builder/components/view/sidebars/QuestionInfoSidebar/tests/content-verification.unit.spec.tsx
+++ b/frontend/src/metabase/query_builder/components/view/sidebars/QuestionInfoSidebar/tests/content-verification.unit.spec.tsx
@@ -16,7 +16,7 @@ const setupContentVerification = (opts: SetupOpts) => {
...opts?.settings,
"token-features": createMockTokenFeatures({ content_verification: true }),
}),
- hasEnterprisePlugins: true,
+ enterprisePlugins: ["content_verification", "moderation"],
});
};
diff --git a/frontend/src/metabase/query_builder/components/view/sidebars/QuestionInfoSidebar/tests/enterprise.unit.spec.tsx b/frontend/src/metabase/query_builder/components/view/sidebars/QuestionInfoSidebar/tests/enterprise.unit.spec.tsx
index 6f3e62c02aa..9f4ced283a1 100644
--- a/frontend/src/metabase/query_builder/components/view/sidebars/QuestionInfoSidebar/tests/enterprise.unit.spec.tsx
+++ b/frontend/src/metabase/query_builder/components/view/sidebars/QuestionInfoSidebar/tests/enterprise.unit.spec.tsx
@@ -13,7 +13,6 @@ import { setup } from "./setup";
const setupEnterprise = (opts: SetupOpts) => {
return setup({
...opts,
- hasEnterprisePlugins: true,
});
};
diff --git a/frontend/src/metabase/query_builder/components/view/sidebars/QuestionInfoSidebar/tests/premium.unit.spec.tsx b/frontend/src/metabase/query_builder/components/view/sidebars/QuestionInfoSidebar/tests/premium.unit.spec.tsx
index 1962cb75cc6..8609691b960 100644
--- a/frontend/src/metabase/query_builder/components/view/sidebars/QuestionInfoSidebar/tests/premium.unit.spec.tsx
+++ b/frontend/src/metabase/query_builder/components/view/sidebars/QuestionInfoSidebar/tests/premium.unit.spec.tsx
@@ -22,7 +22,12 @@ const setupEnterprise = (opts: SetupOpts) => {
audit_app: true,
}),
}),
- hasEnterprisePlugins: true,
+ enterprisePlugins: [
+ "content_verification",
+ "audit_app",
+ "collections",
+ "moderation",
+ ],
});
};
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 a46e387bcf9..1628d3fc6ee 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
@@ -1,6 +1,6 @@
import { Route } from "react-router";
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import {
setupAuditInfoEndpoint,
setupCardEndpoints,
@@ -32,15 +32,15 @@ import { QuestionInfoSidebar } from "../QuestionInfoSidebar";
export interface SetupOpts {
card?: Card;
settings?: Settings;
- hasEnterprisePlugins?: boolean;
user?: Partial<User>;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
}
export const setup = async ({
card = createMockCard(),
settings = createMockSettings(),
user,
- hasEnterprisePlugins = false,
+ enterprisePlugins = [],
}: SetupOpts = {}) => {
const currentUser = createMockUser(user);
setupCardEndpoints(card);
@@ -62,11 +62,11 @@ export const setup = async ({
const question = checkNotNull(getQuestion(state));
const onSave = jest.fn();
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
- }
+ enterprisePlugins.forEach((plugin) => {
+ setupEnterpriseOnlyPlugin(plugin);
+ });
- setupTokenStatusEndpoint({ valid: hasEnterprisePlugins });
+ setupTokenStatusEndpoint({ valid: enterprisePlugins.length > 0 });
const TestQuestionInfoSidebar = () => (
<QuestionInfoSidebar question={question} onSave={onSave} />
diff --git a/frontend/src/metabase/query_builder/components/view/sidebars/QuestionSettingsSidebar/tests/enterprise.unit.spec.tsx b/frontend/src/metabase/query_builder/components/view/sidebars/QuestionSettingsSidebar/tests/enterprise.unit.spec.tsx
index 65af556881f..89e5e1e4343 100644
--- a/frontend/src/metabase/query_builder/components/view/sidebars/QuestionSettingsSidebar/tests/enterprise.unit.spec.tsx
+++ b/frontend/src/metabase/query_builder/components/view/sidebars/QuestionSettingsSidebar/tests/enterprise.unit.spec.tsx
@@ -15,13 +15,13 @@ const setupEnterprise = (
) => {
return setup({
...opts,
+ enterprisePlugins: ["caching", "model_persistence"],
settings: createMockSettings({
...opts.settings,
"token-features": createMockTokenFeatures({
...tokenFeatures,
}),
}),
- hasEnterprisePlugins: true,
});
};
diff --git a/frontend/src/metabase/query_builder/components/view/sidebars/QuestionSettingsSidebar/tests/setup.tsx b/frontend/src/metabase/query_builder/components/view/sidebars/QuestionSettingsSidebar/tests/setup.tsx
index 3051fb26c5b..a102ab2988d 100644
--- a/frontend/src/metabase/query_builder/components/view/sidebars/QuestionSettingsSidebar/tests/setup.tsx
+++ b/frontend/src/metabase/query_builder/components/view/sidebars/QuestionSettingsSidebar/tests/setup.tsx
@@ -1,6 +1,6 @@
import { Route } from "react-router";
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import {
setupCardEndpoints,
setupDatabaseEndpoints,
@@ -28,14 +28,14 @@ import { QuestionSettingsSidebar } from "../QuestionSettingsSidebar";
export interface SetupOpts {
card?: Card;
settings?: Settings;
- hasEnterprisePlugins?: boolean;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
dbHasModelPersistence?: boolean;
}
export const setup = async ({
card = createMockCard(),
settings = createMockSettings(),
- hasEnterprisePlugins,
+ enterprisePlugins,
dbHasModelPersistence = true,
}: SetupOpts) => {
const currentUser = createMockUser();
@@ -72,8 +72,8 @@ export const setup = async ({
const metadata = getMetadata(state);
const question = checkNotNull(metadata.question(card.id));
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
+ if (enterprisePlugins) {
+ enterprisePlugins.forEach(setupEnterpriseOnlyPlugin);
}
const TestQuestionSettingsSidebar = () => (
diff --git a/frontend/src/metabase/query_builder/containers/use-register-query-builder-metabot-context.unit.spec.tsx b/frontend/src/metabase/query_builder/containers/use-register-query-builder-metabot-context.unit.spec.tsx
index 919b325c78e..2923df7858f 100644
--- a/frontend/src/metabase/query_builder/containers/use-register-query-builder-metabot-context.unit.spec.tsx
+++ b/frontend/src/metabase/query_builder/containers/use-register-query-builder-metabot-context.unit.spec.tsx
@@ -1,6 +1,6 @@
import _ from "underscore";
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import { mockSettings } from "__support__/settings";
import { renderHook } from "__support__/ui";
import { PLUGIN_METABOT } from "metabase/plugins";
@@ -101,7 +101,8 @@ describe("registerQueryBuilderMetabotContextFn", () => {
}),
}),
);
- setupEnterprisePlugins();
+ setupEnterpriseOnlyPlugin("metabot");
+ setupEnterpriseOnlyPlugin("ai-entity-analysis");
});
beforeEach(() => {
diff --git a/frontend/src/metabase/querying/metrics/components/MetricEditor/MetricEditorBody/MetricEditorSidebar/tests/enterprise.unit.spec.tsx b/frontend/src/metabase/querying/metrics/components/MetricEditor/MetricEditorBody/MetricEditorSidebar/tests/enterprise.unit.spec.tsx
index 2a8e6e8ebe7..94532af29b5 100644
--- a/frontend/src/metabase/querying/metrics/components/MetricEditor/MetricEditorBody/MetricEditorSidebar/tests/enterprise.unit.spec.tsx
+++ b/frontend/src/metabase/querying/metrics/components/MetricEditor/MetricEditorBody/MetricEditorSidebar/tests/enterprise.unit.spec.tsx
@@ -3,7 +3,7 @@ import { screen } from "__support__/ui";
import { type SetupOpts, setup as baseSetup } from "./setup";
function setup(opts: SetupOpts = {}) {
- baseSetup({ hasEnterprisePlugins: true, ...opts });
+ baseSetup({ ...opts });
}
describe("MetricEditorSidebar (EE without a token)", () => {
diff --git a/frontend/src/metabase/querying/metrics/components/MetricEditor/MetricEditorBody/MetricEditorSidebar/tests/setup.tsx b/frontend/src/metabase/querying/metrics/components/MetricEditor/MetricEditorBody/MetricEditorSidebar/tests/setup.tsx
index 3c84bd16f07..19418bff5c4 100644
--- a/frontend/src/metabase/querying/metrics/components/MetricEditor/MetricEditorBody/MetricEditorSidebar/tests/setup.tsx
+++ b/frontend/src/metabase/querying/metrics/components/MetricEditor/MetricEditorBody/MetricEditorSidebar/tests/setup.tsx
@@ -1,4 +1,4 @@
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import { mockSettings } from "__support__/settings";
import { renderWithProviders } from "__support__/ui";
import type { TokenFeatures } from "metabase-types/api";
@@ -10,13 +10,13 @@ import { MetricEditorSidebar } from "../MetricEditorSidebar";
export type SetupOpts = {
tokenFeatures?: Partial<TokenFeatures>;
showMetabaseLinks?: boolean;
- hasEnterprisePlugins?: boolean;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
};
export function setup({
tokenFeatures,
showMetabaseLinks,
- hasEnterprisePlugins,
+ enterprisePlugins = [],
}: SetupOpts = {}) {
const state = createMockState({
settings: mockSettings({
@@ -25,9 +25,9 @@ export function setup({
}),
});
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
- }
+ enterprisePlugins.forEach((plugin) => {
+ setupEnterpriseOnlyPlugin(plugin);
+ });
renderWithProviders(<MetricEditorSidebar />, { storeInitialState: state });
}
diff --git a/frontend/src/metabase/querying/metrics/components/MetricEditor/MetricEditorBody/MetricEditorSidebar/tests/whitelabel.unit.spec.tsx b/frontend/src/metabase/querying/metrics/components/MetricEditor/MetricEditorBody/MetricEditorSidebar/tests/whitelabel.unit.spec.tsx
index dc8f17667c9..ec4f47261ba 100644
--- a/frontend/src/metabase/querying/metrics/components/MetricEditor/MetricEditorBody/MetricEditorSidebar/tests/whitelabel.unit.spec.tsx
+++ b/frontend/src/metabase/querying/metrics/components/MetricEditor/MetricEditorBody/MetricEditorSidebar/tests/whitelabel.unit.spec.tsx
@@ -5,7 +5,7 @@ import { type SetupOpts, setup as baseSetup } from "./setup";
function setup(opts: SetupOpts = {}) {
baseSetup({
tokenFeatures: { whitelabel: true },
- hasEnterprisePlugins: true,
+ enterprisePlugins: ["whitelabel"],
...opts,
});
}
diff --git a/frontend/src/metabase/querying/notebook/components/DataStep/tests/common.unit.spec.tsx b/frontend/src/metabase/querying/notebook/components/DataStep/tests/common.unit.spec.tsx
index 9c29319ef83..01df6b82be6 100644
--- a/frontend/src/metabase/querying/notebook/components/DataStep/tests/common.unit.spec.tsx
+++ b/frontend/src/metabase/querying/notebook/components/DataStep/tests/common.unit.spec.tsx
@@ -47,7 +47,6 @@ const createQueryWithBreakout = () => {
function setup(opts: SetupOpts = {}) {
return baseSetup({
- hasEnterprisePlugins: false,
...opts,
});
}
diff --git a/frontend/src/metabase/querying/notebook/components/DataStep/tests/enterprise.unit.spec.tsx b/frontend/src/metabase/querying/notebook/components/DataStep/tests/enterprise.unit.spec.tsx
index 1718480f494..433e9aafeab 100644
--- a/frontend/src/metabase/querying/notebook/components/DataStep/tests/enterprise.unit.spec.tsx
+++ b/frontend/src/metabase/querying/notebook/components/DataStep/tests/enterprise.unit.spec.tsx
@@ -7,7 +7,7 @@ import { type SetupOpts, setup as baseSetup } from "./setup";
function setup(opts: SetupOpts = {}) {
return baseSetup({
- hasEnterprisePlugins: true,
+ enterprisePlugins: ["embedding"],
...opts,
});
}
diff --git a/frontend/src/metabase/querying/notebook/components/DataStep/tests/setup.tsx b/frontend/src/metabase/querying/notebook/components/DataStep/tests/setup.tsx
index 95591e69625..9f4eae638bb 100644
--- a/frontend/src/metabase/querying/notebook/components/DataStep/tests/setup.tsx
+++ b/frontend/src/metabase/querying/notebook/components/DataStep/tests/setup.tsx
@@ -1,4 +1,4 @@
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import {
setupCollectionByIdEndpoint,
setupDatabasesEndpoints,
@@ -22,16 +22,18 @@ export interface SetupOpts {
step?: NotebookStep;
readOnly?: boolean;
isEmbeddingSdk?: boolean;
- hasEnterprisePlugins?: boolean;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
}
export const setup = ({
step = createMockNotebookStep(),
readOnly = false,
isEmbeddingSdk = false,
- hasEnterprisePlugins = false,
+ enterprisePlugins,
}: SetupOpts = {}) => {
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
+ if (enterprisePlugins) {
+ enterprisePlugins.forEach((plugin) => {
+ setupEnterpriseOnlyPlugin(plugin);
+ });
}
const mockWindowOpen = jest.spyOn(window, "open").mockImplementation();
diff --git a/frontend/src/metabase/reference/segments/SegmentList/tests/enterprise.unit.spec.ts b/frontend/src/metabase/reference/segments/SegmentList/tests/enterprise.unit.spec.ts
index 2e4f539aa4a..928be4e4d17 100644
--- a/frontend/src/metabase/reference/segments/SegmentList/tests/enterprise.unit.spec.ts
+++ b/frontend/src/metabase/reference/segments/SegmentList/tests/enterprise.unit.spec.ts
@@ -6,7 +6,6 @@ import { setup as baseSetup } from "./setup";
function setup(opts: SetupOpts) {
baseSetup({
- hasEnterprisePlugins: true,
...opts,
});
}
diff --git a/frontend/src/metabase/reference/segments/SegmentList/tests/premium.unit.spec.ts b/frontend/src/metabase/reference/segments/SegmentList/tests/premium.unit.spec.ts
index 6930f96607e..febe127925c 100644
--- a/frontend/src/metabase/reference/segments/SegmentList/tests/premium.unit.spec.ts
+++ b/frontend/src/metabase/reference/segments/SegmentList/tests/premium.unit.spec.ts
@@ -6,8 +6,8 @@ import { setup as baseSetup } from "./setup";
function setup(opts: SetupOpts) {
baseSetup({
- hasEnterprisePlugins: true,
tokenFeatures: { whitelabel: true },
+ enterprisePlugins: ["whitelabel"],
...opts,
});
}
diff --git a/frontend/src/metabase/reference/segments/SegmentList/tests/setup.tsx b/frontend/src/metabase/reference/segments/SegmentList/tests/setup.tsx
index 480f5037b59..f90c8507447 100644
--- a/frontend/src/metabase/reference/segments/SegmentList/tests/setup.tsx
+++ b/frontend/src/metabase/reference/segments/SegmentList/tests/setup.tsx
@@ -1,4 +1,4 @@
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import { mockSettings } from "__support__/settings";
import { renderWithProviders } from "__support__/ui";
import type { TokenFeatures, User } from "metabase-types/api";
@@ -13,15 +13,15 @@ import { SegmentList } from "../SegmentList";
export interface SetupOpts {
user: User;
showMetabaseLinks?: boolean;
- hasEnterprisePlugins?: boolean;
tokenFeatures?: Partial<TokenFeatures>;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
}
export const setup = ({
user,
showMetabaseLinks = true,
- hasEnterprisePlugins,
tokenFeatures = {},
+ enterprisePlugins = [],
}: SetupOpts) => {
const state = createMockState({
currentUser: createMockUser(user),
@@ -31,9 +31,9 @@ export const setup = ({
}),
});
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
- }
+ enterprisePlugins.forEach((plugin) => {
+ setupEnterpriseOnlyPlugin(plugin);
+ });
renderWithProviders(<SegmentList />, { storeInitialState: state });
};
diff --git a/frontend/src/metabase/search/components/SearchResult/tests/SearchResult-Collections.unit.spec.tsx b/frontend/src/metabase/search/components/SearchResult/tests/SearchResult-Collections.unit.spec.tsx
index 7b5807bfd0e..927146363fb 100644
--- a/frontend/src/metabase/search/components/SearchResult/tests/SearchResult-Collections.unit.spec.tsx
+++ b/frontend/src/metabase/search/components/SearchResult/tests/SearchResult-Collections.unit.spec.tsx
@@ -1,4 +1,4 @@
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import {
setupCollectionByIdEndpoint,
setupUserRecipientsEndpoint,
@@ -50,13 +50,13 @@ const officialCollectionResult = createWrappedSearchResult({
interface SetupOpts {
tokenFeatures?: Partial<TokenFeatures>;
- hasEnterprisePlugins?: boolean;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
result: WrappedResult;
}
const setup = ({
tokenFeatures = {},
- hasEnterprisePlugins = false,
+ enterprisePlugins,
result,
}: SetupOpts) => {
setupCollectionByIdEndpoint({
@@ -72,8 +72,8 @@ const setup = ({
});
reinitialize();
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
+ if (enterprisePlugins) {
+ enterprisePlugins.forEach(setupEnterpriseOnlyPlugin);
}
renderWithProviders(<SearchResult result={result} index={0} />, {
@@ -86,7 +86,7 @@ describe("SearchResult > Collections", () => {
it("renders regular collection correctly", async () => {
setup({
result: regularCollectionResult,
- hasEnterprisePlugins: true,
+ enterprisePlugins: ["collections", "advanced_permissions"],
tokenFeatures: { official_collections: true },
});
expect(
@@ -99,7 +99,7 @@ describe("SearchResult > Collections", () => {
it("renders official collections correctly", async () => {
setup({
result: officialCollectionResult,
- hasEnterprisePlugins: true,
+ enterprisePlugins: ["collections", "advanced_permissions"],
tokenFeatures: { official_collections: true },
});
diff --git a/frontend/src/metabase/search/components/SearchSidebar/tests/enterprise.unit.spec.tsx b/frontend/src/metabase/search/components/SearchSidebar/tests/enterprise.unit.spec.tsx
index e9a47da9571..e012517e827 100644
--- a/frontend/src/metabase/search/components/SearchSidebar/tests/enterprise.unit.spec.tsx
+++ b/frontend/src/metabase/search/components/SearchSidebar/tests/enterprise.unit.spec.tsx
@@ -6,7 +6,7 @@ import { setup } from "./setup";
const setupEnterprise = async (opts?: SearchSidebarSetupOptions) => {
setup({
...opts,
- hasEnterprisePlugins: true,
+ enterprisePlugins: ["content_verification"],
});
};
diff --git a/frontend/src/metabase/search/components/SearchSidebar/tests/premium.unit.spec.tsx b/frontend/src/metabase/search/components/SearchSidebar/tests/premium.unit.spec.tsx
index e5f7816f533..822c6d6a5ee 100644
--- a/frontend/src/metabase/search/components/SearchSidebar/tests/premium.unit.spec.tsx
+++ b/frontend/src/metabase/search/components/SearchSidebar/tests/premium.unit.spec.tsx
@@ -7,7 +7,7 @@ const setupPremium = async (opts?: SearchSidebarSetupOptions) => {
setup({
...opts,
tokenFeatures: createMockTokenFeatures({ content_verification: true }),
- hasEnterprisePlugins: true,
+ enterprisePlugins: ["content_verification"],
});
};
diff --git a/frontend/src/metabase/search/components/SearchSidebar/tests/setup.tsx b/frontend/src/metabase/search/components/SearchSidebar/tests/setup.tsx
index 499f7440a2e..2234a71e2b2 100644
--- a/frontend/src/metabase/search/components/SearchSidebar/tests/setup.tsx
+++ b/frontend/src/metabase/search/components/SearchSidebar/tests/setup.tsx
@@ -1,4 +1,4 @@
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import { setupDatabasesEndpoints } from "__support__/server-mocks";
import { mockSettings } from "__support__/settings";
import { renderWithProviders } from "__support__/ui";
@@ -13,7 +13,7 @@ import { createMockState } from "metabase-types/store/mocks";
export interface SearchSidebarSetupOptions {
tokenFeatures?: TokenFeatures;
- hasEnterprisePlugins?: boolean;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
value?: URLSearchFilterQueryParams;
onChange?: (filters: URLSearchFilterQueryParams) => void;
}
@@ -22,7 +22,7 @@ const TEST_DATABASE = createMockDatabase();
export const setup = ({
tokenFeatures = createMockTokenFeatures(),
- hasEnterprisePlugins = false,
+ enterprisePlugins,
value = {},
onChange = jest.fn(),
}: SearchSidebarSetupOptions = {}) => {
@@ -34,8 +34,10 @@ export const setup = ({
settings,
});
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
+ if (enterprisePlugins) {
+ enterprisePlugins.forEach((plugin) => {
+ setupEnterpriseOnlyPlugin(plugin);
+ });
}
renderWithProviders(<SearchSidebar value={value} onChange={onChange} />, {
diff --git a/frontend/src/metabase/selectors/whitelabel/tests/enterprise.unit.spec.ts b/frontend/src/metabase/selectors/whitelabel/tests/enterprise.unit.spec.ts
index 861df1d48e1..ec156915cda 100644
--- a/frontend/src/metabase/selectors/whitelabel/tests/enterprise.unit.spec.ts
+++ b/frontend/src/metabase/selectors/whitelabel/tests/enterprise.unit.spec.ts
@@ -10,7 +10,7 @@ import type { SetupOpts } from "./setup";
import { setup as baseSetup } from "./setup";
function setup(opts: SetupOpts = {}) {
- return baseSetup({ hasEnterprisePlugins: true, ...opts });
+ return baseSetup({ ...opts });
}
describe("getWhiteLabeledLoadingMessage (EE without token)", () => {
diff --git a/frontend/src/metabase/selectors/whitelabel/tests/premium.unit.spec.ts b/frontend/src/metabase/selectors/whitelabel/tests/premium.unit.spec.ts
index ec95caf1afc..87ecea13797 100644
--- a/frontend/src/metabase/selectors/whitelabel/tests/premium.unit.spec.ts
+++ b/frontend/src/metabase/selectors/whitelabel/tests/premium.unit.spec.ts
@@ -11,8 +11,8 @@ import { setup as baseSetup } from "./setup";
function setup(opts: SetupOpts = {}) {
return baseSetup({
- hasEnterprisePlugins: true,
tokenFeatures: { whitelabel: true },
+ enterprisePlugins: ["whitelabel"],
...opts,
});
}
diff --git a/frontend/src/metabase/selectors/whitelabel/tests/setup.tsx b/frontend/src/metabase/selectors/whitelabel/tests/setup.tsx
index 18776cbf3e8..099b2c2320d 100644
--- a/frontend/src/metabase/selectors/whitelabel/tests/setup.tsx
+++ b/frontend/src/metabase/selectors/whitelabel/tests/setup.tsx
@@ -1,6 +1,6 @@
/* istanbul ignore file */
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import { mockSettings } from "__support__/settings";
import { renderWithProviders } from "__support__/ui";
import type { LoadingMessage, TokenFeatures } from "metabase-types/api";
@@ -12,7 +12,7 @@ export interface SetupOpts {
applicationName?: string;
showMetabaseLinks?: boolean;
tokenFeatures?: Partial<TokenFeatures>;
- hasEnterprisePlugins?: boolean;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
}
export function setup({
@@ -20,7 +20,7 @@ export function setup({
applicationName = "Metabase",
showMetabaseLinks = true,
tokenFeatures = {},
- hasEnterprisePlugins = false,
+ enterprisePlugins = [],
}: SetupOpts = {}) {
const state = createMockState({
settings: mockSettings({
@@ -31,9 +31,9 @@ export function setup({
}),
});
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
- }
+ enterprisePlugins.forEach((plugin) => {
+ setupEnterpriseOnlyPlugin(plugin);
+ });
const {
store: { getState },
diff --git a/frontend/src/metabase/setup/tests/enterprise.unit.spec.tsx b/frontend/src/metabase/setup/tests/enterprise.unit.spec.tsx
index 5802348ab9f..2399fa97371 100644
--- a/frontend/src/metabase/setup/tests/enterprise.unit.spec.tsx
+++ b/frontend/src/metabase/setup/tests/enterprise.unit.spec.tsx
@@ -27,7 +27,7 @@ jest.mock("../analytics", () => ({
const setupEnterprise = (opts?: SetupOpts) => {
return setup({
...opts,
- hasEnterprisePlugins: true,
+ enterprisePlugins: "*", // we need the license and currently it's enabled at import time with setupEnterprisePlugins :/,
});
};
diff --git a/frontend/src/metabase/setup/tests/premium-pro-cloud.unit.spec.tsx b/frontend/src/metabase/setup/tests/premium-pro-cloud.unit.spec.tsx
index 7f4a34ac061..aa1b1934cb2 100644
--- a/frontend/src/metabase/setup/tests/premium-pro-cloud.unit.spec.tsx
+++ b/frontend/src/metabase/setup/tests/premium-pro-cloud.unit.spec.tsx
@@ -16,7 +16,6 @@ import {
const setupPremium = (opts?: SetupOpts) => {
return setup({
...opts,
- hasEnterprisePlugins: true,
tokenFeatures: createMockTokenFeatures({ hosting: true, embedding: true }),
});
};
diff --git a/frontend/src/metabase/setup/tests/premium-pro-selfhosted.unit.spec.tsx b/frontend/src/metabase/setup/tests/premium-pro-selfhosted.unit.spec.tsx
index 6bedc97baec..20e874f680c 100644
--- a/frontend/src/metabase/setup/tests/premium-pro-selfhosted.unit.spec.tsx
+++ b/frontend/src/metabase/setup/tests/premium-pro-selfhosted.unit.spec.tsx
@@ -18,7 +18,6 @@ import {
const setupPremium = (opts?: SetupOpts) => {
return setup({
...opts,
- hasEnterprisePlugins: true,
tokenFeatures: createMockTokenFeatures({ embedding: true }),
});
};
diff --git a/frontend/src/metabase/setup/tests/premium-starter-cloud.unit.spec.tsx b/frontend/src/metabase/setup/tests/premium-starter-cloud.unit.spec.tsx
index 58ca629649a..40e9fa808ce 100644
--- a/frontend/src/metabase/setup/tests/premium-starter-cloud.unit.spec.tsx
+++ b/frontend/src/metabase/setup/tests/premium-starter-cloud.unit.spec.tsx
@@ -16,7 +16,6 @@ import {
const setupPremium = (opts?: SetupOpts) => {
return setup({
...opts,
- hasEnterprisePlugins: true,
tokenFeatures: createMockTokenFeatures({ hosting: true }),
});
};
diff --git a/frontend/src/metabase/setup/tests/setup.tsx b/frontend/src/metabase/setup/tests/setup.tsx
index 2213e472db1..01e4194aa41 100644
--- a/frontend/src/metabase/setup/tests/setup.tsx
+++ b/frontend/src/metabase/setup/tests/setup.tsx
@@ -2,7 +2,10 @@ import { waitFor, within } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import fetchMock from "fetch-mock";
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import {
+ setupEnterpriseOnlyPlugin,
+ setupEnterprisePlugins,
+} from "__support__/enterprise";
import {
setupPropertiesEndpoints,
setupSettingsEndpoints,
@@ -29,13 +32,13 @@ import type { SetupStep } from "../types";
export interface SetupOpts {
step?: SetupStep;
tokenFeatures?: TokenFeatures;
- hasEnterprisePlugins?: boolean;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][] | "*";
settingOverrides?: SettingDefinition[];
}
export async function setup({
tokenFeatures = createMockTokenFeatures(),
- hasEnterprisePlugins = false,
+ enterprisePlugins,
settingOverrides = [],
}: SetupOpts = {}) {
localStorage.clear();
@@ -53,8 +56,12 @@ export async function setup({
),
});
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
+ if (enterprisePlugins) {
+ if (enterprisePlugins === "*") {
+ setupEnterprisePlugins();
+ } else {
+ enterprisePlugins.forEach(setupEnterpriseOnlyPlugin);
+ }
}
fetchMock.post("path:/api/session/password-check", { valid: true });
diff --git a/frontend/src/metabase/visualizations/visualizations/Map/CustomMapFooter/tests/enterprise.unit.spec.ts b/frontend/src/metabase/visualizations/visualizations/Map/CustomMapFooter/tests/enterprise.unit.spec.ts
index 10d8db483a4..fe7e50499be 100644
--- a/frontend/src/metabase/visualizations/visualizations/Map/CustomMapFooter/tests/enterprise.unit.spec.ts
+++ b/frontend/src/metabase/visualizations/visualizations/Map/CustomMapFooter/tests/enterprise.unit.spec.ts
@@ -4,7 +4,7 @@ import type { SetupOpts } from "./setup";
import { setup as baseSetup } from "./setup";
function setup(opts: SetupOpts) {
- baseSetup({ hasEnterprisePlugins: true, ...opts });
+ baseSetup({ ...opts });
}
describe("CustomMapFooter (EE without token)", () => {
diff --git a/frontend/src/metabase/visualizations/visualizations/Map/CustomMapFooter/tests/premium.unit.spec.ts b/frontend/src/metabase/visualizations/visualizations/Map/CustomMapFooter/tests/premium.unit.spec.ts
index 3ced7a9e57e..ca73e87a11f 100644
--- a/frontend/src/metabase/visualizations/visualizations/Map/CustomMapFooter/tests/premium.unit.spec.ts
+++ b/frontend/src/metabase/visualizations/visualizations/Map/CustomMapFooter/tests/premium.unit.spec.ts
@@ -5,8 +5,8 @@ import { setup as baseSetup } from "./setup";
function setup(opts: SetupOpts) {
baseSetup({
- hasEnterprisePlugins: true,
tokenFeatures: { whitelabel: true },
+ enterprisePlugins: ["whitelabel"],
...opts,
});
}
diff --git a/frontend/src/metabase/visualizations/visualizations/Map/CustomMapFooter/tests/setup.tsx b/frontend/src/metabase/visualizations/visualizations/Map/CustomMapFooter/tests/setup.tsx
index 63a6c601873..b6838bff3fd 100644
--- a/frontend/src/metabase/visualizations/visualizations/Map/CustomMapFooter/tests/setup.tsx
+++ b/frontend/src/metabase/visualizations/visualizations/Map/CustomMapFooter/tests/setup.tsx
@@ -1,6 +1,6 @@
import { Route } from "react-router";
-import { setupEnterprisePlugins } from "__support__/enterprise";
+import { setupEnterpriseOnlyPlugin } from "__support__/enterprise";
import { mockSettings } from "__support__/settings";
import { renderWithProviders } from "__support__/ui";
import type { TokenFeatures } from "metabase-types/api";
@@ -15,15 +15,15 @@ import { CustomMapFooter } from "../CustomMapFooter";
export interface SetupOpts {
isAdmin: boolean;
showMetabaseLinks: boolean;
- hasEnterprisePlugins?: boolean;
tokenFeatures?: Partial<TokenFeatures>;
+ enterprisePlugins?: Parameters<typeof setupEnterpriseOnlyPlugin>[0][];
}
export const setup = ({
isAdmin,
showMetabaseLinks = true,
- hasEnterprisePlugins,
tokenFeatures = {},
+ enterprisePlugins = [],
}: SetupOpts) => {
const state = createMockState({
currentUser: createMockUser({ is_superuser: isAdmin }),
@@ -33,9 +33,9 @@ export const setup = ({
}),
});
- if (hasEnterprisePlugins) {
- setupEnterprisePlugins();
- }
+ enterprisePlugins.forEach((plugin) => {
+ setupEnterpriseOnlyPlugin(plugin);
+ });
renderWithProviders(<Route path="*" component={CustomMapFooter} />, {
storeInitialState: state,
diff --git a/frontend/test/__support__/enterprise-typed.ts b/frontend/test/__support__/enterprise-typed.ts
index 5ac387df9f1..2a9e4c2c1f3 100644
--- a/frontend/test/__support__/enterprise-typed.ts
+++ b/frontend/test/__support__/enterprise-typed.ts
@@ -51,6 +51,7 @@ export const ENTERPRISE_PLUGIN_NAME_MAPPING = {
google_drive: "metabase-enterprise/google_drive",
content_verification: "metabase-enterprise/content_verification",
moderation: "metabase-enterprise/moderation",
+ tenants: "metabase-enterprise/tenants",
// Embedding SDK specific plugins
sdk_subscriptions: "embedding-sdk-ee/subscriptions",
diff --git a/frontend/test/__support__/enterprise.js b/frontend/test/__support__/enterprise.js
index ed29f726c20..b86dc892c5d 100644
--- a/frontend/test/__support__/enterprise.js
+++ b/frontend/test/__support__/enterprise.js
@@ -40,8 +40,15 @@ export function setupEnterprisePlugins() {
initializePlugins?.();
}
-// function is used for optimization, so we don't need to import all plugins
/**
+ * Import only the specified enterprise-only plugin and initialize it.
+ *
+ * Disclaimer: this can lead to unexpected behavior if the plugin being initialized
+ * has dependencies on other enterprise plugins that are not initialized.
+ *
+ * You can resort to using `setupEnterprisePlugins` instead to initialize all enterprise plugins.
+ *
+ * @see https://github.com/metabase/metabase/blob/da3cad00d3dafe3ce7d14d112f115ec5d7fce8a9/plugin_dependencies.md
*
* @param {import("./enterprise-typed").ENTERPRISE_PLUGIN_NAME} pluginName
*/