🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
fix(storybook): remove flaky chart interaction tests (#18556)
Tobias Wochingerc940f360605b
diff --git a/web/src/components/design-system/charts/AreaChart/AreaChart.stories.tsx b/web/src/components/design-system/charts/AreaChart/AreaChart.stories.tsxindex 5ba2ec7616..88c81b5538 100644--- a/web/src/components/design-system/charts/AreaChart/AreaChart.stories.tsx+++ b/web/src/components/design-system/charts/AreaChart/AreaChart.stories.tsx@@ -213,27 +213,7 @@ export const SingleValueAnchor = meta.story({});export const Intermittent = meta.story({- name: "(Test) Intermittent",args: { scenario: "gaps" },- play: async ({ canvasElement }) => {- const labelsBeforeHover = canvasElement.querySelectorAll(- '[data-x-axis-label=""]',- ).length;- const hoverArea = canvasElement.querySelectorAll<SVGRectElement>(- 'rect[fill="transparent"]',- )[1];- if (!hoverArea) throw new Error("Missing hover area for data gap");- await userEvent.hover(hoverArea);- const tooltip = within(document.body).getByRole("tooltip");- await expect(tooltip).toHaveTextContent("No data available");- await expect(tooltip).toHaveTextContent("Sep 2, 2026");- const labels = Array.from(- canvasElement.querySelectorAll('[data-x-axis-label=""]'),- (label) => label.textContent,- );- await expect(labels).toHaveLength(labelsBeforeHover);- await expect(new Set(labels).size).toBe(labels.length);- },});export const DenseCategories = meta.story({@@ -366,12 +346,6 @@ export const StackedAreas = meta.story({Number(apiPoint.getAttribute("cy")),0,);- workerPoint.focus();- const tooltip = await within(canvasElement.ownerDocument.body).findByRole(- "tooltip",- );- await expect(tooltip).toHaveTextContent("Worker");- await expect(tooltip).toHaveTextContent("48.0 requests");await userEvent.click(await canvas.findByRole("button", { name: "Hide API" }),);@@ -486,21 +460,7 @@ export const LimitedVisibleSeries = meta.story({});export const GapsAndIsolatedPoints = meta.story({- name: "(Test) Gaps And Isolated Points",args: { scenario: "gaps" },- play: async ({ canvasElement }) => {- await expect(- canvasElement.querySelectorAll('circle[fill="#3a3dee"][r="4"]'),- ).toHaveLength(3);- const firstPoint = within(canvasElement).getByRole("graphics-symbol", {- name: /API 8\.0 requests/,- });- firstPoint.focus();- const tooltip = await within(canvasElement.ownerDocument.body).findByRole(- "tooltip",- );- await expect(tooltip).toHaveTextContent("8.0 requests");- },});export const ConnectNulls = meta.story({diff --git a/web/src/components/design-system/charts/BarChart/BarChart.stories.tsx b/web/src/components/design-system/charts/BarChart/BarChart.stories.tsxindex be7690278f..6dbb9c0c66 100644--- a/web/src/components/design-system/charts/BarChart/BarChart.stories.tsx+++ b/web/src/components/design-system/charts/BarChart/BarChart.stories.tsx@@ -107,63 +107,6 @@ export const KeyboardFocus = meta.story({},});-export const CategoryHoverArea = meta.story({- name: "(Test) Category Hover Area",- play: async ({ canvasElement }) => {- const area = canvasElement.querySelector<SVGRectElement>(- "[data-bar-hover-area]",- );- if (!area) throw new Error("Hover area not found");- await userEvent.hover(area);- const tooltip = await within(canvasElement.ownerDocument.body).findByRole(- "tooltip",- );- await expect(tooltip).toHaveTextContent("Alpha");- const copy = spyOn(navigator.clipboard, "writeText").mockResolvedValue();- try {- await userEvent.click(area);- await expect(copy).toHaveBeenCalledWith("Alpha");- } finally {- copy.mockRestore();- }- },-});--export const TooltipFollowsBar = meta.story({- name: "(Test) Tooltip Follows Bar",- play: async ({ canvasElement }) => {- const canvas = within(canvasElement);- const bars = canvas.getAllByRole("graphics-symbol");- const areas = canvasElement.querySelectorAll<SVGRectElement>(- "[data-bar-hover-area]",- );- for (let index = 0; index < bars.length; index++) {- const bar = bars[index];- const area = areas[index];- if (!bar || !area) throw new Error("Bar or hover area not found");- await userEvent.hover(area);- const tooltip = await within(canvasElement.ownerDocument.body).findByRole(- "tooltip",- );- const referenceLine = canvasElement.querySelector(- "[data-active-reference-line]",- );- if (!referenceLine) throw new Error("Reference line not found");- await expect(referenceLine.compareDocumentPosition(bar)).toBe(- Node.DOCUMENT_POSITION_FOLLOWING,- );- const areaTop = tooltip.getBoundingClientRect().top;- await userEvent.hover(bar);- await expect(tooltip.getBoundingClientRect().top).toBeCloseTo(areaTop, 0);- if (index === 0) {- await expect(- tooltip.getBoundingClientRect().bottom,- ).toBeLessThanOrEqual(bar.getBoundingClientRect().top);- }- }- },-});-export const CategoryColors = meta.story({args: {data: data.map((item, index) => ({@@ -250,25 +193,12 @@ export const ManyCategories = meta.story({});export const LongLabels = meta.story({- name: "(Test) Long Labels",args: {data: Array.from({ length: 12 }, (_, index) => ({label: `production-evaluation-run-${index + 1}-with-a-long-name`,value: 12 + index,})),},- play: async ({ canvasElement }) => {- const canvas = within(canvasElement);- const firstBar = canvas.getAllByRole("graphics-symbol")[0];- if (!firstBar) throw new Error("Bar not found");- await expect(- canvasElement.querySelector("[data-x-axis-label]"),- ).toHaveTextContent(/…$/);- await userEvent.hover(firstBar);- await expect(- canvasElement.querySelector("[data-active-x-axis-label]"),- ).toHaveTextContent("production-evaluation-run-1-with-a-long-name");- },});export const EdgeLabels = meta.story({diff --git a/web/src/components/design-system/charts/HorizontalBarChart/HorizontalBarChart.stories.tsx b/web/src/components/design-system/charts/HorizontalBarChart/HorizontalBarChart.stories.tsxindex 3270c0108b..d533569bed 100644--- a/web/src/components/design-system/charts/HorizontalBarChart/HorizontalBarChart.stories.tsx+++ b/web/src/components/design-system/charts/HorizontalBarChart/HorizontalBarChart.stories.tsx@@ -45,73 +45,6 @@ export const SideTooltip = meta.story({},});-export const HoverTransition = meta.story({- name: "(Test) Hover Transition",- play: async ({ canvasElement }) => {- const bars =- canvasElement.querySelectorAll<SVGRectElement>("[data-bar-fill]");- const first = bars[0];- const second = bars[1];- if (!first || !second) throw new Error("Bars not found");- const hoverArea = first.parentElement?.querySelector<SVGRectElement>(- 'rect[fill="transparent"][aria-hidden="true"]',- );- if (!hoverArea) throw new Error("Hover area not found");- await userEvent.hover(hoverArea);- await expect(second).toHaveAttribute(- "fill",- expect.stringContaining("20%"),- );- },-});--export const HoverAcrossRowGap = meta.story({- name: "(Test) Hover Across Row Gap",- play: async ({ canvasElement }) => {- const bars =- canvasElement.querySelectorAll<SVGRectElement>("[data-bar-fill]");- const first = bars[0];- const second = bars[1];- const svg = canvasElement.querySelector<SVGSVGElement>(- "svg[aria-label='Horizontal bar chart']",- );- if (!first || !second || !svg) throw new Error("Chart bars not found");- const hoverArea = first.parentElement?.querySelector<SVGRectElement>(- 'rect[fill="transparent"][aria-hidden="true"]',- );- if (!hoverArea) throw new Error("Hover area not found");- await userEvent.hover(hoverArea);- const firstBounds = first.getBoundingClientRect();- const secondBounds = second.getBoundingClientRect();- const gapTarget = canvasElement.ownerDocument.elementFromPoint(- firstBounds.left + 20,- (firstBounds.bottom + secondBounds.top) / 2,- );- if (!gapTarget || !svg.contains(gapTarget)) {- throw new Error("Gap is not part of the chart hit area");- }- await userEvent.hover(gapTarget);- await expect(second).toHaveAttribute(- "fill",- expect.stringContaining("20%"),- );- await expect(- within(canvasElement.ownerDocument.body).getByRole("tooltip"),- ).toHaveTextContent("Alpha");- const secondHoverArea = second.parentElement?.querySelector<SVGRectElement>(- 'rect[fill="transparent"][aria-hidden="true"]',- );- if (!secondHoverArea) throw new Error("Second hover area not found");- await userEvent.hover(secondHoverArea);- await expect(first).toHaveAttribute("fill", expect.stringContaining("20%"));- await userEvent.unhover(secondHoverArea);- await expect(first).not.toHaveAttribute(- "fill",- expect.stringContaining("20%"),- );- },-});-export const FillsAvailableHeight = meta.story({name: "(Test) Fills Available Height",play: async ({ canvasElement }) => {diff --git a/web/src/components/design-system/charts/LineChart/LineChart.stories.tsx b/web/src/components/design-system/charts/LineChart/LineChart.stories.tsxindex 45520b7ab3..d57ab50b16 100644--- a/web/src/components/design-system/charts/LineChart/LineChart.stories.tsx+++ b/web/src/components/design-system/charts/LineChart/LineChart.stories.tsx@@ -463,19 +463,20 @@ export const KeyboardFocus = meta.story({firstPoint.focus();- const activeLabel = await waitFor(() => {+ await waitFor(() => {const label = canvasElement.querySelector("[data-active-x-axis-label]");expect(label).toHaveTextContent("Sep 1");- return label;+ expect(label).toHaveAttribute("font-weight", "700");+ expect(+ canvasElement.querySelector("[data-active-x-axis-label-background]"),+ ).not.toBeInTheDocument();});- await expect(activeLabel).toHaveAttribute("font-weight", "700");- await expect(- canvasElement.querySelector("[data-active-x-axis-label-background]"),- ).not.toBeInTheDocument();- const tooltip = await within(canvasElement.ownerDocument.body).findByRole(- "tooltip",- );+ const tooltipHeading = await within(+ canvasElement.ownerDocument.body,+ ).findByText("Sep 1, 2026");+ const tooltip = tooltipHeading.closest('[role="tooltip"]');+ if (!tooltip) throw new Error("Tooltip not found");await expect(tooltip).toHaveTextContent("API");await expect(tooltip).toHaveTextContent("$18.00");diff --git a/web/src/components/design-system/charts/StackedBarChart/StackedBarChart.stories.tsx b/web/src/components/design-system/charts/StackedBarChart/StackedBarChart.stories.tsxindex a637890629..6e3b4c8586 100644--- a/web/src/components/design-system/charts/StackedBarChart/StackedBarChart.stories.tsx+++ b/web/src/components/design-system/charts/StackedBarChart/StackedBarChart.stories.tsx@@ -1,5 +1,5 @@import preview from "../../../../../.storybook/preview";-import { expect, userEvent, within } from "storybook/test";+import { expect, userEvent, waitFor, within } from "storybook/test";import { StackedBarChart } from "./StackedBarChart";@@ -61,12 +61,14 @@ export const StackingAndTooltip = meta.story({Number(worker.getAttribute("y")) + Number(worker.getAttribute("height")),).toBeCloseTo(Number(api.getAttribute("y")), 0);worker.focus();- const tooltip = await within(canvasElement.ownerDocument.body).findByRole(- "tooltip",- );- await expect(tooltip).toHaveTextContent("Monday");- await expect(tooltip).toHaveTextContent("API");- await expect(tooltip).toHaveTextContent("Worker");+ await waitFor(() => {+ const tooltip = within(canvasElement.ownerDocument.body).getByRole(+ "tooltip",+ );+ expect(tooltip).toHaveTextContent("Monday");+ expect(tooltip).toHaveTextContent("API");+ expect(tooltip).toHaveTextContent("Worker");+ });},});@@ -194,17 +196,6 @@ export const MissingBuckets = meta.story({await expect(canvas.getByRole("button", { name: "Hide Worker" }),).toHaveTextContent("Sum: 5");- const emptyBucket = canvasElement.querySelectorAll<SVGRectElement>(- 'rect[fill="transparent"]',- )[0];- if (!emptyBucket) throw new Error("Missing empty bucket hover area");- await userEvent.hover(emptyBucket);- await expect(- within(canvasElement.ownerDocument.body).getByRole("tooltip"),- ).toHaveTextContent("No data available");- await expect(- canvasElement.querySelector("[data-active-reference-line]"),- ).toBeInTheDocument();},});