Skip to content

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

Skip unused addons and font loads in Loki screenshot runs (#83068)

Fraser145357fbb1e0
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Number.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Number.png
index 7d12d35ab3d..b162dc0a4a4 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Number.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Number.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Text_With_Value.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Text_With_Value.png
index 2854e744735..f69dfe96bdd 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Text_With_Value.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Dark_Theme_Text_With_Value.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Number.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Number.png
index ba73e578e59..accee309b28 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Number.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Number.png differ
diff --git a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Text_With_Value.png b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Text_With_Value.png
index 01c9b6809e2..3d370685223 100644
Binary files a/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Text_With_Value.png and b/.loki/reference/chrome_laptop_App_Embed_PublicOrEmbeddedDashboardView_filters_Light_Theme_Text_With_Value.png differ
diff --git a/.storybook/main.ts b/.storybook/main.ts
index 2670edb78a1..284d93114cf 100644
--- a/.storybook/main.ts
+++ b/.storybook/main.ts
@@ -61,6 +61,15 @@ const config: StorybookConfig = {
build: {
test: {
disableTreeShaking: false,
+ // Setting this replaces the addons --test disables by default,
+ // so the first three repeat Storybook's defaults.
+ disabledAddons: [
+ "@storybook/addon-docs",
+ "@storybook/addon-essentials/docs",
+ "@storybook/addon-coverage",
+ "@storybook/addon-a11y",
+ "@storybook/addon-interactions",
+ ],
},
},
typescript: {
diff --git a/.storybook/preview.tsx b/.storybook/preview.tsx
index f64d830ca2d..b236d75dc37 100644
--- a/.storybook/preview.tsx
+++ b/.storybook/preview.tsx
@@ -49,16 +49,17 @@ if (
document.head.appendChild(fontFaceStyle);
}
-// Force every registered font to load before the story renders. This ensures we
-// use same fonts for tests every time, instead of using generic fallback
-// family like `sans-serif` which might resolve to different specific fonts (depending
-// on what available on current machine) which might have different metrics, in turn
-// producing inconsistent behavior in code relying on measuring text (e.g., column
-// autosize in table visualization). Awaiting all loads here makes measurements
-// deterministic across platforms.
+const PRELOADED_FONT_FAMILIES = ["Lato", "JetBrains Mono"];
+
+// Load the app's text and monospace fonts before the story renders,
+// so code that measures text, like the table's column autosize, gets the same metrics on every machine.
const fontsReady = async () => {
const loads: Promise<unknown>[] = [];
- document.fonts.forEach((face) => loads.push(face.load()));
+ document.fonts.forEach((face) => {
+ if (PRELOADED_FONT_FAMILIES.includes(face.family)) {
+ loads.push(face.load());
+ }
+ });
await Promise.all(loads);
};
diff --git a/frontend/src/metabase/public/containers/PublicOrEmbeddedDashboard/PublicOrEmbeddedDashboardView-filters.stories.tsx b/frontend/src/metabase/public/containers/PublicOrEmbeddedDashboard/PublicOrEmbeddedDashboardView-filters.stories.tsx
index 2a31987af98..994d665d768 100644
--- a/frontend/src/metabase/public/containers/PublicOrEmbeddedDashboard/PublicOrEmbeddedDashboardView-filters.stories.tsx
+++ b/frontend/src/metabase/public/containers/PublicOrEmbeddedDashboard/PublicOrEmbeddedDashboardView-filters.stories.tsx
@@ -20,6 +20,7 @@ import {
} from "metabase/dashboard/context/mock-context";
import { MetabaseReduxProvider } from "metabase/redux";
import { stableStringify } from "metabase/utils/objects";
+import { checkNotNull } from "metabase/utils/types";
import { BarChart } from "metabase/visualizations/visualizations/BarChart";
import { Table } from "metabase/visualizations/visualizations/Table/Table";
import TABLE_RAW_SERIES from "metabase/visualizations/visualizations/Table/stories-data/orders-with-people.json";
@@ -398,25 +399,19 @@ const createDefaultArgs = ({
};
function getLastPopover() {
- // Unjustified type cast. FIXME
- const lastPopover = Array.from(
- document.documentElement.querySelectorAll(
- '[data-element-id="mantine-popover"]',
- ),
- ).at(-1) as HTMLElement;
-
- return within(lastPopover);
+ return within(getLastPopoverElement());
}
function getLastPopoverElement() {
- // Unjustified type cast. FIXME
- const lastPopover = Array.from(
- document.documentElement.querySelectorAll(
- '[data-element-id="mantine-popover"]',
- ),
- ).at(-1) as HTMLElement;
+ const popovers = document.documentElement.querySelectorAll<HTMLElement>(
+ '[data-element-id="mantine-popover"]',
+ );
+ // Mantine renders an input's options dropdown as a hidden popover when there are no options.
+ const lastPopover = Array.from(popovers)
+ .filter((popover) => popover.checkVisibility())
+ .at(-1);
- return lastPopover;
+ return checkNotNull(lastPopover);
}
export const LightThemeText = {