Skip to content
Snippets Groups Projects
Unverified Commit 29a24980 authored by Nicolò Pretto's avatar Nicolò Pretto Committed by GitHub
Browse files

Point to a solution when the "Unknown premium setting xxx" is shown during tests (#48526)

parent fc43d3cd
No related branches found
No related tags found
No related merge requests found
import { hasAnySsoFeature } from "metabase/common/utils/plan";
import { isTest } from "metabase/env";
import MetabaseSettings from "metabase/lib/settings";
import type { TokenFeature } from "metabase-types/api";
export function hasPremiumFeature(feature: TokenFeature) {
const hasFeature = MetabaseSettings.get("token-features")?.[feature];
if (hasFeature == null) {
console.warn("Unknown premium feature", feature);
console.warn(
`Unknown premium feature: '${feature}'.`,
isTest
? "\nDid you forget to use `mockSettings` instead of `createMockSettings` when testing paid features?"
: "",
);
}
return hasFeature;
}
......
......@@ -4,6 +4,10 @@ import type { Settings } from "metabase-types/api";
import { createMockSettings } from "metabase-types/api/mocks";
import { createMockSettingsState } from "metabase-types/store/mocks";
/**
* This function mocks the settings also in MetabaseSettings,
* without that, you'll get the annoying "Unknown premium feature xxx" warning.
*/
export function mockSettings(
params: Partial<Settings | EnterpriseSettings> = {},
) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment