Skip unused addons and font loads in Loki screenshot runs (#83068)
|
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 74 KiB |
|
Before Width: | Height: | Size: 73 KiB After Width: | Height: | Size: 75 KiB |
|
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 72 KiB |
|
Before Width: | Height: | Size: 72 KiB After Width: | Height: | Size: 74 KiB |
@@ -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: {
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
|
||||
@@ -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(
|
||||
const popovers = document.documentElement.querySelectorAll<HTMLElement>(
|
||||
'[data-element-id="mantine-popover"]',
|
||||
),
|
||||
).at(-1) as HTMLElement;
|
||||
);
|
||||
// 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 = {
|
||||
|
||||