Skip to content
Snippets Groups Projects
Unverified Commit 992b2e89 authored by Phoomparin Mano's avatar Phoomparin Mano Committed by GitHub
Browse files

fix(sdk): load custom font files when font is set to custom (#44432)

* load custom font family

* always return custom font family

* add tests for returning custom font family
parent 488e08a7
No related branches found
No related tags found
No related merge requests found
import { renderWithProviders } from "__support__/ui";
import { SdkContentWrapper } from "embedding-sdk/components/private/SdkContentWrapper";
import {
createMockSettingsState,
createMockState,
} from "metabase-types/store/mocks";
describe("SdkContentWrapper", () => {
it("injects the font-face declaration when available", () => {
const state = createMockState({
settings: createMockSettingsState({
"application-font-files": [
{
src: "https://example.com/foo.woff2",
fontFormat: "woff2",
fontWeight: 700,
},
],
}),
});
renderWithProviders(<SdkContentWrapper />, { storeInitialState: state });
const rules = Array.from(document.styleSheets).flatMap(sheet =>
Array.from(sheet.cssRules || []),
);
const fontFaceRule = rules.find(
rule =>
rule.constructor.name === "CSSFontFaceRule" &&
rule.cssText.includes("foo.woff2"),
)!;
expect(fontFaceRule).toBeDefined();
expect(fontFaceRule.cssText).toContain("font-weight: 700");
});
});
......@@ -17,13 +17,6 @@ export const getFont = createSelector(
},
);
export const getFontFiles = createSelector(
[getSettings, getEmbedOptions],
(settings, embedOptions) => {
if (embedOptions.font) {
return [];
} else {
return settings["application-font-files"];
}
},
);
export const getFontFiles = createSelector([getSettings], settings => {
return settings["application-font-files"];
});
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