Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(quill-charts): rename the testing helpers away from hog chart (#123132)

Sam Pennington5b4df6e9db02
diff --git a/frontend/src/lib/components/AppMetrics/AppMetricsTimeSeriesChart.test.tsx b/frontend/src/lib/components/AppMetrics/AppMetricsTimeSeriesChart.test.tsx
index 2508e6254115..07b43df3f074 100644
--- a/frontend/src/lib/components/AppMetrics/AppMetricsTimeSeriesChart.test.tsx
+++ b/frontend/src/lib/components/AppMetrics/AppMetricsTimeSeriesChart.test.tsx
@@ -2,7 +2,7 @@ import '@testing-library/jest-dom'
import { cleanup, render, waitFor } from '@testing-library/react'
-import { ensureJsdom, getHogChart, hoverAtIndex, hoverUntilTooltip } from '@posthog/quill-charts/testing'
+import { ensureJsdom, getChart, hoverAtIndex, hoverUntilTooltip } from '@posthog/quill-charts/testing'
import { AppMetricsTimeSeriesChart } from './AppMetricsTimeSeriesChart'
@@ -25,7 +25,7 @@ describe('AppMetricsTimeSeriesChart', () => {
/>
</div>
)
- const chart = getHogChart(container)
+ const chart = getChart(container)
const tooltip = await hoverUntilTooltip(chart.element, 0, labels.length)
expect(tooltip).toHaveTextContent('Sun, Nov 1, 01:00 (-07:00)')
diff --git a/frontend/src/lib/components/Sparkline.test.tsx b/frontend/src/lib/components/Sparkline.test.tsx
index 1b154e9ae88b..f4b1ec939b0e 100644
--- a/frontend/src/lib/components/Sparkline.test.tsx
+++ b/frontend/src/lib/components/Sparkline.test.tsx
@@ -4,7 +4,7 @@ import { cleanup, render, waitFor } from '@testing-library/react'
import {
createDefaultTooltipAccessor,
- getHogChart,
+ getChart,
hoverUntilTooltip,
setupJsdom,
setupSyncRaf,
@@ -49,7 +49,7 @@ describe('Sparkline', () => {
},
])('normalizes $shape into $seriesCount quill series', ({ data, seriesCount }) => {
renderSparkline({ data, labels: LABELS })
- expect(getHogChart().seriesCount).toBe(seriesCount)
+ expect(getChart().seriesCount).toBe(seriesCount)
})
it('wires tooltip formatting and zero-row filtering through to the quill tooltip', async () => {
@@ -64,7 +64,7 @@ describe('Sparkline', () => {
renderLabel: (label) => `Day: ${label}`,
renderTooltipValue: (value) => `$${value.toFixed(2)}`,
})
- const chart = getHogChart()
+ const chart = getChart()
const tooltip = createDefaultTooltipAccessor(await hoverUntilTooltip(chart.element, 2, LABELS.length))
// The portal mounts before its content commits, so poll until the header lands.
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlBarGraph.test.tsx b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlBarGraph.test.tsx
index f584e2ef041b..9cf16dfae891 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlBarGraph.test.tsx
+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlBarGraph.test.tsx
@@ -9,7 +9,7 @@ import { NodeKind, ChartSettings } from '~/queries/schema/schema-general'
import {
type DataVizFixture,
buildDataVisualizationQuery,
- getHogChart,
+ getChart,
HOVER,
MONTHS,
renderDataVisualization,
@@ -142,11 +142,9 @@ describe('SqlBarGraph', () => {
},
})
const canvas = await screen.findByLabelText(/chart with 2 data series/i)
- expect([...getHogChart().xTicks(), ...getHogChart().yTicks()].some((tick) => /^202[56]-/.test(tick))).toBe(
- false
- )
+ expect([...getChart().xTicks(), ...getChart().yTicks()].some((tick) => /^202[56]-/.test(tick))).toBe(false)
if (dateBucket === 'year') {
- expect(getHogChart().xTicks()).toContain('2025')
+ expect(getChart().xTicks()).toContain('2025')
} else if (chartType !== ChartDisplayType.ActionsBarValue) {
expect((await sqlChart.hoverTooltip(HOVER, dates.length)).label()).toBe('Dec 1, 00:00')
}
@@ -205,7 +203,7 @@ describe('SqlBarGraph', () => {
},
})
await screen.findByLabelText(/chart with/i)
- await waitFor(() => expect(getHogChart().yTicks()).toEqual(['Same label', 'Same label']))
+ await waitFor(() => expect(getChart().yTicks()).toEqual(['Same label', 'Same label']))
})
it.each([
@@ -221,7 +219,7 @@ describe('SqlBarGraph', () => {
renderBar(display, { yAxis: [{ column: 'a' }, { column: 'b' }], ...extra }, twoSeries())
await screen.findByLabelText(/chart with 2 data series/i)
- await waitFor(() => expect(getHogChart().yTicks().length).toBeGreaterThan(0))
+ await waitFor(() => expect(getChart().yTicks().length).toBeGreaterThan(0))
})
it('renders category labels on the vertical axis for horizontal bars', async () => {
@@ -232,10 +230,10 @@ describe('SqlBarGraph', () => {
)
await screen.findByLabelText(/chart with/i)
- await waitFor(() => expect(getHogChart().xTicks().length).toBeGreaterThan(0))
- expect(getHogChart().yTicks()).toContain('Oct 1, 2025')
+ await waitFor(() => expect(getChart().xTicks().length).toBeGreaterThan(0))
+ expect(getChart().yTicks()).toContain('Oct 1, 2025')
expect(
- getHogChart()
+ getChart()
.xTicks()
.map((tick) => tick.startsWith('$'))
).not.toContain(false)
@@ -249,8 +247,8 @@ describe('SqlBarGraph', () => {
)
await screen.findByLabelText(/chart with 2 data series/i)
- await waitFor(() => expect(getHogChart().yTicks().length).toBeGreaterThan(0))
- for (const tick of getHogChart().yTicks()) {
+ await waitFor(() => expect(getChart().yTicks().length).toBeGreaterThan(0))
+ for (const tick of getChart().yTicks()) {
expect(tick).toMatch(/%$/)
}
})
@@ -276,8 +274,8 @@ describe('SqlBarGraph', () => {
)
await screen.findByLabelText(/chart with 2 data series/i)
- await waitFor(() => expect(getHogChart().hasRightAxis).toBe(true))
- const chart = getHogChart()
+ await waitFor(() => expect(getChart().hasRightAxis).toBe(true))
+ const chart = getChart()
expect(chart.yTicks().length).toBeGreaterThan(0)
expect(chart.yTicks().every((tick) => tick.startsWith('$'))).toBe(true)
const rightTicks = chart.yRightTicks()
@@ -293,8 +291,8 @@ describe('SqlBarGraph', () => {
)
await screen.findByLabelText(/chart with/i)
- await waitFor(() => expect(getHogChart().yRightTicks().length).toBeGreaterThan(0))
- expect(getHogChart().yTicks()).toHaveLength(0)
+ await waitFor(() => expect(getChart().yRightTicks().length).toBeGreaterThan(0))
+ expect(getChart().yTicks()).toHaveLength(0)
})
})
@@ -347,7 +345,7 @@ describe('SqlBarGraph', () => {
)!
fireEvent.click(bButton)
- await waitFor(() => expect(getHogChart().seriesCount).toBe(1))
+ await waitFor(() => expect(getChart().seriesCount).toBe(1))
})
})
@@ -363,7 +361,7 @@ describe('SqlBarGraph', () => {
)
await screen.findByLabelText(/chart with/i)
- const lines = getHogChart().referenceLines()
+ const lines = getChart().referenceLines()
expect(lines.map((l) => l.label)).toEqual(['Target'])
expect(lines[0].orientation).toBe(orientation)
})
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlLineGraph.test.tsx b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlLineGraph.test.tsx
index 310a100be62a..da0aec5e4782 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlLineGraph.test.tsx
+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlLineGraph.test.tsx
@@ -8,7 +8,7 @@ import { ChartSettings, ChartSettingsFormatting, VisualizationNode } from '~/que
import {
type DataVizFixture,
buildDataVisualizationQuery,
- getHogChart,
+ getChart,
HOVER,
MONTHS,
renderDataVisualization,
@@ -107,7 +107,7 @@ it.each([
})
await screen.findByLabelText(/chart with 2 data series/i)
await sqlChart.hoverTooltip(1, 3)
- fireEvent.click(getHogChart().element)
+ fireEvent.click(getChart().element)
fireEvent.click(screen.getByText('b', { selector: '[data-attr="hog-chart-tooltip-series"]' }))
expect(onPointClick).toHaveBeenCalledWith('b-1', 1, 'Tue')
expect(onPointClick).toHaveBeenCalledTimes(1)
@@ -199,8 +199,8 @@ describe('SqlLineGraph', () => {
describe('y-axis tick formatting', () => {
const waitForYTicks = async (): Promise<string[]> => {
- await waitFor(() => expect(getHogChart().yTicks().length).toBeGreaterThan(0))
- return getHogChart().yTicks()
+ await waitFor(() => expect(getChart().yTicks().length).toBeGreaterThan(0))
+ return getChart().yTicks()
}
it('applies the column prefix/suffix to the left-axis ticks', async () => {
@@ -230,8 +230,8 @@ describe('SqlLineGraph', () => {
],
})
- await waitFor(() => expect(getHogChart().hasRightAxis).toBe(true))
- const chart = getHogChart()
+ await waitFor(() => expect(getChart().hasRightAxis).toBe(true))
+ const chart = getChart()
const rightTicks = chart.yRightTicks()
expect(chart.yTicks().every((tick) => tick.startsWith('$'))).toBe(true)
expect(rightTicks.length).toBeGreaterThan(0)
@@ -247,8 +247,8 @@ describe('SqlLineGraph', () => {
],
})
- await waitFor(() => expect(getHogChart().yTicks().length).toBeGreaterThan(0))
- expect(getHogChart().yRightTicks().filter(Boolean)).toHaveLength(0)
+ await waitFor(() => expect(getChart().yTicks().length).toBeGreaterThan(0))
+ expect(getChart().yRightTicks().filter(Boolean)).toHaveLength(0)
expect(await screen.findByText('Conversion rate')).toBeInTheDocument()
})
@@ -261,16 +261,16 @@ describe('SqlLineGraph', () => {
],
})
- await waitFor(() => expect(getHogChart().hasRightAxis).toBe(true))
- expect(lowestTick(getHogChart().yRightTicks())).toBeGreaterThan(0)
- expect(lowestTick(getHogChart().yTicks())).toBe(0)
+ await waitFor(() => expect(getChart().hasRightAxis).toBe(true))
+ expect(lowestTick(getChart().yRightTicks())).toBeGreaterThan(0)
+ expect(lowestTick(getChart().yTicks())).toBe(0)
})
})
describe('start at zero', () => {
const waitForYTicks = async (): Promise<string[]> => {
- await waitFor(() => expect(getHogChart().yTicks().length).toBeGreaterThan(0))
- return getHogChart().yTicks()
+ await waitFor(() => expect(getChart().yTicks().length).toBeGreaterThan(0))
+ return getChart().yTicks()
}
it('clamps the left-axis baseline to 0 by default', async () => {
@@ -406,7 +406,7 @@ describe('SqlLineGraph', () => {
)!
fireEvent.click(bButton, { metaKey: additive })
- await waitFor(() => expect(getHogChart().seriesCount).toBe(1))
+ await waitFor(() => expect(getChart().seriesCount).toBe(1))
const tooltip = await sqlChart.hoverTooltip(HOVER, MONTHS.length)
expect(tooltip.rows()).toEqual(expectedRows)
})
@@ -431,8 +431,8 @@ describe('SqlLineGraph', () => {
// Axis titles are a layout-dependent overlay that commits a tick after the
// chart's aria-label appears, so read them through waitFor rather than synchronously.
await waitFor(() => {
- expect(getHogChart().xAxisLabel()).toBe(expectedX)
- expect(getHogChart().yAxisLabel()).toBe(expectedY)
+ expect(getChart().xAxisLabel()).toBe(expectedX)
+ expect(getChart().yAxisLabel()).toBe(expectedY)
})
})
})
@@ -445,9 +445,9 @@ describe('SqlLineGraph', () => {
)
await screen.findByLabelText(/chart with/i)
- await waitFor(() => expect(getHogChart().xTicks().length).toBeGreaterThan(0))
+ await waitFor(() => expect(getChart().xTicks().length).toBeGreaterThan(0))
// Date-axis tick formatter renders month names (year shown at the Jan boundary).
- expect(getHogChart().xTicks()).toEqual(expect.arrayContaining(['October', 'November', 'December']))
+ expect(getChart().xTicks()).toEqual(expect.arrayContaining(['October', 'November', 'December']))
})
it('hides x-axis ticks while preserving its title', async () => {
@@ -457,8 +457,8 @@ describe('SqlLineGraph', () => {
)
await screen.findByLabelText(/chart with/i)
- expect(getHogChart().xTicks().filter(Boolean)).toHaveLength(0)
- await waitFor(() => expect(getHogChart().xAxisLabel()).toBe('Signup month'))
+ expect(getChart().xTicks().filter(Boolean)).toHaveLength(0)
+ await waitFor(() => expect(getChart().xAxisLabel()).toBe('Signup month'))
})
})
@@ -470,9 +470,9 @@ describe('SqlLineGraph', () => {
)
await screen.findByLabelText(/chart with/i)
- await waitFor(() => expect(getHogChart().yTicks().length).toBeGreaterThan(0))
+ await waitFor(() => expect(getChart().yTicks().length).toBeGreaterThan(0))
// A log axis lays out ticks per power of ten (10, 20, … 100, 200, …) rather than evenly.
- expect(getHogChart().yTicks()).toEqual(expect.arrayContaining(['10', '100']))
+ expect(getChart().yTicks()).toEqual(expect.arrayContaining(['10', '100']))
})
})
@@ -484,7 +484,7 @@ describe('SqlLineGraph', () => {
)
// One data series + one trend line = 2 rendered series.
- await waitFor(() => expect(getHogChart().seriesCount).toBe(2))
+ await waitFor(() => expect(getChart().seriesCount).toBe(2))
const tooltip = await sqlChart.hoverTooltip(HOVER, MONTHS.length)
expect(tooltip.rows()).toEqual(['a'])
@@ -518,7 +518,7 @@ describe('SqlLineGraph', () => {
)
await screen.findByLabelText(/chart with/i)
- const lines = getHogChart().referenceLines()
+ const lines = getChart().referenceLines()
expect(lines.map((l) => l.label)).toEqual(expectedLabels)
expect(lines.map((l) => l.orientation)).toEqual(expectedLabels.map(() => 'horizontal'))
})
@@ -576,8 +576,8 @@ describe('SqlLineGraph', () => {
describe('show values on series', () => {
const waitForValueLabels = async (): Promise<string[]> => {
- await waitFor(() => expect(getHogChart().valueLabels().length).toBeGreaterThan(0))
- return getHogChart()
+ await waitFor(() => expect(getChart().valueLabels().length).toBeGreaterThan(0))
+ return getChart()
.valueLabels()
.map((label) => label.text)
}
@@ -596,7 +596,7 @@ describe('SqlLineGraph', () => {
it('draws no value labels when showValuesOnSeries is off', async () => {
await renderChart({ yData: [ySeries('revenue', [1200, 1400, 1300])] })
- expect(getHogChart().valueLabels()).toHaveLength(0)
+ expect(getChart().valueLabels()).toHaveLength(0)
})
})
})
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlMetricCard.test.tsx b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlMetricCard.test.tsx
index 0bcf3ec619fc..b4b70f7ae319 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlMetricCard.test.tsx
+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlMetricCard.test.tsx
@@ -2,7 +2,7 @@ import '@testing-library/jest-dom'
import { cleanup, screen, waitFor } from '@testing-library/react'
-import { getHogChart, hoverAtIndex, setupJsdom, setupSyncRaf } from '@posthog/quill-charts/testing'
+import { getChart, hoverAtIndex, setupJsdom, setupSyncRaf } from '@posthog/quill-charts/testing'
import { buildDataVisualizationQuery, renderDataVisualization } from '~/test/insight-testing'
import { ChartDisplayType } from '~/types'
@@ -55,7 +55,7 @@ describe('SqlMetricCard', () => {
expect(screen.getByText('Jan 3, 2026')).toBeInTheDocument()
expect(container.querySelector('[data-attr="metric-card-sparkline"]')).toBeInTheDocument()
- hoverAtIndex(getHogChart(container).element, 1, 3)
+ hoverAtIndex(getChart(container).element, 1, 3)
await waitFor(() => expect(screen.getByText('Jan 2, 2026')).toBeInTheDocument())
})
diff --git a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlProportionBar.test.tsx b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlProportionBar.test.tsx
index ab05ba78efb2..c14b702f0522 100644
--- a/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlProportionBar.test.tsx
+++ b/frontend/src/queries/nodes/DataVisualization/Components/Charts/SqlProportionBar.test.tsx
@@ -2,7 +2,7 @@ import '@testing-library/jest-dom'
import { cleanup, fireEvent, render, screen } from '@testing-library/react'
-import { getHogChart, mockRect, setupJsdom, setupSyncRaf, waitForHogChartTooltip } from '@posthog/quill-charts/testing'
+import { getChart, mockRect, setupJsdom, setupSyncRaf, waitForChartTooltip } from '@posthog/quill-charts/testing'
import { ChartSettings } from '~/queries/schema/schema-general'
import { initKeaTests } from '~/test/init'
@@ -87,7 +87,7 @@ describe('SqlProportionBar', () => {
const props = partCount ? withParts(partCount) : barProps(chartSettings, [40, 30, 20, 10])
const { container } = render(<SqlProportionBar {...props} />)
- const legendRows = getHogChart(container).legendItems()
+ const legendRows = getChart(container).legendItems()
expect(legendRows.map((row) => row.secondaryLabel)).toEqual(expectedShares)
expect(screen.queryByText('100') !== null).toBe(showsTotal)
})
@@ -96,9 +96,9 @@ describe('SqlProportionBar', () => {
const props = barProps({}, [0.2, 0.2])
props.yData[0].settings = { formatting: { style: 'percent' } }
const { container } = render(<SqlProportionBar {...props} />)
- const chart = getHogChart(container)
+ const chart = getChart(container)
- const tooltip = await waitForHogChartTooltip(3000, () =>
+ const tooltip = await waitForChartTooltip(3000, () =>
fireEvent.mouseMove(chart.element, { clientX: mockRect.width / 4, clientY: mockRect.height / 2 })
)
diff --git a/frontend/src/scenes/billing/BillingChart.test.tsx b/frontend/src/scenes/billing/BillingChart.test.tsx
index 21984a299ca7..27e55d057d24 100644
--- a/frontend/src/scenes/billing/BillingChart.test.tsx
+++ b/frontend/src/scenes/billing/BillingChart.test.tsx
@@ -1,11 +1,6 @@
import { cleanup, render, screen, waitFor } from '@testing-library/react'
-import {
- createDefaultTooltipAccessor,
- ensureJsdom,
- getHogChart,
- hoverUntilTooltip,
-} from '@posthog/quill-charts/testing'
+import { createDefaultTooltipAccessor, ensureJsdom, getChart, hoverUntilTooltip } from '@posthog/quill-charts/testing'
import { dayjs } from 'lib/dayjs'
@@ -44,13 +39,13 @@ describe('BillingChart', () => {
it('renders only the series that are not hidden', async () => {
render(<BillingChart series={SERIES} dates={DATES} hiddenSeries={[1]} />)
- await waitFor(() => expect(getHogChart().seriesCount).toBe(1))
+ await waitFor(() => expect(getChart().seriesCount).toBe(1))
})
it('colors the surviving series by its id, not its position after filtering', async () => {
render(<BillingChart series={SERIES} dates={DATES} hiddenSeries={[0]} />)
- const chart = getHogChart()
+ const chart = getChart()
await waitFor(() => expect(chart.seriesCount).toBe(1))
const tooltip = createDefaultTooltipAccessor(await hoverUntilTooltip(chart.element, 0, DATES.length))
@@ -130,7 +125,7 @@ describe('BillingChart', () => {
/>
)
- const chart = getHogChart()
+ const chart = getChart()
await waitFor(() => expect(chart.yTicks().length).toBeGreaterThan(0))
expect(chart.yTicks().every((tick) => tick.startsWith('$'))).toBe(true)
@@ -148,7 +143,7 @@ describe('BillingChart', () => {
/>
)
- await waitFor(() => expect(getHogChart().seriesCount).toBe(2))
+ await waitFor(() => expect(getChart().seriesCount).toBe(2))
expect(screen.queryByText('New billing period')).toBeNull()
})
@@ -180,14 +175,14 @@ describe('BillingChart', () => {
it('draws no more than the cap and says how many it left out', async () => {
render(<BillingChart series={MANY} dates={DATES} hiddenSeries={[]} maxSeries={2} />)
- await waitFor(() => expect(getHogChart().seriesCount).toBe(2))
+ await waitFor(() => expect(getChart().seriesCount).toBe(2))
expect(await screen.findByText(/2 more are in the table below/)).toBeTruthy()
})
it('keeps the largest series when it caps', async () => {
render(<BillingChart series={MANY} dates={DATES} hiddenSeries={[]} maxSeries={2} />)
- const chart = getHogChart()
+ const chart = getChart()
await waitFor(() => expect(chart.seriesCount).toBe(2))
const tooltip = createDefaultTooltipAccessor(await hoverUntilTooltip(chart.element, 0, DATES.length))
@@ -197,7 +192,7 @@ describe('BillingChart', () => {
it('says nothing when every series fits', async () => {
render(<BillingChart series={MANY} dates={DATES} hiddenSeries={[]} maxSeries={10} />)
- await waitFor(() => expect(getHogChart().seriesCount).toBe(4))
+ await waitFor(() => expect(getChart().seriesCount).toBe(4))
expect(screen.queryByText(/more are in the table below/)).toBeNull()
})
@@ -205,7 +200,7 @@ describe('BillingChart', () => {
// Two of four are hidden, so the two that remain fit and nothing is left out.
render(<BillingChart series={MANY} dates={DATES} hiddenSeries={[2, 3]} maxSeries={2} />)
- await waitFor(() => expect(getHogChart().seriesCount).toBe(2))
+ await waitFor(() => expect(getChart().seriesCount).toBe(2))
expect(screen.queryByText(/more are in the table below/)).toBeNull()
})
})
@@ -221,7 +216,7 @@ describe('BillingChart', () => {
it('draws lines by default', async () => {
const { container } = render(<BillingChart series={SERIES} dates={DATES} hiddenSeries={[]} />)
- await waitFor(() => expect(getHogChart().seriesCount).toBe(2))
+ await waitFor(() => expect(getChart().seriesCount).toBe(2))
expect(drawn(container)).toBe('line')
})
@@ -230,7 +225,7 @@ describe('BillingChart', () => {
<BillingChart series={SERIES} dates={DATES} hiddenSeries={[]} chartType="bar" />
)
- await waitFor(() => expect(getHogChart().seriesCount).toBe(2))
+ await waitFor(() => expect(getChart().seriesCount).toBe(2))
expect(drawn(container)).toBe('bar')
})
@@ -246,7 +241,7 @@ describe('BillingChart', () => {
render(<BillingChart series={many} dates={DATES} hiddenSeries={[0]} maxSeries={2} chartType="bar" />)
- await waitFor(() => expect(getHogChart().seriesCount).toBe(2))
+ await waitFor(() => expect(getChart().seriesCount).toBe(2))
expect(await screen.findByText(/1 more are in the table below/)).toBeTruthy()
})
})
@@ -262,7 +257,7 @@ describe('BillingChart', () => {
<BillingChart series={SERIES} dates={DATES} hiddenSeries={[]} chartType="bar" cumulativeLabel={LABEL} />
)
- const chart = getHogChart()
+ const chart = getChart()
await waitFor(() => expect(chart.seriesCount).toBe(3))
expect(chart.hasRightAxis).toBe(true)
@@ -285,7 +280,7 @@ describe('BillingChart', () => {
/>
)
- const chart = getHogChart()
+ const chart = getChart()
await waitFor(() => expect(chart.seriesCount).toBe(2))
// 10 + 20, with Recordings hidden.
@@ -312,7 +307,7 @@ describe('BillingChart', () => {
/>
)
- const chart = getHogChart()
+ const chart = getChart()
// The two largest plus the line. The two the cap dropped are not drawn, but they are
// still spend, so they still count.
await waitFor(() => expect(chart.seriesCount).toBe(3))
@@ -326,13 +321,13 @@ describe('BillingChart', () => {
it('is drawn over lines too', async () => {
render(<BillingChart series={SERIES} dates={DATES} hiddenSeries={[]} cumulativeLabel={LABEL} />)
- await waitFor(() => expect(getHogChart().seriesCount).toBe(3))
+ await waitFor(() => expect(getChart().seriesCount).toBe(3))
})
it('is not drawn unless asked for', async () => {
render(<BillingChart series={SERIES} dates={DATES} hiddenSeries={[]} chartType="bar" />)
- const chart = getHogChart()
+ const chart = getChart()
await waitFor(() => expect(chart.seriesCount).toBe(2))
expect(chart.hasRightAxis).toBe(false)
})
diff --git a/frontend/src/scenes/insights/EmptyStates/SampleDataState.test.tsx b/frontend/src/scenes/insights/EmptyStates/SampleDataState.test.tsx
index ac3d83d8479a..8fdf8377bdd1 100644
--- a/frontend/src/scenes/insights/EmptyStates/SampleDataState.test.tsx
+++ b/frontend/src/scenes/insights/EmptyStates/SampleDataState.test.tsx
@@ -2,7 +2,7 @@ import '@testing-library/jest-dom'
import { cleanup, render, waitFor } from '@testing-library/react'
-import { getHogChart, getHogChartTooltip, hoverAtIndex, setupJsdom, setupSyncRaf } from '@posthog/quill-charts/testing'
+import { getChart, getChartTooltip, hoverAtIndex, setupJsdom, setupSyncRaf } from '@posthog/quill-charts/testing'
import { useMocks } from '~/mocks/jest'
import { initKeaTests } from '~/test/init'
@@ -36,7 +36,7 @@ describe('<SampleDataState />', () => {
['funnel' as SampleDataVariant, 4],
])('keeps the made-up %s numbers out of a tooltip on hover', async (variant, pointCount) => {
const { container } = render(<SampleDataState variant={variant} />)
- const chart = getHogChart(container)
+ const chart = getChart(container)
// Axis ticks appear once the chart commits its scales, which is also when it starts
// answering hovers - without waiting for them the hovers below would be dropped.
await waitFor(() => expect(chart.xTicks().length).toBeGreaterThan(0))
@@ -45,6 +45,6 @@ describe('<SampleDataState />', () => {
hoverAtIndex(chart.element, index, pointCount)
}
- expect(getHogChartTooltip()).toBeNull()
+ expect(getChartTooltip()).toBeNull()
})
})
diff --git a/frontend/src/scenes/surveys/components/StackedBar.test.tsx b/frontend/src/scenes/surveys/components/StackedBar.test.tsx
index 62e519673b1b..bfc8ee40d768 100644
--- a/frontend/src/scenes/surveys/components/StackedBar.test.tsx
+++ b/frontend/src/scenes/surveys/components/StackedBar.test.tsx
@@ -2,7 +2,7 @@ import '@testing-library/jest-dom'
import { cleanup, fireEvent, render } from '@testing-library/react'
-import { ensureJsdom, getHogChart, waitForHogChartTooltip } from '@posthog/quill-charts/testing'
+import { ensureJsdom, getChart, waitForChartTooltip } from '@posthog/quill-charts/testing'
import { StackedBar, type StackedBarSegment } from './StackedBar'
@@ -22,10 +22,10 @@ describe('StackedBar', () => {
[[{ ...segments[0], tooltip: '20 unique users (20.0%)' }, ...segments.slice(1)], '20 unique users (20.0%)'],
])('preserves counts and units in percent-chart tooltips', async (data, expected) => {
const { container } = render(<StackedBar segments={data} size="sm" />)
- const chart = getHogChart(container)
+ const chart = getChart(container)
const rect = chart.element.getBoundingClientRect()
fireEvent.mouseMove(chart.element, { clientX: rect.width * 0.1, clientY: rect.height / 2 })
- expect(await waitForHogChartTooltip()).toHaveTextContent(expected)
+ expect(await waitForChartTooltip()).toHaveTextContent(expected)
})
it('passes raw counts to the NPS value formatter', () => {
@@ -33,7 +33,7 @@ describe('StackedBar', () => {
<StackedBar segments={segments} showTooltips={false} barValueFormatter={(count) => `${count} answers`} />
)
expect(
- getHogChart(container)
+ getChart(container)
.valueLabels()
.map((label) => label.text)
).toEqual(['20 answers', '60 answers', '20 answers'])
diff --git a/frontend/src/test/insight-testing/README.md b/frontend/src/test/insight-testing/README.md
index 9f5b91f4149f..a99559f7915a 100644
--- a/frontend/src/test/insight-testing/README.md
+++ b/frontend/src/test/insight-testing/README.md
@@ -5,7 +5,7 @@ A test wrapper for rendering insight components (or any component that depends o
## Quick start
```tsx
-import { renderInsight, waitForChart, buildTrendsQuery } from './index'
+import { buildTrendsQuery, chart, getChart, renderInsight } from '~/test/insight-testing'
renderInsight({
query: buildTrendsQuery({
@@ -13,8 +13,9 @@ renderInsight({
}),
})
-const chart = await waitForChart()
-expect(chart.series('$pageview').data).toEqual([45, 82, 134, 210, 95])
+const tooltip = await chart.hoverTooltip(2)
+expect(tooltip.row('Pageview')).toContain('134')
+expect(getChart().seriesCount).toBe(1)
```
## `renderInsight(props?)`
@@ -55,46 +56,20 @@ renderWithInsights({
## Chart API
-`waitForChart()` waits for a new chart to render since the last call, then returns it.
-Back-to-back calls after interactions always return fresh data.
-
-`getChart(index?)` returns the most recently rendered chart (or a specific one by index)
-without waiting.
-
-### Chart
-
-| API | Description |
-| ---------------------- | ------------------------------------------------------------------------------------------- |
-| `series(nameOrIndex)` | Get a series by label or index |
-| `seriesCount` | Number of datasets |
-| `seriesNames` | Array of series labels |
-| `value(series, point)` | Single data point — series by name/index, point by index or label (`value('Spike', 'Thu')`) |
-| `labels` | X-axis label array |
-| `label(index)` | Single label by index |
-| `type` | Chart type (`'line'`, `'bar'`, etc.) |
-| `axes` | Axis accessors (`axes.x`, `axes.y`, or any custom axis) |
-| `config` | Raw `ChartConfig` escape hatch |
-
-### Series
-
-| API | Description |
-| ----------------- | -------------------------------------- |
-| `label` | Series name |
-| `data` | Number array |
-| `at(index)` | Single data point with bounds checking |
-| `hidden` | Whether the series is hidden |
-| `borderColor` | Line/border color |
-| `backgroundColor` | Fill color |
-
-### Axis
-
-| API | Description |
-| ------------------ | ------------------------------------------- |
-| `display` | Whether the axis is visible |
-| `type` | Scale type (`'linear'`, `'category'`, etc.) |
-| `stacked` | Whether stacking is enabled |
-| `position` | Axis position (`'left'`, `'bottom'`, etc.) |
-| `tickLabel(value)` | Runs the tick formatter callback |
+`getChart()` comes from `@posthog/quill-charts/testing`.
+It reads the rendered chart through its stable DOM hooks: series count, axis ticks and titles, legend, reference lines and value labels.
+See the [quill-charts testing guide](../../../../packages/quill/packages/charts/src/docs/TESTING.md).
+
+`chart` wraps the gestures for insight charts, which render the InsightTooltip table:
+
+| API | Description |
+| -------------------------- | --------------------------------------------------- |
+| `chart.hoverTooltip(i)` | Hover the point at index `i` and return the tooltip |
+| `chart.clickAtIndex(i)` | Hover, then click the point at index `i` |
+| `chart.clickTooltipRow(l)` | Click the row labelled `l` in a pinned tooltip |
+| `chart.getTooltip()` | The current tooltip element, or `null` |
+
+`sqlChart` does the same for SQL charts, which render the quill `DefaultTooltip`.
## Interactions
@@ -110,7 +85,7 @@ await display.set('Bar chart') // change chart display type
await compare.enable() // enable compare to previous period
```
-After any interaction, call `await waitForChart()` to get the updated chart.
+After any interaction, wrap the assertions in `waitFor`.
## Test data
diff --git a/frontend/src/test/insight-testing/chart-accessor.ts b/frontend/src/test/insight-testing/chart-accessor.ts
deleted file mode 100644
index e065ce10a43d..000000000000
--- a/frontend/src/test/insight-testing/chart-accessor.ts
+++ /dev/null
@@ -1,161 +0,0 @@
-import type { ChartConfig, ChartDataset, ChartScaleConfig } from './chartjs-mock'
-import { getCapturedChartConfigs } from './chartjs-mock'
-
-interface Series {
- label: string
- data: number[]
- at(index: number): number
- hidden: boolean
- compare: boolean
- compareLabel: string
- borderColor: string
- backgroundColor: string
-}
-
-function makeSeries(ds: ChartDataset): Series {
- const data = ds.data ?? []
- return {
- label: ds.label ?? '',
- data,
- at(index: number): number {
- if (index < 0 || index >= data.length) {
- throw new Error(`Point index ${index} out of range (series "${ds.label}" has ${data.length} points)`)
- }
- return data[index]
- },
- hidden: ds.hidden ?? false,
- compare: ds.compare ?? false,
- compareLabel: ds.compare_label ?? '',
- borderColor: ds.borderColor ?? '',
- backgroundColor: ds.backgroundColor ?? '',
- }
-}
-
-interface Axis {
- display: boolean
- type: string
- stacked: boolean
- position: string
- tickLabel: (value: number | string) => string
-}
-
-interface Axes {
- [key: string]: Axis
- x: Axis
- y: Axis
-}
-
-function makeAxis(scaleConfig: ChartScaleConfig | undefined): Axis {
- return {
- display: scaleConfig?.display ?? true,
- type: scaleConfig?.type ?? 'linear',
- stacked: scaleConfig?.stacked ?? false,
- position: scaleConfig?.position ?? 'left',
- tickLabel: (value: number | string) => {
- const cb = scaleConfig?.ticks?.callback
- return typeof cb === 'function' ? String(cb(value, 0, [])) : String(value)
- },
- }
-}
-
-export interface Chart {
- series(nameOrIndex: string | number): Series
- seriesCount: number
- seriesNames: string[]
- value(series: string | number, pointIndexOrLabel: number | string): number
- labels: string[]
- label(index: number): string
- type: string
- axes: Axes
- config: ChartConfig
-}
-
-function resolveChartConfig(index: number): ChartConfig {
- const charts = getCapturedChartConfigs()
- if (charts.length === 0) {
- throw new Error('No charts captured')
- }
- const resolved = index < 0 ? charts.length + index : index
- if (resolved < 0 || resolved >= charts.length) {
- throw new Error(`No chart at index ${resolved} (${charts.length} captured)`)
- }
- return charts[resolved].config
-}
-
-function quotedSeriesNames(allSeries: Series[]): string[] {
- return allSeries.map((s) => `"${s.label}"`)
-}
-
-function findSeriesByName(allSeries: Series[], name: string): Series {
- const match = allSeries.find((s) => s.label === name)
- if (!match) {
- throw new Error(`No series "${name}". Available: ${quotedSeriesNames(allSeries).join(', ')}`)
- }
- return match
-}
-
-function findSeriesByIndex(allSeries: Series[], index: number): Series {
- if (index < 0 || index >= allSeries.length) {
- throw new Error(
- `Series index ${index} out of range (${allSeries.length} series: ${quotedSeriesNames(allSeries).join(', ')})`
- )
- }
- return allSeries[index]
-}
-
-function findSeries(allSeries: Series[], nameOrIndex: string | number): Series {
- return typeof nameOrIndex === 'number'
- ? findSeriesByIndex(allSeries, nameOrIndex)
- : findSeriesByName(allSeries, nameOrIndex)
-}
-
-function resolvePointIndex(labels: string[], pointIndexOrLabel: number | string): number {
- if (typeof pointIndexOrLabel === 'number') {
- return pointIndexOrLabel
- }
- const i = labels.indexOf(pointIndexOrLabel)
- if (i < 0) {
- throw new Error(`Label "${pointIndexOrLabel}" not found. Available: ${labels.map((l) => `"${l}"`).join(', ')}`)
- }
- return i
-}
-
-function labelAtIndex(labels: string[], index: number): string {
- if (index < 0 || index >= labels.length) {
- throw new Error(`Label index ${index} out of range (${labels.length} labels)`)
- }
- return labels[index]
-}
-
-/** Lazily creates axis accessors — x and y are pre-built, others are created on first access. */
-function makeAxes(scales: Record<string, ChartScaleConfig | undefined>): Axes {
- return new Proxy(
- { x: makeAxis(scales.x), y: makeAxis(scales.y) },
- {
- get(target, prop) {
- if (typeof prop === 'string' && !(prop in target)) {
- return makeAxis(scales[prop])
- }
- return target[prop as keyof typeof target]
- },
- }
- ) as Axes
-}
-
-export function getChart(index = -1): Chart {
- const config = resolveChartConfig(index)
- const allSeries = (config.data?.datasets ?? []).map(makeSeries)
- const chartLabels = config.data?.labels ?? []
-
- return {
- series: (nameOrIndex) => findSeries(allSeries, nameOrIndex),
- seriesCount: allSeries.length,
- seriesNames: allSeries.map((s) => s.label),
- value: (s, pointIndexOrLabel) => findSeries(allSeries, s).at(resolvePointIndex(chartLabels, pointIndexOrLabel)),
- labels: chartLabels,
- label: (i) => labelAtIndex(chartLabels, i),
- type: config.type ?? '',
- axes: makeAxes(config.options?.scales ?? {}),
- config,
- }
-}
diff --git a/frontend/src/test/insight-testing/index.ts b/frontend/src/test/insight-testing/index.ts
index 4efe0ba4e4dc..d597d47b0188 100644
--- a/frontend/src/test/insight-testing/index.ts
+++ b/frontend/src/test/insight-testing/index.ts
@@ -1,7 +1,5 @@
-export { getChart } from './chart-accessor'
-export type { Chart } from './chart-accessor'
-export { getHogChart } from '@posthog/quill-charts/testing'
-export type { HogChart } from '@posthog/quill-charts/testing'
+export { getChart } from '@posthog/quill-charts/testing'
+export type { ChartAccessor } from '@posthog/quill-charts/testing'
export { createInsightTooltipAccessor } from './tooltip-helpers'
export type { InsightTooltipAccessor } from './tooltip-helpers'
export {
@@ -33,4 +31,3 @@ export { buildActorsResponse, setupInsightMocks } from './mocks'
export type { MockResponse, QueryBody, SetupMocksOptions } from './mocks'
export { expectNoNaN } from './query-helpers'
export * from './test-data'
-export { waitForChart } from './wait-for-chart'
diff --git a/frontend/src/test/insight-testing/interactions.ts b/frontend/src/test/insight-testing/interactions.ts
index f7b2b65be03c..0f8bd02785b5 100644
--- a/frontend/src/test/insight-testing/interactions.ts
+++ b/frontend/src/test/insight-testing/interactions.ts
@@ -5,9 +5,9 @@ import {
clickAtIndex,
createDefaultTooltipAccessor,
type DefaultTooltipAccessor,
- getHogChartTooltip,
+ getChartTooltip,
hoverUntilTooltip,
- waitForHogChartTooltip,
+ waitForChartTooltip,
} from '@posthog/quill-charts/testing'
import { insightVizDataLogic } from 'scenes/insights/insightVizDataLogic'
@@ -160,7 +160,7 @@ export function getQuerySource(): TrendsQuery {
export const chart = {
/** Current chart tooltip element, or null if none is rendered. */
- getTooltip: getHogChartTooltip,
+ getTooltip: getChartTooltip,
async hoverTooltip(
index: number,
totalLabels = trendsSeries.pageviews.labels.length
@@ -178,7 +178,7 @@ export const chart = {
/** Click a row inside the pinned tooltip by matching its label text. Use
* after `clickAtIndex` has pinned a multi-series tooltip. */
async clickTooltipRow(label: string | RegExp): Promise<void> {
- const tooltip = await waitForHogChartTooltip()
+ const tooltip = await waitForChartTooltip()
// Each quill tooltip row renders its label twice — a visible copy plus an aria-hidden
// measurement copy used for truncation layout — so match only the visible one.
const matches = within(tooltip).getAllByText(label)
diff --git a/frontend/src/test/insight-testing/render-insight.test.tsx b/frontend/src/test/insight-testing/render-insight.test.tsx
deleted file mode 100644
index e7445def80fe..000000000000
--- a/frontend/src/test/insight-testing/render-insight.test.tsx
+++ /dev/null
@@ -1,31 +0,0 @@
-import { cleanup } from '@testing-library/react'
-
-import { breakdown, renderInsight, series, waitForChart } from './index'
-
-jest.mock('lib/components/AutoSizer', () => ({
- AutoSizer: ({ renderProp }: { renderProp: (size: { height: number; width: number }) => React.ReactNode }) =>
- renderProp({ height: 400, width: 400 }),
-}))
-
-describe('renderInsight', () => {
- afterEach(() => {
- cleanup()
- })
-
- it.skip('breakdown naps by hedgehogs', async () => {
- renderInsight()
- await waitForChart()
-
- await series.select('Napped')
- await breakdown.set('hedgehog')
-
- const chart = await waitForChart()
- expect(chart.seriesNames).toEqual(['Spike', 'Bramble', 'Thistle', 'Conker', 'Prickles'])
-
- expect(chart.value('Spike', 'Thu')).toBe(4) // Spike had 4 naps on thursday
- expect(chart.series('Bramble').data).toEqual([0, 0, 1, 1, 0]) // Bramble had 1 nap on wednesday and thursday
-
- expect(chart.type).toBe('line')
- expect(chart.labels).toEqual(['Mon', 'Tue', 'Wed', 'Thu', 'Fri'])
- })
-})
diff --git a/frontend/src/test/insight-testing/tooltip-helpers.ts b/frontend/src/test/insight-testing/tooltip-helpers.ts
index 51cefde9d929..48998628a94b 100644
--- a/frontend/src/test/insight-testing/tooltip-helpers.ts
+++ b/frontend/src/test/insight-testing/tooltip-helpers.ts
@@ -1,11 +1,11 @@
-import { createHogChartTooltip, type HogChartTooltip } from '@posthog/quill-charts/testing'
+import { createChartTooltipAccessor, type ChartTooltipAccessor } from '@posthog/quill-charts/testing'
/** Insight-flavored tooltip accessor. Extends the generic hog-charts tooltip
* with helpers for reading a per-series tooltip. Insight charts render hog-charts'
* `DefaultTooltip` (`hog-chart-tooltip-*` rows); the legacy `InsightTooltip` table
* branch (`<th>` header, `<tr>` rows with `.datum-column` / `.datum-counts-column`)
* is retained for any remaining table-based tooltip readers. */
-export interface InsightTooltipAccessor extends HogChartTooltip {
+export interface InsightTooltipAccessor extends ChartTooltipAccessor {
/** Header text — typically the hovered date (e.g. "Wednesday, 12 Jun (UTC)"). */
title(): string
/** Value cell text for the row whose label contains `label`. */
@@ -19,7 +19,7 @@ export function createInsightTooltipAccessor(element: HTMLElement): InsightToolt
const defaultRows = (): HTMLElement[] =>
Array.from(element.querySelectorAll<HTMLElement>('[data-attr="hog-chart-tooltip-row"]'))
- return Object.assign(createHogChartTooltip(element), {
+ return Object.assign(createChartTooltipAccessor(element), {
title(): string {
if (isDefaultTooltip()) {
return element.querySelector('[data-attr="hog-chart-tooltip-label"]')?.textContent?.trim() ?? ''
diff --git a/frontend/src/test/insight-testing/wait-for-chart.ts b/frontend/src/test/insight-testing/wait-for-chart.ts
deleted file mode 100644
index 85a8006eb6fe..000000000000
--- a/frontend/src/test/insight-testing/wait-for-chart.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import { waitFor } from '@testing-library/react'
-
-import { type Chart, getChart } from './chart-accessor'
-import { getCapturedChartConfigs } from './chartjs-mock'
-
-/** Wait for a new chart to render. On each call, waits for a chart that
- * didn't exist when waitForChart was invoked, so back-to-back calls
- * after interactions always return fresh data. */
-export async function waitForChart(): Promise<Chart> {
- const countAtCall = getCapturedChartConfigs().length
- let chart: Chart
- await waitFor(
- () => {
- expect(getCapturedChartConfigs().length).toBeGreaterThan(countAtCall)
- chart = getChart()
- expect(chart.seriesCount).toBeGreaterThan(0)
- },
- { timeout: 2000 }
- )
- return chart!
-}
diff --git a/packages/quill/packages/charts/AGENTS.md b/packages/quill/packages/charts/AGENTS.md
index 71c28ee1156f..b896924db254 100644
--- a/packages/quill/packages/charts/AGENTS.md
+++ b/packages/quill/packages/charts/AGENTS.md
@@ -105,7 +105,7 @@ Charts fill their container and need a parent with real dimensions — a zero-he
## Testing
-Import helpers from `@posthog/quill-charts/testing` (jsdom only): `getHogChart` reads rendered overlays through stable `data-attr` hooks, `renderHogChart` adds tooltip-context capture for library tests, `hoverAtIndex` / `clickAtIndex` / `hoverUntilTooltip` / `dragSelection` drive gestures, and `createDefaultTooltipAccessor` reads the built-in tooltip. The `data-attr` selectors are a public contract. [docs/TESTING.md](./src/docs/TESTING.md)
+Import helpers from `@posthog/quill-charts/testing` (jsdom only): `getChart` reads rendered overlays through stable `data-attr` hooks, `renderChart` adds tooltip-context capture for library tests, `hoverAtIndex` / `clickAtIndex` / `hoverUntilTooltip` / `dragSelection` drive gestures, and `createDefaultTooltipAccessor` reads the built-in tooltip. The `data-attr` selectors are a public contract. [docs/TESTING.md](./src/docs/TESTING.md)
## Docs index
diff --git a/packages/quill/packages/charts/src/charts/BarChart/BarChart.test.tsx b/packages/quill/packages/charts/src/charts/BarChart/BarChart.test.tsx
index 2336dd0461de..df02b2821f97 100644
--- a/packages/quill/packages/charts/src/charts/BarChart/BarChart.test.tsx
+++ b/packages/quill/packages/charts/src/charts/BarChart/BarChart.test.tsx
@@ -2,7 +2,7 @@ import { fireEvent, waitFor } from '@testing-library/react'
import type { BarChartConfig, ChartTheme, PointClickData, Series } from '../../core/types'
import { ReferenceLine } from '../../overlays/ReferenceLine'
-import { getHogChart, getHogChartTooltip, renderHogChart, waitForHogChartTooltip } from '../../testing'
+import { getChart, getChartTooltip, renderChart, waitForChartTooltip } from '../../testing'
import { dimensions } from '../../testing/jsdom'
import { measureLabelWidth } from '../../utils/text-measure'
import { BarChart } from './BarChart'
@@ -34,7 +34,7 @@ describe('BarChart', () => {
['percent', 'horizontal'],
])('%s / %s', (barLayout, axisOrientation) => {
it('renders ticks for the value axis', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<BarChart series={SERIES} labels={LABELS} theme={THEME} config={{ barLayout, axisOrientation }} />
)
const valueTicks = axisOrientation === 'horizontal' ? chart.xTicks() : chart.yTicks()
@@ -58,7 +58,7 @@ describe('BarChart', () => {
['A', 'B'],
],
])('horizontal: %s anchors value axis at 0', (_name, series, labels) => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<BarChart
series={series}
labels={labels}
@@ -72,20 +72,20 @@ describe('BarChart', () => {
})
it('forwards `dataAttr` to the chart wrapper for product-test selection', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<BarChart series={SERIES} labels={LABELS} theme={THEME} dataAttr="bar-chart-instance" />
)
expect(chart.element.getAttribute('data-attr')).toBe('bar-chart-instance')
})
it('renders empty state without crashing', () => {
- const { chart } = renderHogChart(<BarChart series={[]} labels={[]} theme={THEME} />)
+ const { chart } = renderChart(<BarChart series={[]} labels={[]} theme={THEME} />)
expect(chart.seriesCount).toBe(0)
})
it('renders custom percent formatter when consumer supplies one', () => {
const formatter = jest.fn((v: number) => `${Math.round(v * 1000) / 10}‰`)
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<BarChart
series={SERIES}
labels={LABELS}
@@ -98,7 +98,7 @@ describe('BarChart', () => {
})
it('applies a default percent formatter when consumer omits one', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<BarChart series={SERIES} labels={LABELS} theme={THEME} config={{ barLayout: 'percent' }} />
)
expect(chart.yTicks().some((t) => /\d+%/.test(t))).toBe(true)
@@ -112,7 +112,7 @@ describe('BarChart', () => {
data: [Number.NaN, Number.NaN, Number.NaN],
},
]
- const { chart } = renderHogChart(<BarChart series={broken} labels={LABELS} theme={THEME} />)
+ const { chart } = renderChart(<BarChart series={broken} labels={LABELS} theme={THEME} />)
expect(chart.seriesCount).toBe(1)
})
@@ -130,7 +130,7 @@ describe('BarChart', () => {
},
{ key: 'c', label: 'C', data: [3, 6, 9] },
]
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<BarChart series={series} labels={LABELS} theme={THEME} config={{ barLayout }} />
)
expect(chart.seriesCount).toBe(2)
@@ -140,21 +140,21 @@ describe('BarChart', () => {
describe('axis configuration', () => {
it('hides x-axis ticks when hideXAxis is true', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<BarChart series={SERIES} labels={LABELS} theme={THEME} config={{ hideXAxis: true }} />
)
expect(chart.xTicks()).toHaveLength(0)
})
it('hides y-axis ticks when hideYAxis is true', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<BarChart series={SERIES} labels={LABELS} theme={THEME} config={{ hideYAxis: true }} />
)
expect(chart.yTicks()).toHaveLength(0)
})
it('applies xTickFormatter to x-axis ticks', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<BarChart
series={SERIES}
labels={LABELS}
@@ -166,7 +166,7 @@ describe('BarChart', () => {
})
it('renders custom axis titles in horizontal orientation', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<BarChart
series={SERIES}
labels={LABELS}
@@ -187,7 +187,7 @@ describe('BarChart', () => {
['vertical', false],
])('%s: a wide chart raises the category label cap (shows full label: %s)', (axisOrientation, showsFull) => {
const label = 'filesystem::play_open_in_app'
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<BarChart
series={[{ key: 'a', label: 'A', data: [10] }]}
labels={[label]}
@@ -201,7 +201,7 @@ describe('BarChart', () => {
it('renders without crashing in yScaleType log with positive data', () => {
const series: Series[] = [{ key: 'a', label: 'A', data: [1, 10, 100] }]
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<BarChart
series={series}
labels={LABELS}
@@ -219,7 +219,7 @@ describe('BarChart', () => {
describe('hover & tooltip', () => {
it('mounts a tooltip on hover', async () => {
- const { chart } = renderHogChart(<BarChart series={SERIES} labels={LABELS} theme={THEME} />)
+ const { chart } = renderChart(<BarChart series={SERIES} labels={LABELS} theme={THEME} />)
chart.hoverAtIndex(1)
const tooltip = await chart.waitForTooltip()
expect(tooltip.element.textContent).toContain('Tue')
@@ -227,7 +227,7 @@ describe('BarChart', () => {
it('invokes onPointClick with the clicked column', async () => {
const onPointClick = jest.fn()
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<BarChart series={SERIES} labels={LABELS} theme={THEME} onPointClick={onPointClick} />
)
await chart.clickAtIndex(1)
@@ -247,7 +247,7 @@ describe('BarChart', () => {
expectedKeys: ['b'],
},
])('$name', async ({ config, expectedKeys }) => {
- const { chart } = renderHogChart(<BarChart series={SERIES} labels={LABELS} theme={THEME} config={config} />)
+ const { chart } = renderChart(<BarChart series={SERIES} labels={LABELS} theme={THEME} config={config} />)
chart.hoverAtIndex(1)
const tooltip = await chart.waitForTooltip()
// Stacked/percent order is cursor-resolved, so assert membership not declaration order.
@@ -257,7 +257,7 @@ describe('BarChart', () => {
it('stacked tooltip shows each series own value, not the cumulative stack total', async () => {
// At index 1: a=20 (bottom) and b=15 stacked on top. b's stacked top is 35, but the
// tooltip must report b's own 15 — the segment, not the running total.
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<BarChart series={SERIES} labels={LABELS} theme={THEME} config={{ barLayout: 'stacked' }} />
)
chart.hoverAtIndex(1)
@@ -270,7 +270,7 @@ describe('BarChart', () => {
// At index 1: a=20 (bottom of stack), b=15 (on top). The tooltip lists the whole stack in
// declaration order — visual top-to-bottom ordering is handled downstream by DefaultTooltip's
// yPixel sort, so seriesData stays declaration-ordered no matter which segment the cursor is over.
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<BarChart series={SERIES} labels={LABELS} theme={THEME} config={{ barLayout: 'stacked' }} />
)
chart.hoverAtIndex(1)
@@ -301,7 +301,7 @@ describe('BarChart', () => {
{ key: 'b', label: 'B', data: [30] },
{ key: 'filler', label: 'Filler', data: [30], visibility: { tooltip: false } },
]
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<BarChart
series={series}
labels={['step']}
@@ -321,7 +321,7 @@ describe('BarChart', () => {
it('stacked onPointClick routes to the segment whose rect contains the cursor', async () => {
const onPointClick = jest.fn()
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<BarChart
series={SERIES}
labels={LABELS}
@@ -357,7 +357,7 @@ describe('BarChart', () => {
it('percent tooltip shows each series own fraction, not the cumulative fraction', async () => {
// At index 1: a=20, b=15 → total 35. b sits on top of a, so b's cumulative top is 1.0,
// but the tooltip must report b's own 15/35 fraction — the segment, not the running total.
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<BarChart series={SERIES} labels={LABELS} theme={THEME} config={{ barLayout: 'percent' }} />
)
chart.hoverAtIndex(1)
@@ -371,7 +371,7 @@ describe('BarChart', () => {
{ index: 1, calls: 1, cursor: 'cursor-pointer' },
])('isPointClickable gates click and pointer at index $index', async ({ index, calls, cursor }) => {
const onPointClick = jest.fn()
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<BarChart
series={SERIES}
labels={LABELS}
@@ -389,7 +389,7 @@ describe('BarChart', () => {
it('stacked onPointClick reports each series own value, not the cumulative stack total', async () => {
const onPointClick = jest.fn()
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<BarChart
series={SERIES}
labels={LABELS}
@@ -415,7 +415,7 @@ describe('BarChart', () => {
['grouped', { barLayout: 'grouped' } as BarChartConfig],
['stacked', { barLayout: 'stacked' } as BarChartConfig],
])('%s layout suppresses tooltip in the gap between band groups', async (_name, config) => {
- const { chart } = renderHogChart(<BarChart series={SERIES} labels={LABELS} theme={THEME} config={config} />)
+ const { chart } = renderChart(<BarChart series={SERIES} labels={LABELS} theme={THEME} config={config} />)
// d3.scaleBand with paddingInner=0.2 and paddingOuter=0.1 yields step = plotWidth / 3
// for 3 labels. Bands occupy [0.1*step, 0.9*step], [1.1*step, 1.9*step], [2.1*step, 2.9*step]
// — so x = plotLeft + 1.0*step is centred in the between-group gap.
@@ -430,7 +430,7 @@ describe('BarChart', () => {
})
it('stacked horizontal suppresses tooltip past the bar value extent', async () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<BarChart
series={SERIES}
labels={LABELS}
@@ -457,11 +457,11 @@ describe('BarChart', () => {
clientX: dimensions.plotLeft + dimensions.plotWidth * 0.95,
clientY: yMidRow,
})
- await waitFor(() => expect(getHogChartTooltip()?.textContent ?? '').toBe(''))
+ await waitFor(() => expect(getChartTooltip()?.textContent ?? '').toBe(''))
})
const hoverBandCenter = async (hitArea: 'bar' | 'band', index: number): Promise<void> => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<BarChart
series={[{ key: 'v', label: 'V', data: [100, 1, 0] }]}
labels={LABELS}
@@ -473,7 +473,7 @@ describe('BarChart', () => {
dimensions.plotLeft + ((i + 0.5) * dimensions.plotWidth) / LABELS.length
const clientY = dimensions.plotTop + 4
// The first bar fills the plot, so this hover proves the chart is live.
- await waitForHogChartTooltip(3000, () =>
+ await waitForChartTooltip(3000, () =>
fireEvent.mouseMove(chart.element, { clientX: bandCenterX(0), clientY })
)
fireEvent.mouseMove(chart.element, { clientX: bandCenterX(index), clientY })
@@ -484,7 +484,7 @@ describe('BarChart', () => {
['an empty bucket', 2, 'Wed'],
])('band hit-testing reaches %s', async (_name, index, expectedLabel) => {
await hoverBandCenter('band', index)
- await waitFor(() => expect(getHogChartTooltip()?.textContent ?? '').toContain(expectedLabel))
+ await waitFor(() => expect(getChartTooltip()?.textContent ?? '').toContain(expectedLabel))
})
it.each<[string, number]>([
@@ -492,7 +492,7 @@ describe('BarChart', () => {
['an empty bucket', 2],
])('bar hit-testing leaves %s unreachable', async (_name, index) => {
await hoverBandCenter('bar', index)
- await waitFor(() => expect(getHogChartTooltip()?.textContent ?? '').toBe(''))
+ await waitFor(() => expect(getChartTooltip()?.textContent ?? '').toBe(''))
})
describe('sparse-stacked horizontal (overlap layout)', () => {
@@ -521,7 +521,7 @@ describe('BarChart', () => {
])(
'tooltip surfaces the visible segment with its own value for cursor in the %s',
async (_name, valueAtCursor, key, expectedValue) => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<BarChart
series={SPARSE_SERIES}
labels={SPARSE_LABELS}
@@ -550,7 +550,7 @@ describe('BarChart', () => {
'onPointClick routes to the visible segment for cursor in the %s',
async (_name, valueAtCursor, key, expectedValue, expectedSeriesIndex) => {
const onPointClick = jest.fn()
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<BarChart
series={SPARSE_SERIES}
labels={SPARSE_LABELS}
@@ -573,7 +573,7 @@ describe('BarChart', () => {
})
it('grouped layout still narrows when the cursor is above every bar (value-axis miss)', async () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<BarChart series={SERIES} labels={LABELS} theme={THEME} config={{ barLayout: 'grouped' }} />
)
// Same x as `hoverAtIndex(1)` (which lands inside `b`'s sub-band) but a y above
@@ -601,7 +601,7 @@ describe('BarChart', () => {
'grouped onPointClick routes to the sub-bar column under the cursor, even above the bar — %s',
async (_name, stepMultiplier, key, value) => {
const onPointClick = jest.fn()
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<BarChart
series={SERIES}
labels={LABELS}
@@ -634,7 +634,7 @@ describe('BarChart', () => {
'grouped onPointClick reports inTrackArea false when the cursor is within the bar fill — %s',
async (_name, stepMultiplier, key) => {
const onPointClick = jest.fn()
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<BarChart
series={SERIES}
labels={LABELS}
@@ -659,7 +659,7 @@ describe('BarChart', () => {
)
it('pins the tooltip on click when tooltip.pinnable is true', async () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<BarChart series={SERIES} labels={LABELS} theme={THEME} config={{ tooltip: { pinnable: true } }} />
)
await chart.clickAtIndex(1)
@@ -677,7 +677,7 @@ describe('BarChart', () => {
visibility: { tooltip: false },
},
]
- const { chart } = renderHogChart(<BarChart series={series} labels={LABELS} theme={THEME} />)
+ const { chart } = renderChart(<BarChart series={series} labels={LABELS} theme={THEME} />)
chart.hoverAtIndex(1)
const tooltip = await chart.waitForTooltip()
expect(tooltip.element.textContent).toContain('A')
@@ -687,7 +687,7 @@ describe('BarChart', () => {
describe('children & error boundary', () => {
it('renders custom overlay children', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<BarChart series={SERIES} labels={LABELS} theme={THEME}>
<div data-attr="custom-child" />
</BarChart>
@@ -696,7 +696,7 @@ describe('BarChart', () => {
})
it('renders a ReferenceLine child via the accessor', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<BarChart series={SERIES} labels={LABELS} theme={THEME}>
<ReferenceLine value={15} label="Target" />
</BarChart>
@@ -714,7 +714,7 @@ describe('BarChart', () => {
}
const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(() => {})
try {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<BarChart series={SERIES} labels={LABELS} theme={THEME} tooltip={tooltip} onError={onError} />
)
chart.hoverAtIndex(1)
@@ -727,12 +727,12 @@ describe('BarChart', () => {
describe('interactive legend', () => {
it('renders no legend by default', () => {
- const { container } = renderHogChart(<BarChart series={SERIES} labels={LABELS} theme={THEME} />)
+ const { container } = renderChart(<BarChart series={SERIES} labels={LABELS} theme={THEME} />)
expect(container.querySelector('[data-attr="hog-chart-bar-legend"]')).toBeNull()
})
it('isolates a series when its legend row is clicked, and restores all on the next click', () => {
- const { container, chart } = renderHogChart(
+ const { container, chart } = renderChart(
<BarChart series={SERIES} labels={LABELS} theme={THEME} config={{ legend: { show: true } }} />
)
expect(chart.seriesCount).toBe(2)
@@ -740,16 +740,16 @@ describe('BarChart', () => {
Array.from(container.querySelectorAll('[data-attr="hog-chart-bar-legend"] button'))
fireEvent.click(buttons()[1])
- expect(getHogChart(container).seriesCount).toBe(1)
+ expect(getChart(container).seriesCount).toBe(1)
expect(buttons()[0].className).toContain('opacity-40')
expect(buttons()[1].className).not.toContain('opacity-40')
fireEvent.click(buttons()[1])
- expect(getHogChart(container).seriesCount).toBe(2)
+ expect(getChart(container).seriesCount).toBe(2)
})
it('toggles just one series off and on when its legend row is meta-clicked', () => {
- const { container, chart } = renderHogChart(
+ const { container, chart } = renderChart(
<BarChart series={SERIES} labels={LABELS} theme={THEME} config={{ legend: { show: true } }} />
)
expect(chart.seriesCount).toBe(2)
@@ -757,11 +757,11 @@ describe('BarChart', () => {
Array.from(container.querySelectorAll('[data-attr="hog-chart-bar-legend"] button'))
fireEvent.click(buttons()[1], { metaKey: true })
- expect(getHogChart(container).seriesCount).toBe(1)
+ expect(getChart(container).seriesCount).toBe(1)
expect(buttons()[1].className).toContain('opacity-40')
fireEvent.click(buttons()[1], { metaKey: true })
- expect(getHogChart(container).seriesCount).toBe(2)
+ expect(getChart(container).seriesCount).toBe(2)
})
})
@@ -771,7 +771,7 @@ describe('BarChart', () => {
it('fires onDateRangeZoom with the dragged label range on vertical bars', () => {
const onDateRangeZoom = jest.fn()
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<BarChart series={FIVE_SERIES} labels={FIVE_LABELS} theme={THEME} onDateRangeZoom={onDateRangeZoom} />
)
chart.dragSelection(1, 3)
@@ -785,7 +785,7 @@ describe('BarChart', () => {
it('does not fire on horizontal bars, whose interaction axis is vertical', () => {
const onDateRangeZoom = jest.fn()
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<BarChart
series={FIVE_SERIES}
labels={FIVE_LABELS}
diff --git a/packages/quill/packages/charts/src/charts/BarList/BarList.test.tsx b/packages/quill/packages/charts/src/charts/BarList/BarList.test.tsx
index f2e288c19c8f..769f0c033810 100644
--- a/packages/quill/packages/charts/src/charts/BarList/BarList.test.tsx
+++ b/packages/quill/packages/charts/src/charts/BarList/BarList.test.tsx
@@ -1,7 +1,7 @@
import { fireEvent, screen, within } from '@testing-library/react'
import type { ChartTheme, Series } from '../../core/types'
-import { mockRect, renderHogChart, waitForHogChartTooltip } from '../../testing'
+import { mockRect, renderChart, waitForChartTooltip } from '../../testing'
import { BarList } from './BarList'
const THEME: ChartTheme = { colors: ['#22d3ee', '#f14f58', '#a78bfa', '#fbbf24'], backgroundColor: '#ffffff' }
@@ -20,12 +20,12 @@ describe('BarList', () => {
{ name: 'the sum of the rows', total: undefined, valueText: '12.5% · 100' },
{ name: 'an explicit total', total: 1000, valueText: '10% · 100' },
])('shows the hovered row in the tooltip and its share of $name', async ({ total, valueText }) => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<BarList series={ROWS} theme={THEME} total={total} config={{ valueDisplay: 'both' }} />,
{ nativeTooltip: true }
)
- const tooltip = await waitForHogChartTooltip(3000, () => fireEvent.mouseMove(chart.element, INSIDE_B))
+ const tooltip = await waitForChartTooltip(3000, () => fireEvent.mouseMove(chart.element, INSIDE_B))
expect(within(tooltip).getByText('Row b')).toBeTruthy()
expect(within(tooltip).getByText('100')).toBeTruthy()
@@ -33,9 +33,9 @@ describe('BarList', () => {
})
it('hands a custom tooltip the meta of the hovered row', async () => {
- const { chart } = renderHogChart(<BarList series={ROWS} theme={THEME} tooltip={() => <span>custom</span>} />)
+ const { chart } = renderChart(<BarList series={ROWS} theme={THEME} tooltip={() => <span>custom</span>} />)
- await waitForHogChartTooltip(3000, () => fireEvent.mouseMove(chart.element, INSIDE_B))
+ await waitForChartTooltip(3000, () => fireEvent.mouseMove(chart.element, INSIDE_B))
const tooltip = await chart.waitForTooltip()
expect(tooltip.seriesData[0].series.meta).toEqual({ id: 'b' })
diff --git a/packages/quill/packages/charts/src/charts/BoxPlot/BoxPlot.test.tsx b/packages/quill/packages/charts/src/charts/BoxPlot/BoxPlot.test.tsx
index 10bb27b16c93..52ff253a9578 100644
--- a/packages/quill/packages/charts/src/charts/BoxPlot/BoxPlot.test.tsx
+++ b/packages/quill/packages/charts/src/charts/BoxPlot/BoxPlot.test.tsx
@@ -1,7 +1,7 @@
import { waitFor } from '@testing-library/react'
import type { ChartTheme } from '../../core/types'
-import { renderHogChart, waitForHogChartTooltip } from '../../testing'
+import { renderChart, waitForChartTooltip } from '../../testing'
import { BoxPlot, type BoxPlotClickData, type BoxPlotConfig } from './BoxPlot'
import type { BoxPlotDatum, BoxPlotSeries } from './types'
@@ -33,12 +33,12 @@ const TWO_SERIES: BoxPlotSeries[] = [
describe('BoxPlot', () => {
it('renders the canvas and reports series count via aria-label', () => {
- const { chart } = renderHogChart(<BoxPlot series={TWO_SERIES} labels={LABELS} theme={THEME} />)
+ const { chart } = renderChart(<BoxPlot series={TWO_SERIES} labels={LABELS} theme={THEME} />)
expect(chart.seriesCount).toBe(2)
})
it('renders a legend when requested', () => {
- const { container } = renderHogChart(
+ const { container } = renderChart(
<BoxPlot series={TWO_SERIES} labels={LABELS} theme={THEME} config={{ legend: { show: true } }} />
)
const buttons = container.querySelectorAll('[data-attr="hog-chart-box-plot-legend"] button')
@@ -53,7 +53,7 @@ describe('BoxPlot', () => {
data: [datum({ min: 0, max: 200 }), datum({ min: 10, max: 220 })],
},
]
- const { chart } = renderHogChart(<BoxPlot series={series} labels={['Mon', 'Tue']} theme={THEME} />)
+ const { chart } = renderChart(<BoxPlot series={series} labels={['Mon', 'Tue']} theme={THEME} />)
const ticks = chart.yTicks()
expect(ticks.length).toBeGreaterThan(0)
const nums = ticks.map((t) => parseFloat(t.replace(/[^\d.-]/g, '')))
@@ -73,7 +73,7 @@ describe('BoxPlot', () => {
],
},
]
- const { chart } = renderHogChart(<BoxPlot series={series} labels={['Mon', 'Tue']} theme={THEME} />)
+ const { chart } = renderChart(<BoxPlot series={series} labels={['Mon', 'Tue']} theme={THEME} />)
const nums = chart.yTicks().map((t) => parseFloat(t.replace(/[^\d.-]/g, '')))
const maxTick = Math.max(...nums.filter((n) => Number.isFinite(n)))
expect(maxTick).toBeGreaterThanOrEqual(130)
@@ -85,7 +85,7 @@ describe('BoxPlot', () => {
{ name: 'below the lower whisker', override: { mean: -50, whiskerMin: 10 }, expectTick: -50 },
])('keeps a mean $name inside the y-axis', ({ override, expectTick }) => {
const series: BoxPlotSeries[] = [{ key: 'a', label: 'A', data: [datum(override)] }]
- const { chart } = renderHogChart(<BoxPlot series={series} labels={['Mon']} theme={THEME} />)
+ const { chart } = renderChart(<BoxPlot series={series} labels={['Mon']} theme={THEME} />)
const nums = chart
.yTicks()
.map((t) => parseFloat(t.replace(/[^\d.-]/g, '')))
@@ -110,7 +110,7 @@ describe('BoxPlot', () => {
],
},
]
- const { chart } = renderHogChart(<BoxPlot series={series} labels={['Mon', 'Tue']} theme={THEME} />)
+ const { chart } = renderChart(<BoxPlot series={series} labels={['Mon', 'Tue']} theme={THEME} />)
const ticks = chart.yTicks()
const maxTickNumeric = Math.max(
...ticks.map((t) => parseFloat(t.replace(/[^\d.-]/g, ''))).filter((n) => Number.isFinite(n))
@@ -119,7 +119,7 @@ describe('BoxPlot', () => {
})
it('lists the labels down the y-axis and the values along x when horizontal', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<BoxPlot series={TWO_SERIES} labels={LABELS} theme={THEME} config={{ axisOrientation: 'horizontal' }} />
)
expect(chart.yTicks()).toEqual(LABELS)
@@ -128,20 +128,20 @@ describe('BoxPlot', () => {
})
it('forwards `dataAttr` to the chart wrapper', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<BoxPlot series={TWO_SERIES} labels={LABELS} theme={THEME} dataAttr="boxplot-instance" />
)
expect(chart.element.getAttribute('data-attr')).toBe('boxplot-instance')
})
it('renders empty state without crashing', () => {
- const { chart } = renderHogChart(<BoxPlot series={[]} labels={[]} theme={THEME} />)
+ const { chart } = renderChart(<BoxPlot series={[]} labels={[]} theme={THEME} />)
expect(chart.seriesCount).toBe(0)
})
it('tolerates null entries in series data', () => {
const series: BoxPlotSeries[] = [{ key: 'a', label: 'A', data: [datum(), null, datum()] }]
- const { chart } = renderHogChart(<BoxPlot series={series} labels={LABELS} theme={THEME} />)
+ const { chart } = renderChart(<BoxPlot series={series} labels={LABELS} theme={THEME} />)
expect(chart.seriesCount).toBe(1)
})
@@ -155,13 +155,13 @@ describe('BoxPlot', () => {
visibility: { excluded: true },
},
]
- const { chart } = renderHogChart(<BoxPlot series={series} labels={LABELS} theme={THEME} />)
+ const { chart } = renderChart(<BoxPlot series={series} labels={LABELS} theme={THEME} />)
expect(chart.seriesCount).toBe(1)
})
describe('tooltip context', () => {
it('exposes the original BoxPlotDatum on each series via meta.datums (six stats reachable)', async () => {
- const { chart } = renderHogChart(<BoxPlot series={TWO_SERIES} labels={LABELS} theme={THEME} />)
+ const { chart } = renderChart(<BoxPlot series={TWO_SERIES} labels={LABELS} theme={THEME} />)
chart.hoverAtIndex(1)
const tooltip = await chart.waitForTooltip()
const aMeta = tooltip.series.a!.series.meta as { datums: (BoxPlotDatum | null)[] }
@@ -178,7 +178,7 @@ describe('BoxPlot', () => {
})
it('includes the x-axis label in the tooltip context', async () => {
- const { chart } = renderHogChart(<BoxPlot series={TWO_SERIES} labels={LABELS} theme={THEME} />)
+ const { chart } = renderChart(<BoxPlot series={TWO_SERIES} labels={LABELS} theme={THEME} />)
chart.hoverAtIndex(1)
const tooltip = await chart.waitForTooltip()
expect(tooltip.label).toBe('Tue')
@@ -198,11 +198,11 @@ describe('BoxPlot', () => {
]
it('renders the six stats in the canonical order (Max → p75 → Median → Mean → p25 → Min)', async () => {
- const { chart } = renderHogChart(<BoxPlot series={SINGLE_SERIES} labels={LABELS} theme={THEME} />, {
+ const { chart } = renderChart(<BoxPlot series={SINGLE_SERIES} labels={LABELS} theme={THEME} />, {
nativeTooltip: true,
})
chart.hoverAtIndex(0)
- const tooltipEl = await waitForHogChartTooltip()
+ const tooltipEl = await waitForChartTooltip()
const rowLabels = Array.from(tooltipEl.querySelectorAll('tr')).map((tr) =>
(tr.firstElementChild as HTMLElement).textContent!.trim()
)
@@ -277,12 +277,12 @@ describe('BoxPlot', () => {
const series: BoxPlotSeries[] = [
{ key: 'a', label: 'A-label', data: [datum(override), datum(), datum()] },
]
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<BoxPlot series={series} labels={LABELS} theme={THEME} config={config} />,
{ nativeTooltip: true }
)
chart.hoverAtIndex(0)
- const tooltipEl = await waitForHogChartTooltip()
+ const tooltipEl = await waitForChartTooltip()
const rendered = Array.from(tooltipEl.querySelectorAll('tr')).map((tr) => [
(tr.firstElementChild as HTMLElement).textContent!.trim(),
(tr.lastElementChild as HTMLElement).textContent!.trim(),
@@ -292,11 +292,11 @@ describe('BoxPlot', () => {
)
it('renders the values in the canonical row order', async () => {
- const { chart } = renderHogChart(<BoxPlot series={SINGLE_SERIES} labels={LABELS} theme={THEME} />, {
+ const { chart } = renderChart(<BoxPlot series={SINGLE_SERIES} labels={LABELS} theme={THEME} />, {
nativeTooltip: true,
})
chart.hoverAtIndex(0)
- const tooltipEl = await waitForHogChartTooltip()
+ const tooltipEl = await waitForChartTooltip()
const values = Array.from(tooltipEl.querySelectorAll('tr')).map((tr) =>
(tr.lastElementChild as HTMLElement).textContent!.trim()
)
@@ -304,20 +304,20 @@ describe('BoxPlot', () => {
})
it('shows the x label in the header', async () => {
- const { chart } = renderHogChart(<BoxPlot series={SINGLE_SERIES} labels={LABELS} theme={THEME} />, {
+ const { chart } = renderChart(<BoxPlot series={SINGLE_SERIES} labels={LABELS} theme={THEME} />, {
nativeTooltip: true,
})
chart.hoverAtIndex(0)
- const tooltipEl = await waitForHogChartTooltip()
+ const tooltipEl = await waitForChartTooltip()
expect(tooltipEl.textContent).toContain('Mon')
})
it('renders one stat table per visible series when grouped (multi-series)', async () => {
- const { chart } = renderHogChart(<BoxPlot series={TWO_SERIES} labels={LABELS} theme={THEME} />, {
+ const { chart } = renderChart(<BoxPlot series={TWO_SERIES} labels={LABELS} theme={THEME} />, {
nativeTooltip: true,
})
chart.hoverAtIndex(0)
- const tooltipEl = await waitForHogChartTooltip()
+ const tooltipEl = await waitForChartTooltip()
// Per-series header labels show in grouped mode.
expect(tooltipEl.textContent).toContain('A')
expect(tooltipEl.textContent).toContain('B')
@@ -325,11 +325,11 @@ describe('BoxPlot', () => {
})
it('hides the per-series label when not grouped (single series)', async () => {
- const { chart } = renderHogChart(<BoxPlot series={SINGLE_SERIES} labels={LABELS} theme={THEME} />, {
+ const { chart } = renderChart(<BoxPlot series={SINGLE_SERIES} labels={LABELS} theme={THEME} />, {
nativeTooltip: true,
})
chart.hoverAtIndex(0)
- const tooltipEl = await waitForHogChartTooltip()
+ const tooltipEl = await waitForChartTooltip()
const headers = Array.from(tooltipEl.querySelectorAll('.font-semibold')).map((el) => el.textContent)
// The single "Mon" header is the only font-semibold heading in single-series mode.
expect(headers).toContain('Mon')
@@ -340,12 +340,12 @@ describe('BoxPlot', () => {
const userTooltip = jest.fn(
(): React.ReactElement => <div data-attr="custom-boxplot-user-tooltip">custom</div>
)
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<BoxPlot series={SINGLE_SERIES} labels={LABELS} theme={THEME} tooltip={userTooltip} />,
{ nativeTooltip: true }
)
chart.hoverAtIndex(0)
- const tooltipEl = await waitForHogChartTooltip()
+ const tooltipEl = await waitForChartTooltip()
expect(tooltipEl.querySelector('[data-attr="custom-boxplot-user-tooltip"]')).not.toBeNull()
expect(userTooltip).toHaveBeenCalled()
})
@@ -354,7 +354,7 @@ describe('BoxPlot', () => {
describe('click', () => {
it('invokes onBoxClick with the clicked datum and cross-series data', async () => {
const onBoxClick = jest.fn()
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<BoxPlot series={TWO_SERIES} labels={LABELS} theme={THEME} onBoxClick={onBoxClick} />
)
await chart.clickAtIndex(1)
@@ -386,7 +386,7 @@ describe('BoxPlot', () => {
const tooltip = (): React.ReactNode => {
throw new Error('boom')
}
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<BoxPlot series={TWO_SERIES} labels={LABELS} theme={THEME} tooltip={tooltip} onError={onError} />
)
chart.hoverAtIndex(1)
@@ -396,7 +396,7 @@ describe('BoxPlot', () => {
describe('children', () => {
it('renders custom overlay children', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<BoxPlot series={TWO_SERIES} labels={LABELS} theme={THEME}>
<div data-attr="custom-box-child" />
</BoxPlot>
diff --git a/packages/quill/packages/charts/src/charts/ComboChart/ComboChart.test.tsx b/packages/quill/packages/charts/src/charts/ComboChart/ComboChart.test.tsx
index 4819f6e8330b..ef3087e205db 100644
--- a/packages/quill/packages/charts/src/charts/ComboChart/ComboChart.test.tsx
+++ b/packages/quill/packages/charts/src/charts/ComboChart/ComboChart.test.tsx
@@ -1,6 +1,6 @@
import type { ChartTheme, Series } from '../../core/types'
import { ReferenceLine } from '../../overlays/ReferenceLine'
-import { renderHogChart } from '../../testing'
+import { renderChart } from '../../testing'
import { ComboChart } from './ComboChart'
const THEME: ChartTheme = {
@@ -19,7 +19,7 @@ const BAR_AND_LINE: Series[] = [
describe('ComboChart', () => {
it('renders a bar + line combo without crashing', () => {
- const { chart } = renderHogChart(<ComboChart series={BAR_AND_LINE} labels={LABELS} theme={THEME} />)
+ const { chart } = renderChart(<ComboChart series={BAR_AND_LINE} labels={LABELS} theme={THEME} />)
expect(chart.seriesCount).toBe(2)
expect(chart.yTicks().length).toBeGreaterThan(0)
})
@@ -29,24 +29,24 @@ describe('ComboChart', () => {
{ key: 'area', label: 'Area', data: [10, 30, 20], type: 'area' },
{ key: 'avg', label: 'Avg', data: [15, 25, 20], type: 'line' },
]
- const { chart } = renderHogChart(<ComboChart series={series} labels={LABELS} theme={THEME} />)
+ const { chart } = renderChart(<ComboChart series={series} labels={LABELS} theme={THEME} />)
expect(chart.seriesCount).toBe(2)
})
it('renders empty state without crashing', () => {
- const { chart } = renderHogChart(<ComboChart series={[]} labels={[]} theme={THEME} />)
+ const { chart } = renderChart(<ComboChart series={[]} labels={[]} theme={THEME} />)
expect(chart.seriesCount).toBe(0)
})
it('forwards `dataAttr` to the chart wrapper', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<ComboChart series={BAR_AND_LINE} labels={LABELS} theme={THEME} dataAttr="combo-instance" />
)
expect(chart.element.getAttribute('data-attr')).toBe('combo-instance')
})
it('applies xTickFormatter to x-axis ticks', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<ComboChart
series={BAR_AND_LINE}
labels={LABELS}
@@ -62,14 +62,14 @@ describe('ComboChart', () => {
{ key: 'b', label: 'B', data: [40, 60, 50], type: 'bar' },
{ key: 'l', label: 'L', data: [1000, 2000, 3000], type: 'line', yAxisId: 'right' },
]
- const { chart } = renderHogChart(<ComboChart series={series} labels={LABELS} theme={THEME} />)
+ const { chart } = renderChart(<ComboChart series={series} labels={LABELS} theme={THEME} />)
expect(chart.hasRightAxis).toBe(true)
expect(chart.yRightTicks().length).toBeGreaterThan(0)
})
describe('percent barLayout', () => {
it('applies a default percent formatter when the consumer omits one', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<ComboChart series={BAR_AND_LINE} labels={LABELS} theme={THEME} config={{ barLayout: 'percent' }} />
)
expect(chart.yTicks().some((t) => /\d+%/.test(t))).toBe(true)
@@ -77,7 +77,7 @@ describe('ComboChart', () => {
it('renders a custom percent formatter when the consumer supplies one', () => {
const formatter = jest.fn((v: number) => `${Math.round(v * 1000) / 10}‰`)
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<ComboChart
series={BAR_AND_LINE}
labels={LABELS}
@@ -92,7 +92,7 @@ describe('ComboChart', () => {
describe('hover & tooltip', () => {
it('lists every visible series at the hovered x', async () => {
- const { chart } = renderHogChart(<ComboChart series={BAR_AND_LINE} labels={LABELS} theme={THEME} />)
+ const { chart } = renderChart(<ComboChart series={BAR_AND_LINE} labels={LABELS} theme={THEME} />)
chart.hoverAtIndex(1)
const tooltip = await chart.waitForTooltip()
const keys = tooltip.seriesData.map((s) => s.series.key).sort()
@@ -104,7 +104,7 @@ describe('ComboChart', () => {
{ key: 'b', label: 'B', data: [10, 20, 30], type: 'bar' },
{ key: 'l', label: 'L', data: [5, 15, 25], type: 'line' },
]
- const { chart } = renderHogChart(<ComboChart series={onlyLine} labels={LABELS} theme={THEME} />)
+ const { chart } = renderChart(<ComboChart series={onlyLine} labels={LABELS} theme={THEME} />)
chart.hoverAtIndex(1)
const tooltip = await chart.waitForTooltip()
const keys = tooltip.seriesData.map((s) => s.series.key)
@@ -116,7 +116,7 @@ describe('ComboChart', () => {
{ key: 'b', label: 'Revenue', data: [1000, 2000, 1500], type: 'bar' },
{ key: 'l', label: 'Conv', data: [0.02, 0.03, 0.025], type: 'line', yAxisId: 'right' },
]
- const { chart } = renderHogChart(<ComboChart series={series} labels={LABELS} theme={THEME} />)
+ const { chart } = renderChart(<ComboChart series={series} labels={LABELS} theme={THEME} />)
chart.hoverAtIndex(1)
const tooltip = await chart.waitForTooltip()
expect(tooltip.seriesData.map((s) => s.series.key).sort()).toEqual(['b', 'l'])
@@ -124,7 +124,7 @@ describe('ComboChart', () => {
})
it('pins the tooltip on click when tooltip.pinnable is true', async () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<ComboChart
series={BAR_AND_LINE}
labels={LABELS}
@@ -145,7 +145,7 @@ describe('ComboChart', () => {
{ key: 'b', label: 'B', data: [5, 15, 25], type: 'bar' },
{ key: 'l', label: 'L', data: [50, 60, 70], type: 'line' },
]
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<ComboChart series={series} labels={LABELS} theme={THEME} config={{ barLayout: 'stacked' }} />
)
chart.hoverAtIndex(1)
@@ -164,7 +164,7 @@ describe('ComboChart', () => {
{ key: 'neg', label: 'Neg', data: [-20, -30, -10], type: 'bar' },
{ key: 'l', label: 'L', data: [5, 10, 15], type: 'line' },
]
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<ComboChart
series={series}
labels={LABELS}
@@ -182,7 +182,7 @@ describe('ComboChart', () => {
describe('children & error boundary', () => {
it('renders a ReferenceLine child via the accessor', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<ComboChart series={BAR_AND_LINE} labels={LABELS} theme={THEME}>
<ReferenceLine value={45} label="Target" />
</ComboChart>
@@ -202,7 +202,7 @@ describe('ComboChart', () => {
// getBoundingClientRect spy that restoreAllMocks would also tear down.
const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(() => {})
try {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<ComboChart
series={BAR_AND_LINE}
labels={LABELS}
diff --git a/packages/quill/packages/charts/src/charts/FunnelChart/FunnelChart.test.tsx b/packages/quill/packages/charts/src/charts/FunnelChart/FunnelChart.test.tsx
index 8d67d43305ff..3aaead28f662 100644
--- a/packages/quill/packages/charts/src/charts/FunnelChart/FunnelChart.test.tsx
+++ b/packages/quill/packages/charts/src/charts/FunnelChart/FunnelChart.test.tsx
@@ -1,7 +1,7 @@
import { fireEvent, waitFor } from '@testing-library/react'
import type { ChartTheme, Series } from '../../core/types'
-import { createDefaultTooltipAccessor, renderHogChart } from '../../testing'
+import { createDefaultTooltipAccessor, renderChart } from '../../testing'
import { dimensions } from '../../testing/jsdom'
import { funnelFromCounts } from './funnel-data'
import { FunnelChart, type FunnelStepClickData } from './FunnelChart'
@@ -23,7 +23,7 @@ describe('FunnelChart', () => {
it('keeps steps with the same display name on separate bands', () => {
// Bands are keyed by step index; keying by name would collapse both `Pageview`
// steps into one d3 band slot and the funnel would lose a step.
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<FunnelChart
steps={['Pageview', 'Pageview']}
series={[{ key: 'all', label: 'All', data: [100, 40] }]}
@@ -34,7 +34,7 @@ describe('FunnelChart', () => {
})
it('formats the value axis as percentages by default', () => {
- const { chart } = renderHogChart(<FunnelChart steps={STEPS} series={SERIES} theme={THEME} />)
+ const { chart } = renderChart(<FunnelChart steps={STEPS} series={SERIES} theme={THEME} />)
const ticks = chart.yTicks()
expect(ticks.length).toBeGreaterThan(0)
expect(ticks.every((tick) => tick.endsWith('%'))).toBe(true)
@@ -42,8 +42,8 @@ describe('FunnelChart', () => {
it('tooltip header shows the step name and value is formatted as X.XX%', async () => {
// nativeTooltip preserves config-level formatters (valueFormatter / labelFormatter);
- // the default renderHogChart path intercepts the tooltip prop and bypasses them.
- const { chart } = renderHogChart(<FunnelChart steps={STEPS} series={SERIES} theme={THEME} />, {
+ // the default renderChart path intercepts the tooltip prop and bypasses them.
+ const { chart } = renderChart(<FunnelChart steps={STEPS} series={SERIES} theme={THEME} />, {
nativeTooltip: true,
})
const step = dimensions.plotWidth / STEPS.length
@@ -70,7 +70,7 @@ describe('FunnelChart', () => {
{ area: 'bar fill', clientYOffset: dimensions.plotHeight - 2, converted: true },
])('onStepClick maps a click on the $area to converted=$converted', ({ clientYOffset, converted }) => {
const onStepClick = jest.fn()
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<FunnelChart steps={STEPS} series={SERIES} theme={THEME} onStepClick={onStepClick} />
)
const step = dimensions.plotWidth / STEPS.length
@@ -87,7 +87,7 @@ describe('FunnelChart', () => {
it('floors a near-zero bar for interaction: track above, converted tooltip and click near the baseline', async () => {
// Without the floor a 0.1% bar is sub-pixel and the whole column classifies as drop-off.
const onStepClick = jest.fn()
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<FunnelChart
steps={STEPS}
series={[{ key: 'all', label: 'All', data: [100, 0.1] }]}
@@ -114,7 +114,7 @@ describe('FunnelChart', () => {
})
it('renders one step-footer cell per step and hides the axis step labels', async () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<FunnelChart
steps={STEPS}
series={SERIES}
@@ -133,7 +133,7 @@ describe('FunnelChart', () => {
it('never asks for a step footer past the current step count when a shorter funnel replaces a longer one', async () => {
const THREE_STEPS = ['Exposure', 'Add to cart', 'Purchase']
const requested: number[] = []
- const { rerender } = renderHogChart(
+ const { rerender } = renderChart(
<FunnelChart
steps={THREE_STEPS}
series={[{ key: 'all', label: 'All', data: [100, 60, 20] }]}
@@ -172,7 +172,7 @@ describe('FunnelChart', () => {
})
it('floors the chart region height with chartMinHeight so a tall footer cannot collapse the canvas', async () => {
- renderHogChart(
+ renderChart(
<FunnelChart
steps={STEPS}
series={SERIES}
diff --git a/packages/quill/packages/charts/src/charts/Heatmap/Heatmap.test.tsx b/packages/quill/packages/charts/src/charts/Heatmap/Heatmap.test.tsx
index 7e8a295b261d..4f7a590d4e07 100644
--- a/packages/quill/packages/charts/src/charts/Heatmap/Heatmap.test.tsx
+++ b/packages/quill/packages/charts/src/charts/Heatmap/Heatmap.test.tsx
@@ -1,7 +1,7 @@
import { waitFor } from '@testing-library/react'
import type { ChartTheme } from '../../core/types'
-import { rawDrag, renderHogChart } from '../../testing'
+import { rawDrag, renderChart } from '../../testing'
import { Heatmap, type HeatmapBrushData, type HeatmapCellDatum, type HeatmapCellStyle } from './Heatmap'
const THEME: ChartTheme = {
@@ -24,14 +24,14 @@ const CELLS = [
describe('Heatmap', () => {
it('renders one adapter series per row', () => {
- const { chart } = renderHogChart(<Heatmap xLabels={X_LABELS} yLabels={Y_LABELS} cells={CELLS} theme={THEME} />)
+ const { chart } = renderChart(<Heatmap xLabels={X_LABELS} yLabels={Y_LABELS} cells={CELLS} theme={THEME} />)
expect(chart.seriesCount).toBe(Y_LABELS.length)
})
// The categorical y-axis rides the numeric tick machinery (row-center values + a formatter
// mapping back to labels). If that adapter breaks, ticks render as raw numbers like "0.5".
it('renders row labels, not row-unit numbers, as y-axis ticks', () => {
- const { chart } = renderHogChart(<Heatmap xLabels={X_LABELS} yLabels={Y_LABELS} cells={CELLS} theme={THEME} />)
+ const { chart } = renderChart(<Heatmap xLabels={X_LABELS} yLabels={Y_LABELS} cells={CELLS} theme={THEME} />)
const ticks = chart.yTicks()
expect(ticks.length).toBeGreaterThan(0)
for (const tick of ticks) {
@@ -40,7 +40,7 @@ describe('Heatmap', () => {
})
it('renders column labels as x-axis ticks', () => {
- const { chart } = renderHogChart(<Heatmap xLabels={X_LABELS} yLabels={Y_LABELS} cells={CELLS} theme={THEME} />)
+ const { chart } = renderChart(<Heatmap xLabels={X_LABELS} yLabels={Y_LABELS} cells={CELLS} theme={THEME} />)
const ticks = chart.xTicks()
expect(ticks.length).toBeGreaterThan(0)
for (const tick of ticks) {
@@ -52,12 +52,12 @@ describe('Heatmap', () => {
// Columns are keyed by index, not label text; keying by label would collapse the two
// "10:00" columns onto one x position, dropping a tick and misrouting hover/click.
const dupLabels = ['10:00', '10:00', '10:02', '10:04']
- const { chart } = renderHogChart(<Heatmap xLabels={dupLabels} yLabels={Y_LABELS} cells={CELLS} theme={THEME} />)
+ const { chart } = renderChart(<Heatmap xLabels={dupLabels} yLabels={Y_LABELS} cells={CELLS} theme={THEME} />)
expect(chart.xTicks()).toEqual(dupLabels)
})
it('tolerates a ragged cells grid without crashing', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<Heatmap xLabels={X_LABELS} yLabels={Y_LABELS} cells={[[1], [2, 3]]} theme={THEME} />
)
expect(chart.seriesCount).toBe(Y_LABELS.length)
@@ -73,16 +73,14 @@ describe('Heatmap', () => {
xLabels: string[] = X_LABELS,
cells: number[][] = CELLS
): HTMLElement[] {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<Heatmap xLabels={xLabels} yLabels={Y_LABELS} cells={cells} theme={THEME} config={{ cellLabel }} />
)
return cellLabels(chart.element)
}
it('renders no labels without a formatter', () => {
- const { chart } = renderHogChart(
- <Heatmap xLabels={X_LABELS} yLabels={Y_LABELS} cells={CELLS} theme={THEME} />
- )
+ const { chart } = renderChart(<Heatmap xLabels={X_LABELS} yLabels={Y_LABELS} cells={CELLS} theme={THEME} />)
expect(cellLabels(chart.element)).toHaveLength(0)
})
@@ -117,7 +115,7 @@ describe('Heatmap', () => {
// accent instead would print white text on a pale cell and dark text on an unfilled one.
describe('cellStyle', () => {
function labelColor(cellStyle: (cell: HeatmapCellDatum) => HeatmapCellStyle | null): string {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<Heatmap
xLabels={X_LABELS}
yLabels={Y_LABELS}
@@ -149,7 +147,7 @@ describe('Heatmap', () => {
{ filled: true, fills: X_LABELS.length * Y_LABELS.length },
])('paints $fills fills on an all-zero grid when filled is $filled', async ({ filled, fills }) => {
const zeros = Y_LABELS.map(() => X_LABELS.map(() => 0))
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<Heatmap
xLabels={X_LABELS}
yLabels={Y_LABELS}
@@ -170,7 +168,7 @@ describe('Heatmap', () => {
describe('onBrush', () => {
async function brush(from: { x: number; y: number }, to: { x: number; y: number }): Promise<HeatmapBrushData> {
const onBrush = jest.fn()
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<Heatmap xLabels={X_LABELS} yLabels={Y_LABELS} cells={CELLS} theme={THEME} onBrush={onBrush} />
)
// The chart commits scales in a post-render effect; retry the drag until it lands.
diff --git a/packages/quill/packages/charts/src/charts/LineChart/LineChart.test.tsx b/packages/quill/packages/charts/src/charts/LineChart/LineChart.test.tsx
index 579d2b656bd3..96cc8ffc2ef7 100644
--- a/packages/quill/packages/charts/src/charts/LineChart/LineChart.test.tsx
+++ b/packages/quill/packages/charts/src/charts/LineChart/LineChart.test.tsx
@@ -2,7 +2,7 @@ import { fireEvent } from '@testing-library/react'
import type { ChartTheme, Series } from '../../core/types'
import { ReferenceLine } from '../../overlays/ReferenceLine'
-import { dimensions as testDimensions, getHogChart, rawDrag, renderHogChart } from '../../testing'
+import { dimensions as testDimensions, getChart, rawDrag, renderChart } from '../../testing'
import { LineChart } from './LineChart'
function legendButtons(container: HTMLElement): HTMLButtonElement[] {
@@ -30,12 +30,12 @@ describe('LineChart', () => {
['area mode', [{ key: 'a', label: 'A', data: [10, 20, 30], fill: {} }] as Series[], undefined],
['percent stack mode', SERIES, { percentStackView: true }],
] as const)('renders without throwing in %s', (_, series, config) => {
- const { chart } = renderHogChart(<LineChart series={series} labels={LABELS} theme={THEME} config={config} />)
+ const { chart } = renderChart(<LineChart series={series} labels={LABELS} theme={THEME} config={config} />)
expect(chart.seriesCount).toBeGreaterThan(0)
})
it('renders empty state without crashing', () => {
- const { chart } = renderHogChart(<LineChart series={[]} labels={[]} theme={THEME} />)
+ const { chart } = renderChart(<LineChart series={[]} labels={[]} theme={THEME} />)
expect(chart.seriesCount).toBe(0)
})
@@ -50,19 +50,19 @@ describe('LineChart', () => {
},
{ key: 'c', label: 'C', data: [3, 6, 9] },
]
- const { chart } = renderHogChart(<LineChart series={series} labels={LABELS} theme={THEME} />)
+ const { chart } = renderChart(<LineChart series={series} labels={LABELS} theme={THEME} />)
expect(chart.seriesCount).toBe(2)
})
it('forwards `dataAttr` to the chart wrapper for product-test selection', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<LineChart series={SERIES} labels={LABELS} theme={THEME} dataAttr="line-chart-instance" />
)
expect(chart.element.getAttribute('data-attr')).toBe('line-chart-instance')
})
it('applies a default percent formatter when consumer omits one in percent stack mode', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<LineChart series={SERIES} labels={LABELS} theme={THEME} config={{ percentStackView: true }} />
)
expect(chart.yTicks().some((t) => /\d+%/.test(t))).toBe(true)
@@ -70,7 +70,7 @@ describe('LineChart', () => {
it('uses custom yTickFormatter when supplied in percent stack mode', () => {
const formatter = jest.fn((v: number) => `${Math.round(v * 1000) / 10}‰`)
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<LineChart
series={SERIES}
labels={LABELS}
@@ -90,7 +90,7 @@ describe('LineChart', () => {
data: [Number.NaN, Number.NaN, Number.NaN],
},
]
- const { chart } = renderHogChart(<LineChart series={broken} labels={LABELS} theme={THEME} />)
+ const { chart } = renderChart(<LineChart series={broken} labels={LABELS} theme={THEME} />)
expect(chart.seriesCount).toBe(1)
})
@@ -99,14 +99,12 @@ describe('LineChart', () => {
['hideXAxis', { hideXAxis: true }, 'xTicks'],
['hideYAxis', { hideYAxis: true }, 'yTicks'],
] as const)('hides ticks when %s is true', (_, config, accessor) => {
- const { chart } = renderHogChart(
- <LineChart series={SERIES} labels={LABELS} theme={THEME} config={config} />
- )
+ const { chart } = renderChart(<LineChart series={SERIES} labels={LABELS} theme={THEME} config={config} />)
expect(chart[accessor]()).toHaveLength(0)
})
it('applies xTickFormatter to x-axis ticks', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<LineChart
series={SERIES}
labels={LABELS}
@@ -118,7 +116,7 @@ describe('LineChart', () => {
})
it('renders custom axis titles', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<LineChart
series={SERIES}
labels={LABELS}
@@ -134,7 +132,7 @@ describe('LineChart', () => {
})
it('includes custom axis titles in the canvas accessible label', () => {
- const { getByRole } = renderHogChart(
+ const { getByRole } = renderChart(
<LineChart
series={SERIES}
labels={LABELS}
@@ -151,7 +149,7 @@ describe('LineChart', () => {
})
it('ignores whitespace-only axis titles', () => {
- const { chart, getByRole } = renderHogChart(
+ const { chart, getByRole } = renderChart(
<LineChart
series={SERIES}
labels={LABELS}
@@ -168,7 +166,7 @@ describe('LineChart', () => {
it('truncates long axis titles without losing the full label metadata', () => {
const xAxisLabel = 'Signup date for a very long customer lifecycle analysis '.repeat(30).trim()
const yAxisLabel = 'Unique users with a very long aggregation description '.repeat(30).trim()
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<LineChart series={SERIES} labels={LABELS} theme={THEME} config={{ xAxisLabel, yAxisLabel }} />
)
@@ -184,7 +182,7 @@ describe('LineChart', () => {
})
it('hides an axis title when that axis is hidden', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<LineChart
series={SERIES}
labels={LABELS}
@@ -210,7 +208,7 @@ describe('LineChart', () => {
yAxisId: 'right',
},
]
- const { chart } = renderHogChart(<LineChart series={series} labels={LABELS} theme={THEME} />)
+ const { chart } = renderChart(<LineChart series={series} labels={LABELS} theme={THEME} />)
expect(chart.hasRightAxis).toBe(true)
expect(chart.yRightTicks().length).toBeGreaterThan(0)
})
@@ -226,7 +224,7 @@ describe('LineChart', () => {
yAxisId: 'y2',
},
]
- const { chart } = renderHogChart(<LineChart series={series} labels={LABELS} theme={THEME} />)
+ const { chart } = renderChart(<LineChart series={series} labels={LABELS} theme={THEME} />)
expect(chart.hasRightAxis).toBe(true)
const leftValues = chart.yTicks().map((t) => parseFloat(t.replace(/[^0-9.]/g, '')))
// 30 is the default axis max, 5000 the third axis max — both gutters stack on the left.
@@ -236,7 +234,7 @@ describe('LineChart', () => {
it('renders without crashing in yScaleType log with positive data', () => {
const series: Series[] = [{ key: 'a', label: 'A', data: [1, 10, 100] }]
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<LineChart series={series} labels={LABELS} theme={THEME} config={{ yScaleType: 'log' }} />
)
const ticks = chart.yTicks()
@@ -249,7 +247,7 @@ describe('LineChart', () => {
describe('hover & tooltip', () => {
it('mounts a tooltip on hover', async () => {
- const { chart } = renderHogChart(<LineChart series={SERIES} labels={LABELS} theme={THEME} />)
+ const { chart } = renderChart(<LineChart series={SERIES} labels={LABELS} theme={THEME} />)
chart.hoverAtIndex(1)
const tooltip = await chart.waitForTooltip()
expect(tooltip.element.textContent).toContain('Tue')
@@ -257,7 +255,7 @@ describe('LineChart', () => {
it('invokes onPointClick with the clicked column', async () => {
const onPointClick = jest.fn()
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<LineChart series={SERIES} labels={LABELS} theme={THEME} onPointClick={onPointClick} />
)
await chart.clickAtIndex(1)
@@ -271,14 +269,14 @@ describe('LineChart', () => {
})
it('passes hovered seriesData to the tooltip render prop', async () => {
- const { chart } = renderHogChart(<LineChart series={SERIES} labels={LABELS} theme={THEME} />)
+ const { chart } = renderChart(<LineChart series={SERIES} labels={LABELS} theme={THEME} />)
chart.hoverAtIndex(1)
const tooltip = await chart.waitForTooltip()
expect(tooltip.seriesData).toHaveLength(SERIES.length)
})
it('pins the tooltip on click when tooltip.pinnable is true', async () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<LineChart series={SERIES} labels={LABELS} theme={THEME} config={{ tooltip: { pinnable: true } }} />
)
await chart.clickAtIndex(1)
@@ -291,7 +289,7 @@ describe('LineChart', () => {
{ key: 'a', label: 'A', data: [10, 20, 30] },
{ key: 'b', label: 'B', data: [5, 15, 25], overlay: true },
]
- const { chart } = renderHogChart(<LineChart series={series} labels={LABELS} theme={THEME} />)
+ const { chart } = renderChart(<LineChart series={series} labels={LABELS} theme={THEME} />)
chart.hoverAtIndex(1)
const tooltip = await chart.waitForTooltip()
expect(tooltip.element.textContent).toContain('Tue')
@@ -307,7 +305,7 @@ describe('LineChart', () => {
visibility: { tooltip: false },
},
]
- const { chart } = renderHogChart(<LineChart series={series} labels={LABELS} theme={THEME} />)
+ const { chart } = renderChart(<LineChart series={series} labels={LABELS} theme={THEME} />)
chart.hoverAtIndex(1)
const tooltip = await chart.waitForTooltip()
expect(tooltip.element.textContent).toContain('A')
@@ -321,7 +319,7 @@ describe('LineChart', () => {
it('fires onDateRangeZoom with the start and end labels of the dragged range', () => {
const onDateRangeZoom = jest.fn()
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<LineChart series={LONG_SERIES} labels={LONG_LABELS} theme={THEME} onDateRangeZoom={onDateRangeZoom} />
)
chart.dragSelection(1, 3)
@@ -336,7 +334,7 @@ describe('LineChart', () => {
it('normalizes a right-to-left drag', () => {
const onDateRangeZoom = jest.fn()
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<LineChart series={LONG_SERIES} labels={LONG_LABELS} theme={THEME} onDateRangeZoom={onDateRangeZoom} />
)
chart.dragSelection(3, 1)
@@ -351,7 +349,7 @@ describe('LineChart', () => {
it('does not fire onPointClick when a drag completes', () => {
const onDateRangeZoom = jest.fn()
const onPointClick = jest.fn()
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<LineChart
series={LONG_SERIES}
labels={LONG_LABELS}
@@ -368,7 +366,7 @@ describe('LineChart', () => {
it('still fires onPointClick on a plain click when onDateRangeZoom is set', async () => {
const onDateRangeZoom = jest.fn()
const onPointClick = jest.fn()
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<LineChart
series={LONG_SERIES}
labels={LONG_LABELS}
@@ -383,7 +381,7 @@ describe('LineChart', () => {
})
it('switches the wrapper cursor to crosshair when onDateRangeZoom is provided', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<LineChart series={LONG_SERIES} labels={LONG_LABELS} theme={THEME} onDateRangeZoom={jest.fn()} />
)
expect(chart.element.classList).toContain('cursor-crosshair')
@@ -392,7 +390,7 @@ describe('LineChart', () => {
it('a drag that releases outside the wrapper does not swallow the next unrelated click', async () => {
const onDateRangeZoom = jest.fn()
const onPointClick = jest.fn()
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<LineChart
series={LONG_SERIES}
labels={LONG_LABELS}
@@ -419,7 +417,7 @@ describe('LineChart', () => {
it('click-without-drag still dismisses a pinned tooltip when onDateRangeZoom is set', async () => {
const onDateRangeZoom = jest.fn()
const onPointClick = jest.fn()
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<LineChart
series={[
{ key: 'a', label: 'A', data: [10, 20, 30, 40, 50] },
@@ -444,7 +442,7 @@ describe('LineChart', () => {
it('treats a sub-threshold mousedown+move as a click, not a drag', async () => {
const onDateRangeZoom = jest.fn()
const onPointClick = jest.fn()
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<LineChart
series={LONG_SERIES}
labels={LONG_LABELS}
@@ -467,7 +465,7 @@ describe('LineChart', () => {
it('ignores a non-primary-button drag', () => {
const onDateRangeZoom = jest.fn()
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<LineChart series={LONG_SERIES} labels={LONG_LABELS} theme={THEME} onDateRangeZoom={onDateRangeZoom} />
)
const y = testDimensions.plotTop + testDimensions.plotHeight / 2
@@ -481,7 +479,7 @@ describe('LineChart', () => {
it('does not start a drag from outside the plot area', () => {
const onDateRangeZoom = jest.fn()
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<LineChart series={LONG_SERIES} labels={LONG_LABELS} theme={THEME} onDateRangeZoom={onDateRangeZoom} />
)
const yAbovePlot = testDimensions.plotTop - 5
@@ -495,7 +493,7 @@ describe('LineChart', () => {
describe('children & error boundary', () => {
it('renders custom overlay children', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<LineChart series={SERIES} labels={LABELS} theme={THEME}>
<div data-attr="custom-child" />
</LineChart>
@@ -504,7 +502,7 @@ describe('LineChart', () => {
})
it('renders a ReferenceLine child via the accessor', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<LineChart series={SERIES} labels={LABELS} theme={THEME}>
<ReferenceLine value={15} label="Target" />
</LineChart>
@@ -523,7 +521,7 @@ describe('LineChart', () => {
// ChartErrorBoundary surfaces the error to onError; React still logs it.
const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(() => {})
try {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<LineChart series={SERIES} labels={LABELS} theme={THEME} tooltip={tooltip} onError={onError} />
)
chart.hoverAtIndex(1)
@@ -536,50 +534,50 @@ describe('LineChart', () => {
describe('interactive legend', () => {
it('renders no legend by default', () => {
- const { container } = renderHogChart(<LineChart series={SERIES} labels={LABELS} theme={THEME} />)
+ const { container } = renderChart(<LineChart series={SERIES} labels={LABELS} theme={THEME} />)
expect(container.querySelector('[data-attr="hog-chart-line-legend"]')).toBeNull()
})
it('renders a clickable legend item per series when legend.show is set', () => {
- const { container } = renderHogChart(
+ const { container } = renderChart(
<LineChart series={SERIES} labels={LABELS} theme={THEME} config={{ legend: { show: true } }} />
)
expect(legendButtons(container).map((b) => b.textContent)).toEqual(['A', 'B'])
})
it('isolates a series on legend click and shows them all again on a second click', () => {
- const { container, chart } = renderHogChart(
+ const { container, chart } = renderChart(
<LineChart series={SERIES} labels={LABELS} theme={THEME} config={{ legend: { show: true } }} />
)
expect(chart.seriesCount).toBe(2)
fireEvent.click(legendButtons(container)[1])
- expect(getHogChart(container).seriesCount).toBe(1)
+ expect(getChart(container).seriesCount).toBe(1)
// The isolated-away row stays in the legend (dimmed) so it can be restored.
const dimmed = legendButtons(container).filter((b) => b.className.includes('opacity-40'))
expect(dimmed.map((b) => b.textContent)).toEqual(['A'])
fireEvent.click(legendButtons(container)[1])
- expect(getHogChart(container).seriesCount).toBe(2)
+ expect(getChart(container).seriesCount).toBe(2)
})
it('hides just one series on a meta-click and shows it again on a second one', () => {
- const { container, chart } = renderHogChart(
+ const { container, chart } = renderChart(
<LineChart series={SERIES} labels={LABELS} theme={THEME} config={{ legend: { show: true } }} />
)
expect(chart.seriesCount).toBe(2)
fireEvent.click(legendButtons(container)[1], { metaKey: true })
- expect(getHogChart(container).seriesCount).toBe(1)
+ expect(getChart(container).seriesCount).toBe(1)
const dimmed = legendButtons(container).filter((b) => b.className.includes('opacity-40'))
expect(dimmed.map((b) => b.textContent)).toEqual(['B'])
fireEvent.click(legendButtons(container)[1], { metaKey: true })
- expect(getHogChart(container).seriesCount).toBe(2)
+ expect(getChart(container).seriesCount).toBe(2)
})
it('renders a static (non-clickable) legend when interactive is false', () => {
- const { container } = renderHogChart(
+ const { container } = renderChart(
<LineChart
series={SERIES}
labels={LABELS}
diff --git a/packages/quill/packages/charts/src/charts/PieChart/PieChart.test.tsx b/packages/quill/packages/charts/src/charts/PieChart/PieChart.test.tsx
index 76ed789762db..16fca09eb97b 100644
--- a/packages/quill/packages/charts/src/charts/PieChart/PieChart.test.tsx
+++ b/packages/quill/packages/charts/src/charts/PieChart/PieChart.test.tsx
@@ -4,7 +4,7 @@ import React from 'react'
import type { RadialSlicePayload } from '../../core/hooks/useRadialInteraction'
import { RADIAL_MARGINS } from '../../core/RadialChart'
import type { ResolvedSeries, ChartTheme, Series } from '../../core/types'
-import { getHogChartTooltip, renderHogChart } from '../../testing'
+import { getChartTooltip, renderChart } from '../../testing'
import { mockRect } from '../../testing/jsdom'
import { computePieLayout } from './computePieLayout'
import type { PieLayout } from './computePieLayout'
@@ -51,33 +51,31 @@ function sliceLabels(wrapper: HTMLElement): string[] {
describe('PieChart', () => {
it('renders a canvas labeled as a pie chart with one slice per series', () => {
- const { container } = renderHogChart(<PieChart series={SERIES} theme={THEME} />)
+ const { container } = renderChart(<PieChart series={SERIES} theme={THEME} />)
const canvas = container.querySelector('canvas[aria-label]')
expect(canvas?.getAttribute('aria-label')).toBe('Pie chart with 2 slices')
})
it('forwards dataAttr to the chart wrapper', () => {
- const { chart } = renderHogChart(<PieChart series={SERIES} theme={THEME} dataAttr="pie-instance" />)
+ const { chart } = renderChart(<PieChart series={SERIES} theme={THEME} dataAttr="pie-instance" />)
expect(chart.element.getAttribute('data-attr')).toBe('pie-instance')
})
it('renders one on-slice value label per slice by default', () => {
- const { chart } = renderHogChart(<PieChart series={SERIES} theme={THEME} />)
+ const { chart } = renderChart(<PieChart series={SERIES} theme={THEME} />)
const labels = sliceLabels(chart.element)
expect(labels).toHaveLength(2)
expect(labels.join('|')).toContain('50')
})
it('renders percentage labels when isPercent is set', () => {
- const { chart } = renderHogChart(<PieChart series={SERIES} theme={THEME} config={{ isPercent: true }} />)
+ const { chart } = renderChart(<PieChart series={SERIES} theme={THEME} config={{ isPercent: true }} />)
const text = sliceLabels(chart.element).join('|')
expect(text).toContain('50%')
})
it('renders value and percentage on one line when sliceValueDisplay is both', () => {
- const { chart } = renderHogChart(
- <PieChart series={SERIES} theme={THEME} config={{ sliceValueDisplay: 'both' }} />
- )
+ const { chart } = renderChart(<PieChart series={SERIES} theme={THEME} config={{ sliceValueDisplay: 'both' }} />)
expect(sliceLabels(chart.element).join('|')).toContain('50 (50%)')
})
@@ -86,19 +84,19 @@ describe('PieChart', () => {
['hidden on a donut by default', { innerRadiusRatio: 0.5 }, false],
['shown on a donut that sets showValueOnSlice', { innerRadiusRatio: 0.5, showValueOnSlice: true }, true],
])('on-slice value labels are %s', (_name, config, shown) => {
- const { chart } = renderHogChart(<PieChart series={SERIES} theme={THEME} config={config} />)
+ const { chart } = renderChart(<PieChart series={SERIES} theme={THEME} config={config} />)
expect(sliceLabels(chart.element).length > 0).toBe(shown)
})
it('renders a center label for a donut', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<PieChart series={SERIES} theme={THEME} config={{ innerRadiusRatio: 0.5 }} centerLabel="Total: 100" />
)
expect(chart.element.textContent).toContain('Total: 100')
})
it('renders custom overlay children', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<PieChart series={SERIES} theme={THEME}>
<div data-attr="custom-child" />
</PieChart>
@@ -107,13 +105,13 @@ describe('PieChart', () => {
})
it('renders an empty pie (zero total) without crashing and with no slice labels', () => {
- const { chart } = renderHogChart(<PieChart series={[{ key: 'a', label: 'A', data: [0] }]} theme={THEME} />)
+ const { chart } = renderChart(<PieChart series={[{ key: 'a', label: 'A', data: [0] }]} theme={THEME} />)
expect(sliceLabels(chart.element)).toHaveLength(0)
})
describe('hover & tooltip', () => {
it('shows a tooltip for the slice under the cursor', async () => {
- const { chart } = renderHogChart(<PieChart series={SERIES} theme={THEME} />)
+ const { chart } = renderChart(<PieChart series={SERIES} theme={THEME} />)
const layout = layoutFor(SERIES)
fireEvent.mouseMove(chart.element, pointInSlice(layout, 0))
const tooltip = await chart.waitForTooltip()
@@ -122,7 +120,7 @@ describe('PieChart', () => {
})
it('switches the tooltip to the other slice when the cursor moves', async () => {
- const { chart } = renderHogChart(<PieChart series={SERIES} theme={THEME} />)
+ const { chart } = renderChart(<PieChart series={SERIES} theme={THEME} />)
const layout = layoutFor(SERIES)
fireEvent.mouseMove(chart.element, pointInSlice(layout, 1))
const tooltip = await chart.waitForTooltip()
@@ -130,24 +128,22 @@ describe('PieChart', () => {
})
it('shows no tooltip when hovering the donut hole', async () => {
- const { chart } = renderHogChart(
- <PieChart series={SERIES} theme={THEME} config={{ innerRadiusRatio: 0.5 }} />
- )
+ const { chart } = renderChart(<PieChart series={SERIES} theme={THEME} config={{ innerRadiusRatio: 0.5 }} />)
const layout = layoutFor(SERIES, 0.5)
// Dead center is inside the inner radius — a hit-test miss.
fireEvent.mouseMove(chart.element, { clientX: layout.cx, clientY: layout.cy })
await new Promise((resolve) => setTimeout(resolve, 0))
- expect(getHogChartTooltip()?.textContent ?? '').toBe('')
+ expect(getChartTooltip()?.textContent ?? '').toBe('')
})
})
describe('slice click', () => {
it('invokes onSliceClick with the clicked slice payload', async () => {
const onSliceClick = jest.fn<void, [RadialSlicePayload]>()
- const { chart } = renderHogChart(<PieChart series={SERIES} theme={THEME} onSliceClick={onSliceClick} />)
+ const { chart } = renderChart(<PieChart series={SERIES} theme={THEME} onSliceClick={onSliceClick} />)
const layout = layoutFor(SERIES)
fireEvent.mouseMove(chart.element, pointInSlice(layout, 1))
- await waitFor(() => expect(getHogChartTooltip()).not.toBeNull())
+ await waitFor(() => expect(getChartTooltip()).not.toBeNull())
fireEvent.click(chart.element)
expect(onSliceClick).toHaveBeenCalledWith(
expect.objectContaining({ sliceIndex: 1, value: 50, fraction: 0.5 })
@@ -157,7 +153,7 @@ describe('PieChart', () => {
it('does not invoke onSliceClick when the click misses every slice', () => {
const onSliceClick = jest.fn()
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<PieChart
series={SERIES}
theme={THEME}
@@ -181,12 +177,12 @@ describe('PieChart', () => {
}
it('renders no legend by default', () => {
- const { container } = renderHogChart(<PieChart series={SERIES} theme={THEME} />)
+ const { container } = renderChart(<PieChart series={SERIES} theme={THEME} />)
expect(container.querySelector('[data-attr="hog-chart-pie-legend"]')).toBeNull()
})
it('isolates a slice on legend click and restores them all on a second click', () => {
- const { container } = renderHogChart(
+ const { container } = renderChart(
<PieChart series={SERIES} theme={THEME} config={{ legend: { show: true } }} />
)
expect(legendButtons(container).map((b) => b.textContent)).toEqual(['Chrome', 'Firefox'])
@@ -217,7 +213,7 @@ describe('PieChart', () => {
}
const consoleErrorSpy = jest.spyOn(console, 'error').mockImplementation(() => {})
try {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<PieChart series={SERIES} theme={THEME} tooltip={tooltip} onError={onError} />
)
const layout = layoutFor(SERIES)
diff --git a/packages/quill/packages/charts/src/charts/ProportionBar/ProportionBar.test.tsx b/packages/quill/packages/charts/src/charts/ProportionBar/ProportionBar.test.tsx
index 3890a85593d5..269d99e9744f 100644
--- a/packages/quill/packages/charts/src/charts/ProportionBar/ProportionBar.test.tsx
+++ b/packages/quill/packages/charts/src/charts/ProportionBar/ProportionBar.test.tsx
@@ -2,7 +2,7 @@ import { fireEvent } from '@testing-library/react'
import type { RadialSlicePayload } from '../../core/hooks/useRadialInteraction'
import type { ChartTheme, Series } from '../../core/types'
-import { mockRect, renderHogChart, waitForHogChartTooltip } from '../../testing'
+import { mockRect, renderChart, waitForChartTooltip } from '../../testing'
import { ProportionBar } from './ProportionBar'
const THEME: ChartTheme = { colors: ['#22d3ee', '#f14f58', '#a78bfa'], backgroundColor: '#ffffff' }
@@ -19,9 +19,9 @@ const INSIDE_B = at(650)
describe('ProportionBar', () => {
it('hands the tooltip the hovered part with its raw value, like a pie', async () => {
- const { chart } = renderHogChart(<ProportionBar series={PARTS} theme={THEME} />)
+ const { chart } = renderChart(<ProportionBar series={PARTS} theme={THEME} />)
- await waitForHogChartTooltip(3000, () => fireEvent.mouseMove(chart.element, INSIDE_B))
+ await waitForChartTooltip(3000, () => fireEvent.mouseMove(chart.element, INSIDE_B))
const tooltip = await chart.waitForTooltip()
expect(tooltip).toMatchObject({ label: 'b', dataIndex: 1 })
@@ -38,7 +38,7 @@ describe('ProportionBar', () => {
{ name: 'a hidden part before it', hidden: ['a'], cursor: at(200), sliceIndex: 0, fraction: 0.5 },
])('reports the clicked part like a pie slice, with $name', async ({ hidden, cursor, sliceIndex, fraction }) => {
const onSliceClick = jest.fn()
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<ProportionBar
series={PARTS}
theme={THEME}
@@ -47,7 +47,7 @@ describe('ProportionBar', () => {
/>
)
- await waitForHogChartTooltip(3000, () => fireEvent.mouseMove(chart.element, cursor))
+ await waitForChartTooltip(3000, () => fireEvent.mouseMove(chart.element, cursor))
fireEvent.click(chart.element)
const payload: RadialSlicePayload = onSliceClick.mock.calls[0][0]
@@ -76,7 +76,7 @@ describe('ProportionBar', () => {
({ series, hidden, secondaryLabels }) => {
const onSliceClick = jest.fn()
const onError = jest.fn()
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<ProportionBar
series={series}
theme={THEME}
@@ -95,7 +95,7 @@ describe('ProportionBar', () => {
)
it('recomputes the legend shares over the parts left visible', () => {
- const { chart } = renderHogChart(<ProportionBar series={PARTS} theme={THEME} />)
+ const { chart } = renderChart(<ProportionBar series={PARTS} theme={THEME} />)
expect(chart.legendItems().map((item) => item.secondaryLabel)).toEqual([
'75% · 600',
'12.5% · 100',
diff --git a/packages/quill/packages/charts/src/charts/SankeyChart/SankeyChart.test.tsx b/packages/quill/packages/charts/src/charts/SankeyChart/SankeyChart.test.tsx
index 152438a4b5ab..d636a166cf49 100644
--- a/packages/quill/packages/charts/src/charts/SankeyChart/SankeyChart.test.tsx
+++ b/packages/quill/packages/charts/src/charts/SankeyChart/SankeyChart.test.tsx
@@ -1,7 +1,7 @@
import { fireEvent, render, waitFor } from '@testing-library/react'
import type { ChartTheme } from '../../core/types'
-import { getHogChartTooltip, renderHogChart } from '../../testing'
+import { getChartTooltip, renderChart } from '../../testing'
import { computeSankeyLayout } from './sankey-data'
import type { SankeyLinkInput, SankeyNodeDatum, SankeyNodeInput } from './sankey-data'
import { labelsSharingLastGap, outsideLabelWidth, sankeyLabelBoxes } from './sankey-labels'
@@ -39,7 +39,7 @@ function nodeCenter(id: string): { clientX: number; clientY: number } {
describe('SankeyChart', () => {
it('renders node labels and column headers as DOM overlays', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<SankeyChart
nodes={NODES}
links={LINKS}
@@ -55,7 +55,7 @@ describe('SankeyChart', () => {
it('drops the label of a thin node that would print over its larger neighbor', () => {
// Two thin nodes stacked in one column: their boxes are a pixel or two tall, so their label
// centers sit closer than a line of text. The larger flow keeps its label.
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<SankeyChart
nodes={[
{ id: 'start', label: 'Start' },
@@ -78,7 +78,7 @@ describe('SankeyChart', () => {
it('shows the hovered node in the tooltip, reports it once, and fires onNodeClick for it', async () => {
const onNodeClick = jest.fn()
const onHoverChange = jest.fn()
- const { chart, rerender } = renderHogChart(
+ const { chart, rerender } = renderChart(
<SankeyChart
nodes={NODES}
links={LINKS}
@@ -90,10 +90,10 @@ describe('SankeyChart', () => {
)
await waitFor(() => {
fireEvent.mouseMove(chart.element, nodeCenter('a'))
- expect(getHogChartTooltip()?.textContent).toContain('Tool A')
+ expect(getChartTooltip()?.textContent).toContain('Tool A')
})
// The share is of the total inflow, so the only path reads as 100%.
- expect(getHogChartTooltip()?.textContent).toContain('100%')
+ expect(getChartTooltip()?.textContent).toContain('100%')
fireEvent.click(chart.element)
expect(onNodeClick).toHaveBeenCalledWith(expect.objectContaining({ id: 'a', value: 12 }))
@@ -105,7 +105,7 @@ describe('SankeyChart', () => {
await waitFor(() => {
fireEvent.mouseMove(chart.element, nodeCenter('a'))
- expect(getHogChartTooltip()?.textContent).toContain('Tool A')
+ expect(getChartTooltip()?.textContent).toContain('Tool A')
})
rerender(
@@ -117,7 +117,7 @@ describe('SankeyChart', () => {
onHoverChange={onHoverChange}
/>
)
- expect(getHogChartTooltip()?.textContent).toContain('Tool A')
+ expect(getChartTooltip()?.textContent).toContain('Tool A')
expect(onHoverChange).not.toHaveBeenLastCalledWith(null)
onNodeClick.mockClear()
@@ -131,7 +131,7 @@ describe('SankeyChart', () => {
config={{ nodeWidth: 24 }}
/>
)
- await waitFor(() => expect(getHogChartTooltip()).toBeNull())
+ await waitFor(() => expect(getChartTooltip()).toBeNull())
// The hovered node belonged to the old layout, so the host is told it is gone.
expect(onHoverChange).toHaveBeenLastCalledWith(null)
fireEvent.click(chart.element)
@@ -141,7 +141,7 @@ describe('SankeyChart', () => {
it('shows the tooltip on a first tap, fires onNodeClick on the second, and clears on an empty tap', async () => {
const onNodeClick = jest.fn()
const onHoverChange = jest.fn()
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<SankeyChart
nodes={NODES}
links={LINKS}
@@ -159,7 +159,7 @@ describe('SankeyChart', () => {
fireEvent.click(chart.element, at)
}
tap(nodeCenter('a'))
- await waitFor(() => expect(getHogChartTooltip()?.textContent).toContain('Tool A'))
+ await waitFor(() => expect(getChartTooltip()?.textContent).toContain('Tool A'))
expect(onNodeClick).not.toHaveBeenCalled()
tap(nodeCenter('a'))
expect(onNodeClick).toHaveBeenCalledWith(expect.objectContaining({ id: 'a' }))
@@ -172,7 +172,7 @@ describe('SankeyChart', () => {
it('ignores a tap on an interactive overlay over a node', () => {
const onNodeClick = jest.fn()
const onHoverChange = jest.fn()
- const { chart, getByRole } = renderHogChart(
+ const { chart, getByRole } = renderChart(
<SankeyChart
nodes={NODES}
links={LINKS}
@@ -194,7 +194,7 @@ describe('SankeyChart', () => {
it('fires the click on the first tap when the tooltip is disabled', () => {
const onNodeClick = jest.fn()
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<SankeyChart
nodes={NODES}
links={LINKS}
@@ -212,7 +212,7 @@ describe('SankeyChart', () => {
it('ignores hover and clicks from an interactive overlay child', async () => {
const onNodeClick = jest.fn()
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<SankeyChart nodes={NODES} links={LINKS} theme={THEME} onNodeClick={onNodeClick}>
<button data-hog-charts-interactive-overlay>overlay</button>
</SankeyChart>,
@@ -220,11 +220,11 @@ describe('SankeyChart', () => {
)
await waitFor(() => {
fireEvent.mouseMove(chart.element, nodeCenter('a'))
- expect(getHogChartTooltip()?.textContent).toContain('Tool A')
+ expect(getChartTooltip()?.textContent).toContain('Tool A')
})
const overlay = chart.element.querySelector('[data-hog-charts-interactive-overlay]')!
fireEvent.mouseMove(overlay, nodeCenter('a'))
- await waitFor(() => expect(getHogChartTooltip()).toBeNull())
+ await waitFor(() => expect(getChartTooltip()).toBeNull())
fireEvent.click(overlay, nodeCenter('a'))
expect(onNodeClick).not.toHaveBeenCalled()
})
@@ -277,16 +277,16 @@ describe('SankeyChart', () => {
})
it('shows the node tooltip when the pointer is over its label, not the ribbon under it', async () => {
- const { chart } = renderHogChart(<SankeyChart nodes={NODES} links={LINKS} theme={THEME} />, {
+ const { chart } = renderChart(<SankeyChart nodes={NODES} links={LINKS} theme={THEME} />, {
nativeTooltip: true,
})
// Right of the Start node, inside its label and over the Start -> Tool A ribbon.
const start = nodeCenter('start')
await waitFor(() => {
fireEvent.mouseMove(chart.element, { clientX: start.clientX + 17, clientY: start.clientY })
- expect(getHogChartTooltip()?.textContent).toContain('Start')
+ expect(getChartTooltip()?.textContent).toContain('Start')
})
- expect(getHogChartTooltip()?.textContent).not.toContain('→')
+ expect(getChartTooltip()?.textContent).not.toContain('→')
})
it('places last-column labels outside the nodes when asked, and truncates headers to their span', () => {
@@ -347,7 +347,7 @@ describe('SankeyChart', () => {
{ id: 'done', label: 'Completed after a very long outcome name that needs the full margin' },
]
// An 800px wrapper with a 700px left margin leaves a 92px plot, under the 160px label cap.
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<SankeyChart
nodes={nodes}
links={[{ source: 'start', target: 'done', value: 5 }]}
@@ -362,7 +362,7 @@ describe('SankeyChart', () => {
})
it('keeps room for column headers when a consumer overrides the top margin', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<SankeyChart
nodes={NODES}
links={LINKS}
diff --git a/packages/quill/packages/charts/src/charts/ScatterChart/ScatterChart.test.tsx b/packages/quill/packages/charts/src/charts/ScatterChart/ScatterChart.test.tsx
index f841fe45dc22..69a436eb90f9 100644
--- a/packages/quill/packages/charts/src/charts/ScatterChart/ScatterChart.test.tsx
+++ b/packages/quill/packages/charts/src/charts/ScatterChart/ScatterChart.test.tsx
@@ -1,13 +1,7 @@
import { act, fireEvent, waitFor } from '@testing-library/react'
import type { ChartMargins, ChartTheme } from '../../core/types'
-import {
- createDefaultTooltipAccessor,
- getHogChartTooltip,
- rawDrag,
- renderHogChart,
- waitForHogChartTooltip,
-} from '../../testing'
+import { createDefaultTooltipAccessor, getChartTooltip, rawDrag, renderChart, waitForChartTooltip } from '../../testing'
import { ScatterChart } from './ScatterChart'
import type { ScatterAreaSelection, ScatterChartConfig, ScatterPointDatum, ScatterSeries } from './types'
@@ -40,10 +34,8 @@ const SERIES: ScatterSeries[] = [
{ key: 'writes', label: 'Writes', points: [{ x: 0, y: 100, label: 'Top left' }] },
]
-function renderScatter(
- props: Partial<React.ComponentProps<typeof ScatterChart>> = {}
-): ReturnType<typeof renderHogChart> {
- return renderHogChart(
+function renderScatter(props: Partial<React.ComponentProps<typeof ScatterChart>> = {}): ReturnType<typeof renderChart> {
+ return renderChart(
<ScatterChart
series={SERIES}
theme={THEME}
@@ -56,7 +48,7 @@ function renderScatter(
/** Hover a data coordinate, re-dispatching until the chart has committed its scales. */
async function hoverPoint(wrapper: HTMLElement, x: number, y: number): Promise<HTMLElement> {
- return waitForHogChartTooltip(3000, () => {
+ return waitForChartTooltip(3000, () => {
act(() => {
fireEvent.mouseMove(wrapper, { clientX: clientX(x), clientY: clientY(y) })
})
@@ -66,17 +58,35 @@ async function hoverPoint(wrapper: HTMLElement, x: number, y: number): Promise<H
describe('ScatterChart', () => {
it('draws selection highlights without rereading point geometry', () => {
let coordinateReads = 0
- const series: ScatterSeries[] = [{key: 'sample', label: 'Sample', points: [
- {get x(): number { coordinateReads++; return 25 }, y: 80},
- {get x(): number { coordinateReads++; return 100 }, y: 0},
- ]}]
- const config = {margins: MARGINS}
- const {chart, rerender} = renderScatter({series, config})
+ const series: ScatterSeries[] = [
+ {
+ key: 'sample',
+ label: 'Sample',
+ points: [
+ {
+ get x(): number {
+ coordinateReads++
+ return 25
+ },
+ y: 80,
+ },
+ {
+ get x(): number {
+ coordinateReads++
+ return 100
+ },
+ y: 0,
+ },
+ ],
+ },
+ ]
+ const config = { margins: MARGINS }
+ const { chart, rerender } = renderScatter({ series, config })
const readsBeforeHighlight = coordinateReads
const stroke = jest.spyOn(chart.canvas.getContext('2d')!, 'stroke')
const strokesBeforeHighlight = stroke.mock.calls.length
- const highlight = jest.fn((point: {x: number}) => point.x === 25)
- rerender(<ScatterChart series={series} theme={THEME} config={{...config, isPointHighlighted: highlight}} />)
+ const highlight = jest.fn((point: { x: number }) => point.x === 25)
+ rerender(<ScatterChart series={series} theme={THEME} config={{ ...config, isPointHighlighted: highlight }} />)
expect(highlight).toHaveBeenCalled()
expect(stroke.mock.calls.length).toBeGreaterThan(strokesBeforeHighlight)
expect(coordinateReads).toBe(readsBeforeHighlight)
@@ -150,7 +160,7 @@ describe('ScatterChart', () => {
],
},
]
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<ScatterChart
series={series}
theme={THEME}
@@ -163,7 +173,7 @@ describe('ScatterChart', () => {
{ nativeTooltip: true }
)
// A log scale clamps, so the excluded point would otherwise sit hoverable on the top edge.
- await waitForHogChartTooltip(3000, () => {
+ await waitForChartTooltip(3000, () => {
act(() => {
fireEvent.mouseMove(chart.element, { clientX: clientX(10), clientY: PLOT_HEIGHT / 2 })
})
@@ -171,7 +181,7 @@ describe('ScatterChart', () => {
act(() => {
fireEvent.mouseMove(chart.element, { clientX: clientX(10), clientY: 4 })
})
- await waitFor(() => expect(getHogChartTooltip()).toBeNull())
+ await waitFor(() => expect(getChartTooltip()).toBeNull())
})
it('drops a legend-hidden series from the plot, not just from the legend', async () => {
@@ -181,7 +191,7 @@ describe('ScatterChart', () => {
act(() => {
fireEvent.mouseMove(chart.element, { clientX: clientX(0), clientY: clientY(100) })
})
- await waitFor(() => expect(getHogChartTooltip()).toBeNull())
+ await waitFor(() => expect(getChartTooltip()).toBeNull())
})
it('reports the clicked point with its series and consumer meta', async () => {
@@ -189,7 +199,7 @@ describe('ScatterChart', () => {
const series: ScatterSeries<{ orgId: string }>[] = [
{ key: 'orgs', label: 'Orgs', points: [{ x: 100, y: 100, label: 'Hedgebox', meta: { orgId: 'hb' } }] },
]
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<ScatterChart series={series} theme={THEME} config={{ margins: MARGINS }} onPointClick={onPointClick} />,
{ nativeTooltip: true }
)
diff --git a/packages/quill/packages/charts/src/charts/SlopeChart/SlopeChart.test.tsx b/packages/quill/packages/charts/src/charts/SlopeChart/SlopeChart.test.tsx
index 04b12a1a108b..2dfb48539ef1 100644
--- a/packages/quill/packages/charts/src/charts/SlopeChart/SlopeChart.test.tsx
+++ b/packages/quill/packages/charts/src/charts/SlopeChart/SlopeChart.test.tsx
@@ -1,7 +1,7 @@
import { fireEvent } from '@testing-library/react'
import type { ChartTheme, Series, TooltipContext } from '../../core/types'
-import { getHogChart, renderHogChart } from '../../testing'
+import { getChart, renderChart } from '../../testing'
import { sortSlopeTooltipRows, type SlopeSeriesMeta } from './slope-data'
import { SlopeChart } from './SlopeChart'
@@ -21,14 +21,14 @@ const SERIES: Series<SlopeSeriesMeta>[] = [
describe('SlopeChart', () => {
it('renders the two columns and hides the value axis by default', () => {
- const { chart } = renderHogChart(<SlopeChart series={SERIES} labels={LABELS} theme={THEME} />)
+ const { chart } = renderChart(<SlopeChart series={SERIES} labels={LABELS} theme={THEME} />)
expect(chart.seriesCount).toBe(2)
expect(chart.xTicks()).toEqual(['Before', 'After'])
expect(chart.yTicks()).toHaveLength(0)
})
it('renders empty state without crashing', () => {
- const { chart } = renderHogChart(<SlopeChart series={[]} labels={LABELS} theme={THEME} />)
+ const { chart } = renderChart(<SlopeChart series={[]} labels={LABELS} theme={THEME} />)
expect(chart.seriesCount).toBe(0)
expect(chart.slopeValueLabels()).toHaveLength(0)
})
@@ -43,7 +43,7 @@ describe('SlopeChart', () => {
visibility: { excluded: true },
},
]
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<SlopeChart series={series} labels={LABELS} config={{ legend: { show: true } }} theme={THEME} />
)
expect(chart.seriesCount).toBe(2)
@@ -53,7 +53,7 @@ describe('SlopeChart', () => {
describe('value labels', () => {
it('shows both start and end value labels for every series by default', () => {
- const { chart } = renderHogChart(<SlopeChart series={SERIES} labels={LABELS} theme={THEME} />)
+ const { chart } = renderChart(<SlopeChart series={SERIES} labels={LABELS} theme={THEME} />)
const labels = chart.slopeValueLabels()
expect(
labels
@@ -82,9 +82,7 @@ describe('SlopeChart', () => {
},
{ key: 'b', label: 'B', data: [80, 20] },
]
- const { chart } = renderHogChart(
- <SlopeChart series={series} labels={LABELS} theme={THEME} config={config} />
- )
+ const { chart } = renderChart(<SlopeChart series={series} labels={LABELS} theme={THEME} config={config} />)
const sideTexts = chart.slopeValueLabels().filter((l) => l.side === side)
// The toggled series (`a`) is missing from that column, the other (`b`) remains.
const aValue = side === 'start' ? '10' : '90'
@@ -102,7 +100,7 @@ describe('SlopeChart', () => {
},
{ key: 'b', label: 'B', data: [80, 20] },
]
- const { chart } = renderHogChart(<SlopeChart series={series} labels={LABELS} theme={THEME} />)
+ const { chart } = renderChart(<SlopeChart series={series} labels={LABELS} theme={THEME} />)
const texts = chart.slopeValueLabels().map((l) => l.text)
expect(texts).toEqual(expect.arrayContaining(['80', '20']))
expect(texts).not.toContain('10')
@@ -110,7 +108,7 @@ describe('SlopeChart', () => {
})
it('formats values with a custom valueFormatter', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<SlopeChart series={SERIES} labels={LABELS} config={{ valueFormatter: (v) => `${v}%` }} theme={THEME} />
)
expect(chart.slopeValueLabels().every((l) => l.text.endsWith('%'))).toBe(true)
@@ -120,7 +118,7 @@ describe('SlopeChart', () => {
// A conditionally built override (`{ top: reserveOrUndefined }`) must not wipe the
// start-label gutter SlopeChart computed — a plain spread would, clipping the labels.
const startLabelLeft = (config?: Parameters<typeof SlopeChart>[0]['config']): string => {
- const { container } = renderHogChart(
+ const { container } = renderChart(
<SlopeChart series={SERIES} labels={LABELS} config={config} theme={THEME} />
)
const label = container.querySelector<HTMLElement>(
@@ -134,12 +132,12 @@ describe('SlopeChart', () => {
describe('series labels', () => {
it('renders a name label per series by default', () => {
- const { chart } = renderHogChart(<SlopeChart series={SERIES} labels={LABELS} theme={THEME} />)
+ const { chart } = renderChart(<SlopeChart series={SERIES} labels={LABELS} theme={THEME} />)
expect(chart.slopeSeriesLabels().sort()).toEqual(['A', 'B'])
})
it('hides all name labels when showSeriesLabels is false', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<SlopeChart series={SERIES} labels={LABELS} config={{ showSeriesLabels: false }} theme={THEME} />
)
expect(chart.slopeSeriesLabels()).toHaveLength(0)
@@ -151,19 +149,19 @@ describe('SlopeChart', () => {
{ key: 'big', label: 'Big', data: [0, 100] },
{ key: 'sml', label: 'Small', data: [98, 100] },
]
- const { chart } = renderHogChart(<SlopeChart series={series} labels={LABELS} theme={THEME} />)
+ const { chart } = renderChart(<SlopeChart series={series} labels={LABELS} theme={THEME} />)
expect(chart.slopeSeriesLabels()).toEqual(['Big'])
})
})
describe('legend', () => {
it('is hidden unless enabled', () => {
- const { chart } = renderHogChart(<SlopeChart series={SERIES} labels={LABELS} theme={THEME} />)
+ const { chart } = renderChart(<SlopeChart series={SERIES} labels={LABELS} theme={THEME} />)
expect(chart.legendItems()).toHaveLength(0)
})
it('shows the label and signed change for each series', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<SlopeChart series={SERIES} labels={LABELS} config={{ legend: { show: true } }} theme={THEME} />
)
expect(chart.legendItems()).toEqual([
@@ -173,7 +171,7 @@ describe('SlopeChart', () => {
})
it('formats the change with a custom deltaFormatter', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<SlopeChart
series={SERIES}
labels={LABELS}
@@ -194,14 +192,14 @@ describe('SlopeChart', () => {
{ key: 'b', label: 'B', data: [0, 90] },
{ key: 'c', label: 'C', data: [0, 60] },
]
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<SlopeChart series={series} labels={LABELS} config={{ legend: { show: true } }} theme={THEME} />
)
expect(chart.legendItems().map((i) => i.label)).toEqual(['B', 'C', 'A'])
})
it('toggles a series off and on when its legend row is clicked', () => {
- const { container, chart } = renderHogChart(
+ const { container, chart } = renderChart(
<SlopeChart series={SERIES} labels={LABELS} config={{ legend: { show: true } }} theme={THEME} />
)
expect(chart.seriesCount).toBe(2)
@@ -210,16 +208,16 @@ describe('SlopeChart', () => {
Array.from(legend.querySelectorAll('button')).find((b) => b.textContent?.startsWith(label))!
fireEvent.click(buttonFor('A'))
- expect(getHogChart(container).seriesCount).toBe(1)
+ expect(getChart(container).seriesCount).toBe(1)
// The toggled-off series stays listed (so it can be restored).
expect(
- getHogChart(container)
+ getChart(container)
.legendItems()
.map((i) => i.label)
).toEqual(['A', 'B'])
fireEvent.click(buttonFor('A'))
- expect(getHogChart(container).seriesCount).toBe(2)
+ expect(getChart(container).seriesCount).toBe(2)
})
})
@@ -249,7 +247,7 @@ describe('SlopeChart', () => {
] as Series<SlopeSeriesMeta>[],
],
])('%s: xTicks shows only the two real labels', (_desc, series) => {
- const { chart } = renderHogChart(<SlopeChart series={series} labels={LABELS} theme={THEME} />)
+ const { chart } = renderChart(<SlopeChart series={series} labels={LABELS} theme={THEME} />)
expect(chart.xTicks()).toEqual(['Before', 'After'])
})
@@ -288,7 +286,7 @@ describe('SlopeChart', () => {
],
],
])('%s: value labels read the true start and end values', (_desc, series, expected) => {
- const { chart } = renderHogChart(<SlopeChart series={series} labels={LABELS} theme={THEME} />)
+ const { chart } = renderChart(<SlopeChart series={series} labels={LABELS} theme={THEME} />)
const labels = chart.slopeValueLabels().map((l) => ({ side: l.side, text: l.text }))
for (const e of expected) {
expect(labels).toContainEqual(e)
@@ -300,7 +298,7 @@ describe('SlopeChart', () => {
it('slopes a >2-point series to its first and last point and labels', () => {
const series: Series<SlopeSeriesMeta>[] = [{ key: 'a', label: 'A', data: [10, 20, 30, 40] }]
const labels = ['Jan', 'Feb', 'Mar', 'Apr']
- const { chart } = renderHogChart(<SlopeChart series={series} labels={labels} theme={THEME} />)
+ const { chart } = renderChart(<SlopeChart series={series} labels={labels} theme={THEME} />)
// Only the two ends are shown — interior points and labels are dropped.
expect(chart.xTicks()).toEqual(['Jan', 'Apr'])
const values = chart.slopeValueLabels().map((l) => ({ side: l.side, text: l.text }))
@@ -333,7 +331,7 @@ describe('SlopeChart', () => {
})
it('forwards dataAttr to the chart wrapper', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<SlopeChart series={SERIES} labels={LABELS} theme={THEME} dataAttr="slope-instance" />
)
expect(chart.element.getAttribute('data-attr')).toBe('slope-instance')
diff --git a/packages/quill/packages/charts/src/charts/Sparkline/Sparkline.test.tsx b/packages/quill/packages/charts/src/charts/Sparkline/Sparkline.test.tsx
index 4381814bee78..5e89091c9ea0 100644
--- a/packages/quill/packages/charts/src/charts/Sparkline/Sparkline.test.tsx
+++ b/packages/quill/packages/charts/src/charts/Sparkline/Sparkline.test.tsx
@@ -2,7 +2,7 @@ import { fireEvent } from '@testing-library/react'
import type { ChartTheme, TooltipContext } from '../../core/types'
import { DefaultTooltip } from '../../overlays/DefaultTooltip'
-import { createDefaultTooltipAccessor, hoverUntilTooltip, renderHogChart } from '../../testing'
+import { createDefaultTooltipAccessor, hoverUntilTooltip, renderChart } from '../../testing'
import { Sparkline } from './Sparkline'
const THEME: ChartTheme = { colors: ['#22d3ee', '#f14f58'], backgroundColor: '#ffffff' }
@@ -10,13 +10,13 @@ const LABELS = ['Jan', 'Feb', 'Mar', 'Apr']
describe('Sparkline', () => {
it('renders a canvas for the line chart', () => {
- const { container } = renderHogChart(<Sparkline data={[100, 200, 300, 400]} labels={LABELS} theme={THEME} />)
+ const { container } = renderChart(<Sparkline data={[100, 200, 300, 400]} labels={LABELS} theme={THEME} />)
expect(container.querySelector('canvas')).not.toBeNull()
})
it('fires onHoverIndexChange with the hovered index and -1 when leaving', () => {
const onHover = jest.fn()
- const { chart, container } = renderHogChart(
+ const { chart, container } = renderChart(
<Sparkline data={[100, 200, 300, 400]} labels={LABELS} theme={THEME} onHoverIndexChange={onHover} />
)
// Initial hoverIndex is -1, so the first subscription fire matches the "not hovering" state.
@@ -33,7 +33,7 @@ describe('Sparkline', () => {
it('fires -1 on unmount so a parent still mounted does not show a stale positive index', () => {
const onHover = jest.fn()
- const { chart, unmount } = renderHogChart(
+ const { chart, unmount } = renderChart(
<Sparkline data={[100, 200, 300]} labels={LABELS.slice(0, 3)} theme={THEME} onHoverIndexChange={onHover} />
)
chart.hoverAtIndex(1)
@@ -43,12 +43,12 @@ describe('Sparkline', () => {
})
it('does not require labels — falls back to index strings', () => {
- const { container } = renderHogChart(<Sparkline data={[10, 20, 30]} theme={THEME} />)
+ const { container } = renderChart(<Sparkline data={[10, 20, 30]} theme={THEME} />)
expect(container.querySelector('canvas')).not.toBeNull()
})
it('renders multi-series stacked bars via the series prop', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<Sparkline
type="bar"
series={[
@@ -63,7 +63,7 @@ describe('Sparkline', () => {
})
it('tooltips a bar the cursor is above, which a bar chart would not', async () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<Sparkline
type="bar"
data={[100, 1, 1, 1]}
@@ -77,7 +77,7 @@ describe('Sparkline', () => {
})
it('enables the tooltip when a tooltip render prop is supplied', async () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<Sparkline
data={[100, 200, 300, 400]}
labels={LABELS}
diff --git a/packages/quill/packages/charts/src/charts/TimeSeriesBarChart/TimeSeriesBarChart.test.tsx b/packages/quill/packages/charts/src/charts/TimeSeriesBarChart/TimeSeriesBarChart.test.tsx
index c16d3147d19e..f6b79ecf27d0 100644
--- a/packages/quill/packages/charts/src/charts/TimeSeriesBarChart/TimeSeriesBarChart.test.tsx
+++ b/packages/quill/packages/charts/src/charts/TimeSeriesBarChart/TimeSeriesBarChart.test.tsx
@@ -2,7 +2,7 @@ import { fireEvent } from '@testing-library/react'
import { useChartLayout } from '../../core/chart-context'
import type { ChartTheme, Series } from '../../core/types'
-import { getHogChart, renderHogChart } from '../../testing'
+import { getChart, renderChart } from '../../testing'
import { TimeSeriesBarChart } from './TimeSeriesBarChart'
const THEME: ChartTheme = {
@@ -19,7 +19,7 @@ const MULTI_SERIES: Series[] = [
describe('TimeSeriesBarChart', () => {
describe('config.xAxis', () => {
it('hides x-axis ticks when xAxis.hide is true', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesBarChart series={SERIES} labels={LABELS} theme={THEME} config={{ xAxis: { hide: true } }} />
)
expect(chart.xTicks()).toHaveLength(0)
@@ -27,7 +27,7 @@ describe('TimeSeriesBarChart', () => {
it('forwards an explicit xAxis.tickFormatter to the chart', () => {
const explicit = (_v: string, i: number): string => `tick-${i}`
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesBarChart
series={SERIES}
labels={['14:00', '15:00', '16:00']}
@@ -39,7 +39,7 @@ describe('TimeSeriesBarChart', () => {
})
it('rotates rendered ticks when xAxis.tickLabelRotation is set', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesBarChart
series={SERIES}
labels={LABELS}
@@ -55,7 +55,7 @@ describe('TimeSeriesBarChart', () => {
it('builds an auto date formatter from xAxis.timezone + xAxis.interval', () => {
const labels = ['2024-06-10', '2024-06-11', '2024-06-12']
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesBarChart
series={SERIES}
labels={labels}
@@ -70,7 +70,7 @@ describe('TimeSeriesBarChart', () => {
it('explicit xAxis.tickFormatter wins over the auto date formatter', () => {
const explicit = (_v: string, i: number): string => `tick-${i}`
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesBarChart
series={SERIES}
labels={['2024-06-10', '2024-06-11', '2024-06-12']}
@@ -93,7 +93,7 @@ describe('TimeSeriesBarChart', () => {
observed = useChartLayout().axis.xTickFormatter
return null
}
- renderHogChart(
+ renderChart(
<TimeSeriesBarChart
series={SERIES}
labels={['2024-06-10', '2024-06-11', '2024-06-12']}
@@ -110,7 +110,7 @@ describe('TimeSeriesBarChart', () => {
describe('config.yAxis', () => {
it('hides y-axis ticks when yAxis.hide is true', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesBarChart series={SERIES} labels={LABELS} theme={THEME} config={{ yAxis: { hide: true } }} />
)
expect(chart.yTicks()).toHaveLength(0)
@@ -120,7 +120,7 @@ describe('TimeSeriesBarChart', () => {
[{ format: 'percentage' as const }, /\d+%$/],
[{ prefix: '$', suffix: ' req' }, /^\$.* req$/],
])('builds a y-axis tick formatter from yAxis %p', (yAxis, pattern) => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesBarChart series={SERIES} labels={LABELS} theme={THEME} config={{ yAxis }} />
)
expect(chart.yTicks().some((t) => pattern.test(t))).toBe(true)
@@ -128,7 +128,7 @@ describe('TimeSeriesBarChart', () => {
it('explicit yAxis.tickFormatter wins over yAxis.format', () => {
const explicit = (v: number): string => `y:${v}`
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesBarChart
series={SERIES}
labels={LABELS}
@@ -150,7 +150,7 @@ describe('TimeSeriesBarChart', () => {
['omitted', undefined],
['false', false as const],
])('does not render value labels when %s', (_, valueLabels) => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesBarChart
series={SERIES}
labels={LABELS}
@@ -162,7 +162,7 @@ describe('TimeSeriesBarChart', () => {
})
it('renders one value label per visible point when valueLabels=true', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesBarChart series={SERIES} labels={LABELS} theme={THEME} config={{ valueLabels: true }} />
)
expect(chart.valueLabels()).toHaveLength(SERIES[0].data.length)
@@ -170,7 +170,7 @@ describe('TimeSeriesBarChart', () => {
it('forwards an explicit formatter', () => {
const formatter = (v: number): string => `~${v}`
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesBarChart
series={SERIES}
labels={LABELS}
@@ -182,7 +182,7 @@ describe('TimeSeriesBarChart', () => {
})
it('falls back to a yAxis-driven formatter when no explicit formatter is provided', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesBarChart
series={[{ key: 'a', label: 'A', data: [50] }]}
labels={['Mon']}
@@ -198,7 +198,7 @@ describe('TimeSeriesBarChart', () => {
it('reuses an explicit yAxis.tickFormatter as the default', () => {
const explicit = (v: number): string => `y:${v}`
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesBarChart
series={SERIES}
labels={LABELS}
@@ -217,7 +217,7 @@ describe('TimeSeriesBarChart', () => {
{ key: 'a', label: 'A', data: [1, 2, 3] },
{ key: 'b', label: 'B', data: [4, 5, 6] },
]
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesBarChart
series={series}
labels={LABELS}
@@ -234,7 +234,7 @@ describe('TimeSeriesBarChart', () => {
['omitted', undefined],
['empty', [] as never[]],
])('does not render reference lines when goalLines is %s', (_, goalLines) => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesBarChart
series={SERIES}
labels={LABELS}
@@ -246,7 +246,7 @@ describe('TimeSeriesBarChart', () => {
})
it('renders horizontal goal lines with their label', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesBarChart
series={[{ key: 'a', label: 'A', data: [10, 20, 100] }]}
labels={LABELS}
@@ -261,7 +261,7 @@ describe('TimeSeriesBarChart', () => {
})
it('extends the value axis so a goal line above the data still renders', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesBarChart
series={[{ key: 'a', label: 'A', data: [10, 20, 30] }]}
labels={LABELS}
@@ -281,12 +281,12 @@ describe('TimeSeriesBarChart', () => {
Math.max(...chart.yTicks().map((t) => Number(t.replace(/,/g, ''))))
it('pins the value axis to a fixed domain instead of nicing past the data max', () => {
- const unpinned = renderHogChart(
+ const unpinned = renderChart(
<TimeSeriesBarChart series={SPIKY_SERIES} labels={LABELS} theme={THEME} />
).chart
expect(maxTick(unpinned)).toBeGreaterThan(246)
- const pinned = renderHogChart(
+ const pinned = renderChart(
<TimeSeriesBarChart
series={SPIKY_SERIES}
labels={LABELS}
@@ -298,7 +298,7 @@ describe('TimeSeriesBarChart', () => {
})
it('a fixed domain wins over the goal-line stretch', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesBarChart
series={SPIKY_SERIES}
labels={LABELS}
@@ -316,7 +316,7 @@ describe('TimeSeriesBarChart', () => {
{ key: 'a', label: 'A', data: [10, 20, 30] },
{ key: 'b', label: 'B', data: [5, 15, 25] },
]
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesBarChart series={series} labels={LABELS} theme={THEME} config={{ barLayout }} />
)
expect(chart.yTicks().length).toBeGreaterThan(0)
@@ -327,7 +327,7 @@ describe('TimeSeriesBarChart', () => {
{ key: 'a', label: 'A', data: [10, 20, 30] },
{ key: 'b', label: 'B', data: [5, 15, 25] },
]
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesBarChart series={series} labels={LABELS} theme={THEME} config={{ barLayout: 'percent' }} />
)
expect(chart.yTicks().some((t) => /\d+%/.test(t))).toBe(true)
@@ -336,7 +336,7 @@ describe('TimeSeriesBarChart', () => {
it('formats value labels as each segment fraction (0..1) in percent layout', () => {
// Two series with totals (10, 100, 1000); a's share is 0.1, 0.2, 0.3 of each band.
// The `percentage_scaled` formatter takes 0..1 input so the labels render as "10%, 20%, 30%".
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesBarChart
series={[
{ key: 'a', label: 'A', data: [1, 20, 300] },
@@ -364,7 +364,7 @@ describe('TimeSeriesBarChart', () => {
describe('config.axisOrientation', () => {
it('renders ticks on the x-axis when axisOrientation=horizontal', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesBarChart
series={SERIES}
labels={LABELS}
@@ -381,11 +381,11 @@ describe('TimeSeriesBarChart', () => {
// reads it as `marginsOverride` — a misplacement like that would silently no-op with a green
// suite otherwise, since nothing else here reaches `useChartMargins`' override path.
it('widens the left gutter and shifts the y-axis ticks over', () => {
- const { chart: defaultChart } = renderHogChart(
+ const { chart: defaultChart } = renderChart(
<TimeSeriesBarChart series={SERIES} labels={LABELS} theme={THEME} />
)
const defaultTick = defaultChart.element.querySelector<HTMLElement>('[data-attr="hog-chart-axis-tick-y"]')
- const { chart: widenedChart } = renderHogChart(
+ const { chart: widenedChart } = renderChart(
<TimeSeriesBarChart series={SERIES} labels={LABELS} theme={THEME} config={{ margins: { left: 200 } }} />
)
const widenedTick = widenedChart.element.querySelector<HTMLElement>('[data-attr="hog-chart-axis-tick-y"]')
@@ -398,7 +398,7 @@ describe('TimeSeriesBarChart', () => {
})
it('forwards children alongside built-in overlays', () => {
- const { container } = renderHogChart(
+ const { container } = renderChart(
<TimeSeriesBarChart series={SERIES} labels={LABELS} theme={THEME}>
<div data-attr="custom-overlay" />
</TimeSeriesBarChart>
@@ -408,7 +408,7 @@ describe('TimeSeriesBarChart', () => {
describe('interactive legend', () => {
it('toggles a series off and on when its legend row is clicked', () => {
- const { container, chart } = renderHogChart(
+ const { container, chart } = renderChart(
<TimeSeriesBarChart
series={MULTI_SERIES}
labels={LABELS}
@@ -421,10 +421,10 @@ describe('TimeSeriesBarChart', () => {
Array.from(container.querySelectorAll('[data-attr="hog-chart-timeseries-bar-legend"] button'))
fireEvent.click(buttons()[1])
- expect(getHogChart(container).seriesCount).toBe(1)
+ expect(getChart(container).seriesCount).toBe(1)
fireEvent.click(buttons()[1])
- expect(getHogChart(container).seriesCount).toBe(2)
+ expect(getChart(container).seriesCount).toBe(2)
})
})
})
diff --git a/packages/quill/packages/charts/src/charts/TimeSeriesComboChart/TimeSeriesComboChart.test.tsx b/packages/quill/packages/charts/src/charts/TimeSeriesComboChart/TimeSeriesComboChart.test.tsx
index a9e5384d45bd..e07f68680543 100644
--- a/packages/quill/packages/charts/src/charts/TimeSeriesComboChart/TimeSeriesComboChart.test.tsx
+++ b/packages/quill/packages/charts/src/charts/TimeSeriesComboChart/TimeSeriesComboChart.test.tsx
@@ -2,7 +2,7 @@ import { fireEvent } from '@testing-library/react'
import { useChartLayout } from '../../core/chart-context'
import type { ChartTheme, Series } from '../../core/types'
-import { getHogChart, renderHogChart, waitForHogChartTooltip } from '../../testing'
+import { getChart, renderChart, waitForChartTooltip } from '../../testing'
import { TimeSeriesComboChart } from './TimeSeriesComboChart'
const THEME: ChartTheme = {
@@ -17,7 +17,7 @@ const BAR_AND_LINE: Series[] = [
describe('TimeSeriesComboChart', () => {
it('renders mixed bar + line series', () => {
- const { chart } = renderHogChart(<TimeSeriesComboChart series={BAR_AND_LINE} labels={LABELS} theme={THEME} />)
+ const { chart } = renderChart(<TimeSeriesComboChart series={BAR_AND_LINE} labels={LABELS} theme={THEME} />)
expect(chart.seriesCount).toBe(2)
expect(chart.yTicks().length).toBeGreaterThan(0)
})
@@ -29,7 +29,7 @@ describe('TimeSeriesComboChart', () => {
bottomMargin = dimensions.height - dimensions.plotTop - dimensions.plotHeight
return null
}
- renderHogChart(
+ renderChart(
<TimeSeriesComboChart
series={BAR_AND_LINE}
labels={LABELS}
@@ -44,7 +44,7 @@ describe('TimeSeriesComboChart', () => {
describe('config.xAxis', () => {
it('hides x-axis ticks when xAxis.hide is true', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesComboChart
series={BAR_AND_LINE}
labels={LABELS}
@@ -57,7 +57,7 @@ describe('TimeSeriesComboChart', () => {
it('forwards an explicit xAxis.tickFormatter to the chart', () => {
const explicit = (_v: string, i: number): string => `tick-${i}`
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesComboChart
series={BAR_AND_LINE}
labels={['14:00', '15:00', '16:00']}
@@ -70,7 +70,7 @@ describe('TimeSeriesComboChart', () => {
it('builds an auto date formatter from xAxis.timezone + xAxis.interval', () => {
const labels = ['2024-06-10', '2024-06-11', '2024-06-12']
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesComboChart
series={BAR_AND_LINE}
labels={labels}
@@ -89,7 +89,7 @@ describe('TimeSeriesComboChart', () => {
observed = useChartLayout().axis.xTickFormatter
return null
}
- renderHogChart(
+ renderChart(
<TimeSeriesComboChart
series={BAR_AND_LINE}
labels={['2024-06-10', '2024-06-11', '2024-06-12']}
@@ -106,7 +106,7 @@ describe('TimeSeriesComboChart', () => {
describe('config.yAxis', () => {
it('pins the value domain even when a goal line extends beyond it', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesComboChart
series={BAR_AND_LINE}
labels={LABELS}
@@ -120,7 +120,7 @@ describe('TimeSeriesComboChart', () => {
})
it('hides y-axis ticks when yAxis.hide is true', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesComboChart
series={BAR_AND_LINE}
labels={LABELS}
@@ -135,7 +135,7 @@ describe('TimeSeriesComboChart', () => {
[{ format: 'percentage' as const }, /\d+%$/],
[{ prefix: '$', suffix: ' req' }, /^\$.* req$/],
])('builds a y-axis tick formatter from yAxis %p', (yAxis, pattern) => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesComboChart series={BAR_AND_LINE} labels={LABELS} theme={THEME} config={{ yAxis }} />
)
expect(chart.yTicks().some((t) => pattern.test(t))).toBe(true)
@@ -143,7 +143,7 @@ describe('TimeSeriesComboChart', () => {
it('explicit yAxis.tickFormatter wins over yAxis.format', () => {
const explicit = (v: number): string => `y:${v}`
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesComboChart
series={BAR_AND_LINE}
labels={LABELS}
@@ -157,21 +157,19 @@ describe('TimeSeriesComboChart', () => {
describe('config.goalLines', () => {
it('does not render reference lines when config is omitted', () => {
- const { chart } = renderHogChart(
- <TimeSeriesComboChart series={BAR_AND_LINE} labels={LABELS} theme={THEME} />
- )
+ const { chart } = renderChart(<TimeSeriesComboChart series={BAR_AND_LINE} labels={LABELS} theme={THEME} />)
expect(chart.referenceLines()).toHaveLength(0)
})
it('does not render reference lines when goalLines is empty', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesComboChart series={BAR_AND_LINE} labels={LABELS} theme={THEME} config={{ goalLines: [] }} />
)
expect(chart.referenceLines()).toHaveLength(0)
})
it('renders horizontal goal lines with their label', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesComboChart
series={BAR_AND_LINE}
labels={LABELS}
@@ -186,7 +184,7 @@ describe('TimeSeriesComboChart', () => {
})
it('extends the value axis so a goal line above the data still renders', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesComboChart
series={[{ key: 'b', label: 'B', data: [10, 20, 30], type: 'bar' }]}
labels={LABELS}
@@ -200,14 +198,12 @@ describe('TimeSeriesComboChart', () => {
describe('config.valueLabels', () => {
it('does not render value labels when config is omitted', () => {
- const { chart } = renderHogChart(
- <TimeSeriesComboChart series={BAR_AND_LINE} labels={LABELS} theme={THEME} />
- )
+ const { chart } = renderChart(<TimeSeriesComboChart series={BAR_AND_LINE} labels={LABELS} theme={THEME} />)
expect(chart.valueLabels()).toHaveLength(0)
})
it('does not render value labels when valueLabels is false', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesComboChart
series={BAR_AND_LINE}
labels={LABELS}
@@ -220,7 +216,7 @@ describe('TimeSeriesComboChart', () => {
it('forwards an explicit formatter', () => {
const formatter = (v: number): string => `~${v}`
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesComboChart
series={[{ key: 'bar', label: 'Bar', data: [1, 2, 3], type: 'bar' }]}
labels={LABELS}
@@ -243,7 +239,7 @@ describe('TimeSeriesComboChart', () => {
const maxTick = (ticks: string[]): number => Math.max(...ticks.map(Number))
it('stacks bar segments so the y-axis spans the stacked total', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesComboChart
series={STACKABLE}
labels={LABELS}
@@ -255,7 +251,7 @@ describe('TimeSeriesComboChart', () => {
})
it('groups bars so the y-axis spans only the tallest single value', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesComboChart
series={STACKABLE}
labels={LABELS}
@@ -272,13 +268,13 @@ describe('TimeSeriesComboChart', () => {
{ key: 'b', label: 'Revenue', data: [1000, 2000, 1500], type: 'bar' },
{ key: 'l', label: 'Conv', data: [0.02, 0.03, 0.025], type: 'line', yAxisId: 'right' },
]
- const { chart } = renderHogChart(<TimeSeriesComboChart series={series} labels={LABELS} theme={THEME} />)
+ const { chart } = renderChart(<TimeSeriesComboChart series={series} labels={LABELS} theme={THEME} />)
expect(chart.hasRightAxis).toBe(true)
expect(chart.yRightTicks().length).toBeGreaterThan(0)
})
it('forwards children alongside built-in overlays', () => {
- const { container } = renderHogChart(
+ const { container } = renderChart(
<TimeSeriesComboChart series={BAR_AND_LINE} labels={LABELS} theme={THEME}>
<div data-attr="custom-overlay" />
</TimeSeriesComboChart>
@@ -288,9 +284,7 @@ describe('TimeSeriesComboChart', () => {
describe('hover & tooltip', () => {
it('lists every visible series at the hovered x', async () => {
- const { chart } = renderHogChart(
- <TimeSeriesComboChart series={BAR_AND_LINE} labels={LABELS} theme={THEME} />
- )
+ const { chart } = renderChart(<TimeSeriesComboChart series={BAR_AND_LINE} labels={LABELS} theme={THEME} />)
chart.hoverAtIndex(1)
const tooltip = await chart.waitForTooltip()
expect(tooltip.seriesData.map((s) => s.series.key).sort()).toEqual(['bar', 'line'])
@@ -299,7 +293,7 @@ describe('TimeSeriesComboChart', () => {
// `nativeTooltip` lets the chart render its own DefaultTooltip from config (the harness's
// default tooltip-prop interception would otherwise bypass the config formatters).
it('formats the built-in tooltip rows with config.tooltip.valueFormatter', async () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesComboChart
series={BAR_AND_LINE}
labels={LABELS}
@@ -309,12 +303,12 @@ describe('TimeSeriesComboChart', () => {
{ nativeTooltip: true }
)
chart.hoverAtIndex(1)
- const tooltip = await waitForHogChartTooltip()
+ const tooltip = await waitForChartTooltip()
expect(tooltip.textContent).toContain('$60')
})
it('appends a total row when config.tooltip.showTotal is set', async () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesComboChart
series={BAR_AND_LINE}
labels={LABELS}
@@ -324,14 +318,14 @@ describe('TimeSeriesComboChart', () => {
{ nativeTooltip: true }
)
chart.hoverAtIndex(1)
- const tooltip = await waitForHogChartTooltip()
+ const tooltip = await waitForChartTooltip()
expect(tooltip.textContent).toContain('Sum')
})
})
describe('interactive legend', () => {
it('toggles a series off and on when its legend row is clicked', () => {
- const { container, chart } = renderHogChart(
+ const { container, chart } = renderChart(
<TimeSeriesComboChart
series={BAR_AND_LINE}
labels={LABELS}
@@ -344,10 +338,10 @@ describe('TimeSeriesComboChart', () => {
Array.from(container.querySelectorAll('[data-attr="hog-chart-timeseries-combo-legend"] button'))
fireEvent.click(buttons()[1])
- expect(getHogChart(container).seriesCount).toBe(1)
+ expect(getChart(container).seriesCount).toBe(1)
fireEvent.click(buttons()[1])
- expect(getHogChart(container).seriesCount).toBe(2)
+ expect(getChart(container).seriesCount).toBe(2)
})
})
})
diff --git a/packages/quill/packages/charts/src/charts/TimeSeriesLineChart/TimeSeriesLineChart.test.tsx b/packages/quill/packages/charts/src/charts/TimeSeriesLineChart/TimeSeriesLineChart.test.tsx
index 328014c43831..6579e4540872 100644
--- a/packages/quill/packages/charts/src/charts/TimeSeriesLineChart/TimeSeriesLineChart.test.tsx
+++ b/packages/quill/packages/charts/src/charts/TimeSeriesLineChart/TimeSeriesLineChart.test.tsx
@@ -4,11 +4,11 @@ import { useChartLayout } from '../../core/chart-context'
import type { ChartTheme, Series } from '../../core/types'
import {
createDefaultTooltipAccessor,
- getHogChart,
- renderHogChart,
+ getChart,
+ renderChart,
setupJsdom,
setupSyncRaf,
- waitForHogChartTooltip,
+ waitForChartTooltip,
} from '../../testing'
import { TimeSeriesLineChart } from './TimeSeriesLineChart'
@@ -45,7 +45,7 @@ describe('TimeSeriesLineChart', () => {
bottomMargin = dimensions.height - dimensions.plotTop - dimensions.plotHeight
return null
}
- renderHogChart(
+ renderChart(
<TimeSeriesLineChart series={SERIES} labels={LABELS} theme={THEME} config={{ margins: { bottom: 76 } }}>
<Measure />
</TimeSeriesLineChart>
@@ -55,7 +55,7 @@ describe('TimeSeriesLineChart', () => {
describe('config.xAxis', () => {
it('hides x-axis ticks when xAxis.hide is true', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesLineChart series={SERIES} labels={LABELS} theme={THEME} config={{ xAxis: { hide: true } }} />
)
expect(chart.xTicks()).toHaveLength(0)
@@ -63,7 +63,7 @@ describe('TimeSeriesLineChart', () => {
it('forwards an explicit xAxis.tickFormatter to the chart', () => {
const explicit = (_v: string, i: number): string => `tick-${i}`
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesLineChart
series={[{ key: 'a', label: 'A', data: [1, 2, 3] }]}
labels={['14:00', '15:00', '16:00']}
@@ -76,7 +76,7 @@ describe('TimeSeriesLineChart', () => {
it('builds an auto date formatter from xAxis.timezone + xAxis.interval', () => {
const labels = ['2024-06-10', '2024-06-11', '2024-06-12']
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesLineChart
series={[{ key: 'a', label: 'A', data: [1, 2, 3] }]}
labels={labels}
@@ -92,7 +92,7 @@ describe('TimeSeriesLineChart', () => {
it('infers the date formatter and tooltip header from timezone and chart labels', async () => {
const labels = ['2024-06-10', '2024-06-11', '2024-06-12']
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesLineChart
series={[{ key: 'a', label: 'A', data: [1, 2, 3] }]}
labels={labels}
@@ -104,12 +104,12 @@ describe('TimeSeriesLineChart', () => {
expect(chart.xTicks().some((tick) => /Jun \d+/.test(tick))).toBe(true)
chart.hoverAtIndex(0)
- expect(createDefaultTooltipAccessor(await waitForHogChartTooltip()).label()).toBe('Mon, Jun 10, 2024')
+ expect(createDefaultTooltipAccessor(await waitForChartTooltip()).label()).toBe('Mon, Jun 10, 2024')
})
it('explicit xAxis.tickFormatter wins over the auto date formatter', () => {
const explicit = (_v: string, i: number): string => `tick-${i}`
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesLineChart
series={[{ key: 'a', label: 'A', data: [1, 2, 3] }]}
labels={['2024-06-10', '2024-06-11', '2024-06-12']}
@@ -132,7 +132,7 @@ describe('TimeSeriesLineChart', () => {
observed = useChartLayout().axis.xTickFormatter
return null
}
- renderHogChart(
+ renderChart(
<TimeSeriesLineChart
series={[{ key: 'a', label: 'A', data: [1, 2, 3] }]}
labels={['2024-06-10', '2024-06-11', '2024-06-12']}
@@ -149,7 +149,7 @@ describe('TimeSeriesLineChart', () => {
describe('config.yAxis', () => {
it('hides y-axis ticks when yAxis.hide is true', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesLineChart series={SERIES} labels={LABELS} theme={THEME} config={{ yAxis: { hide: true } }} />
)
expect(chart.yTicks()).toHaveLength(0)
@@ -159,7 +159,7 @@ describe('TimeSeriesLineChart', () => {
[{ format: 'percentage' as const }, /\d+%$/],
[{ prefix: '$', suffix: ' req' }, /^\$.* req$/],
])('builds a y-axis tick formatter from yAxis %p', (yAxis, pattern) => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesLineChart series={SERIES} labels={LABELS} theme={THEME} config={{ yAxis }} />
)
expect(chart.yTicks().some((t) => pattern.test(t))).toBe(true)
@@ -167,7 +167,7 @@ describe('TimeSeriesLineChart', () => {
it('explicit yAxis.tickFormatter wins over yAxis.format', () => {
const explicit = (v: number): string => `y:${v}`
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesLineChart
series={SERIES}
labels={LABELS}
@@ -188,21 +188,21 @@ describe('TimeSeriesLineChart', () => {
// An offset, all-positive series: clamping to 0 leaves a big empty gutter below the data,
// while floating zooms the axis onto the 50–70 band — so the lowest tick distinguishes them.
const OFFSET_SERIES: Series[] = [{ key: 'a', label: 'A', data: [50, 60, 70] }]
- const lowestTick = (chart: ReturnType<typeof renderHogChart>['chart']): number =>
+ const lowestTick = (chart: ReturnType<typeof renderChart>['chart']): number =>
Math.min(...chart.yTicks().map((t) => parseFloat(t.replace(/[^0-9.eE+-]/g, ''))))
it.each([
['by default', undefined],
['when startAtZero is true', { yAxis: { startAtZero: true } }],
])('clamps the baseline to 0 %s', (_name, config) => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesLineChart series={OFFSET_SERIES} labels={LABELS} theme={THEME} config={config} />
)
expect(lowestTick(chart)).toBe(0)
})
it('floats the axis to the data range when startAtZero is false', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesLineChart
series={OFFSET_SERIES}
labels={LABELS}
@@ -214,7 +214,7 @@ describe('TimeSeriesLineChart', () => {
})
it('ignores startAtZero=false on a log scale, where there is no zero baseline to drop', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesLineChart
series={OFFSET_SERIES}
labels={LABELS}
@@ -232,7 +232,7 @@ describe('TimeSeriesLineChart', () => {
['floors the axis at yAxis.min', { min: 40 }, 40, Math.min],
['caps the axis at yAxis.max', { max: 80 }, 80, Math.max],
])('%s', (_name, bounds, expected, pick) => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesLineChart series={OFFSET_SERIES} labels={LABELS} theme={THEME} config={{ yAxis: bounds }} />
)
const ticks = chart.yTicks().map((t) => parseFloat(t.replace(/[^0-9.eE+-]/g, '')))
@@ -243,7 +243,7 @@ describe('TimeSeriesLineChart', () => {
// DOM-positioned, so without a guard a clipped point still prints its number over the
// title and legend. A point exactly on the bound keeps its label.
it('hides a value label for a point above the bounded window', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesLineChart
series={OFFSET_SERIES}
labels={LABELS}
@@ -256,7 +256,7 @@ describe('TimeSeriesLineChart', () => {
// A goal line pushed outside a bounded window must drop out, not paint over the axis gutter.
it('hides a goal line that falls outside the bounded window', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesLineChart
series={OFFSET_SERIES}
labels={LABELS}
@@ -278,7 +278,7 @@ describe('TimeSeriesLineChart', () => {
const num = (t: string): number => parseFloat(t.replace(/[^0-9.eE+-]/g, ''))
it('renders both a left and a right y-axis when a series targets each', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesLineChart series={LEFT_RIGHT_SERIES} labels={LABELS} theme={THEME} config={DUAL_CONFIG} />
)
expect(chart.hasRightAxis).toBe(true)
@@ -288,7 +288,7 @@ describe('TimeSeriesLineChart', () => {
it('hides only the right axis when its entry sets hide, keeping the left axis', () => {
const yAxis = [{ id: 'left' }, { id: 'right', position: 'right' as const, hide: true }]
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesLineChart series={LEFT_RIGHT_SERIES} labels={LABELS} theme={THEME} config={{ yAxis }} />
)
expect(chart.yTicks().length).toBeGreaterThan(0)
@@ -300,14 +300,14 @@ describe('TimeSeriesLineChart', () => {
{ id: 'left', hide: true },
{ id: 'right', position: 'right' as const, hide: true },
]
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesLineChart series={LEFT_RIGHT_SERIES} labels={LABELS} theme={THEME} config={{ yAxis }} />
)
expect(chart.yTicks()).toHaveLength(0)
})
it('formats each axis with its own tick formatter', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesLineChart
series={LEFT_RIGHT_SERIES}
labels={LABELS}
@@ -325,7 +325,7 @@ describe('TimeSeriesLineChart', () => {
})
it('builds an independent scale per axis — left covers the large series, right the small one', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesLineChart
series={LEFT_RIGHT_SERIES}
labels={LABELS}
@@ -348,7 +348,7 @@ describe('TimeSeriesLineChart', () => {
{ key: 'signups', label: 'Signups', data: [50, 80, 65], yAxisId: 'right' },
{ key: 'conv', label: 'Conversion', data: [0.01, 0.02, 0.015], yAxisId: 'right2' },
]
- const { container, chart } = renderHogChart(
+ const { container, chart } = renderChart(
<TimeSeriesLineChart
series={threeAxisSeries}
labels={LABELS}
@@ -370,7 +370,7 @@ describe('TimeSeriesLineChart', () => {
})
it('reserves right margin so right-axis tick labels are not clipped', () => {
- const { container } = renderHogChart(
+ const { container } = renderChart(
<TimeSeriesLineChart
series={LEFT_RIGHT_SERIES}
labels={LABELS}
@@ -397,7 +397,7 @@ describe('TimeSeriesLineChart', () => {
})
it('treats a single-object yAxis as one axis (no right gutter) — back-compat', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesLineChart
series={SERIES}
labels={LABELS}
@@ -410,7 +410,7 @@ describe('TimeSeriesLineChart', () => {
})
it('does not render a right axis when an array config has no right-axis series', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesLineChart series={SERIES} labels={LABELS} theme={THEME} config={DUAL_CONFIG} />
)
expect(chart.hasRightAxis).toBe(false)
@@ -422,7 +422,7 @@ describe('TimeSeriesLineChart', () => {
['omitted', undefined],
['false', false as const],
])('does not render value labels when %s', (_, valueLabels) => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesLineChart
series={SERIES}
labels={LABELS}
@@ -434,7 +434,7 @@ describe('TimeSeriesLineChart', () => {
})
it('renders one value label per visible point when valueLabels=true', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesLineChart series={SERIES} labels={LABELS} theme={THEME} config={{ valueLabels: true }} />
)
expect(chart.valueLabels()).toHaveLength(SERIES[0].data.length)
@@ -442,7 +442,7 @@ describe('TimeSeriesLineChart', () => {
it('forwards an explicit formatter', () => {
const formatter = (v: number): string => `~${v}`
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesLineChart
series={SERIES}
labels={LABELS}
@@ -454,7 +454,7 @@ describe('TimeSeriesLineChart', () => {
})
it('falls back to a yAxis-driven formatter when no explicit formatter is provided', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesLineChart
series={[{ key: 'a', label: 'A', data: [50] }]}
labels={['Mon']}
@@ -470,7 +470,7 @@ describe('TimeSeriesLineChart', () => {
it('reuses an explicit yAxis.tickFormatter as the default', () => {
const explicit = (v: number): string => `y:${v}`
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesLineChart
series={SERIES}
labels={LABELS}
@@ -489,7 +489,7 @@ describe('TimeSeriesLineChart', () => {
{ key: 'a', label: 'A', data: [1, 2, 3] },
{ key: 'b', label: 'B', data: [4, 5, 6] },
]
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesLineChart
series={series}
labels={LABELS}
@@ -506,7 +506,7 @@ describe('TimeSeriesLineChart', () => {
['omitted', undefined],
['empty', [] as never[]],
])('does not render reference lines when goalLines is %s', (_, goalLines) => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesLineChart
series={SERIES}
labels={LABELS}
@@ -518,7 +518,7 @@ describe('TimeSeriesLineChart', () => {
})
it('renders horizontal goal lines with their label', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesLineChart
series={[{ key: 'a', label: 'A', data: [10, 20, 100] }]}
labels={LABELS}
@@ -533,7 +533,7 @@ describe('TimeSeriesLineChart', () => {
})
it('includes shared domain values beyond the line data', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesLineChart
series={[{ key: 'a', label: 'A', data: [10, 20, 30] }]}
labels={LABELS}
@@ -545,7 +545,7 @@ describe('TimeSeriesLineChart', () => {
})
it('extends the value axis so a goal line above the data still renders', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesLineChart
series={[{ key: 'a', label: 'A', data: [10, 20, 30] }]}
labels={LABELS}
@@ -568,7 +568,7 @@ describe('TimeSeriesLineChart', () => {
['movingAverage', { movingAverage: [{ seriesKey: 'a', window: 2 }] }],
['trendLines', { trendLines: [{ seriesKey: 'a', kind: 'linear' as const }] }],
])('plumbs config.%s through to the rendered series count', (_, derivedConfig) => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesLineChart series={SERIES} labels={LABELS} theme={THEME} config={derivedConfig} />
)
// SERIES has 1 entry; each derived block adds one more series.
@@ -585,7 +585,7 @@ describe('TimeSeriesLineChart', () => {
color: '#112233',
},
]
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<TimeSeriesLineChart
series={series}
labels={LABELS}
@@ -598,7 +598,7 @@ describe('TimeSeriesLineChart', () => {
})
it('forwards children alongside built-in overlays', () => {
- const { container } = renderHogChart(
+ const { container } = renderChart(
<TimeSeriesLineChart series={SERIES} labels={LABELS} theme={THEME}>
<div data-attr="custom-overlay" />
</TimeSeriesLineChart>
@@ -608,7 +608,7 @@ describe('TimeSeriesLineChart', () => {
describe('interactive legend', () => {
it('lists the raw series (not derived trend lines) and isolates one on click', () => {
- const { container, chart } = renderHogChart(
+ const { container, chart } = renderChart(
<TimeSeriesLineChart
series={MULTI_SERIES}
labels={LABELS}
@@ -628,12 +628,12 @@ describe('TimeSeriesLineChart', () => {
expect(chart.seriesCount).toBe(3)
// Isolating A keeps its derived trend line, and drops B.
fireEvent.click(buttons()[0])
- expect(getHogChart(container).seriesCount).toBe(2)
+ expect(getChart(container).seriesCount).toBe(2)
// Meta-clicking A instead hides it, and its trend line with it, leaving only B.
fireEvent.click(buttons()[0])
fireEvent.click(buttons()[0], { metaKey: true })
- expect(getHogChart(container).seriesCount).toBe(1)
+ expect(getChart(container).seriesCount).toBe(1)
})
})
})
diff --git a/packages/quill/packages/charts/src/components/MetricCard/MetricCard.test.tsx b/packages/quill/packages/charts/src/components/MetricCard/MetricCard.test.tsx
index 162e12000ae8..08e0e11f8c75 100644
--- a/packages/quill/packages/charts/src/components/MetricCard/MetricCard.test.tsx
+++ b/packages/quill/packages/charts/src/components/MetricCard/MetricCard.test.tsx
@@ -1,7 +1,7 @@
import { act, render } from '@testing-library/react'
import type { ChartTheme } from '../../core/types'
-import { renderHogChart, setupJsdom, setupSyncRaf } from '../../testing'
+import { renderChart, setupJsdom, setupSyncRaf } from '../../testing'
import { MetricCard, type MetricChange } from './MetricCard'
const THEME: ChartTheme = { colors: ['#22d3ee'], backgroundColor: '#ffffff' }
@@ -25,7 +25,7 @@ describe('MetricCard', () => {
describe('with sparkline (data + theme)', () => {
it('shows the last data point and label by default', () => {
- const { container } = renderHogChart(
+ const { container } = renderChart(
<MetricCard
title="Total"
data={[100, 200, 300, 400]}
@@ -39,7 +39,7 @@ describe('MetricCard', () => {
})
it('renders a positive change pill when the series ends above the first non-zero value', () => {
- const { container } = renderHogChart(
+ const { container } = renderChart(
<MetricCard
title="Total"
data={[100, 200, 300, 400]}
@@ -52,7 +52,7 @@ describe('MetricCard', () => {
})
it('renders a negative change pill when the series ends below the first value', () => {
- const { container } = renderHogChart(
+ const { container } = renderChart(
<MetricCard
title="Total"
data={[400, 300, 200, 100]}
@@ -65,14 +65,14 @@ describe('MetricCard', () => {
})
it('skips the change pill when showChange is false', () => {
- const { container } = renderHogChart(
+ const { container } = renderChart(
<MetricCard title="Total" data={[100, 200]} labels={['Jan', 'Feb']} theme={THEME} showChange={false} />
)
expect(container.textContent).not.toContain('%')
})
it('omits the change pill when the first non-zero value is undefined', () => {
- const { container } = renderHogChart(
+ const { container } = renderChart(
<MetricCard title="Total" data={[0, 0, 0]} labels={['Jan', 'Feb', 'Mar']} theme={THEME} />
)
expect(container.textContent).not.toContain('%')
@@ -84,7 +84,7 @@ describe('MetricCard', () => {
})
it('uses Math.abs in the denominator so a negative baseline still reads as a rise', () => {
- const { container } = renderHogChart(
+ const { container } = renderChart(
<MetricCard
title="Total"
data={[-100, 0, 100]}
@@ -99,7 +99,7 @@ describe('MetricCard', () => {
it('ignores a quick pass-through and only follows the cursor once it settles past the dwell', () => {
jest.useFakeTimers()
try {
- const { container, chart } = renderHogChart(
+ const { container, chart } = renderChart(
<MetricCard
title="Total"
data={[100, 200, 300, 400]}
@@ -131,7 +131,7 @@ describe('MetricCard', () => {
['the raw label', undefined, 'Feb'],
['the label from formatLabel', (label) => `${label} 2026`, 'Feb 2026'],
])('updates the headline value and shows %s when hovering a different point', (_name, formatLabel, label) => {
- const { container, chart } = renderHogChart(
+ const { container, chart } = renderChart(
<MetricCard
title="Total"
data={[100, 200, 300, 400]}
@@ -149,7 +149,7 @@ describe('MetricCard', () => {
})
it('headlines the supplied `value` at rest while the chart still draws from `data`', () => {
- const { container, chart } = renderHogChart(
+ const { container, chart } = renderChart(
<MetricCard
title="Revenue"
data={[100, 200, 300, 400]}
@@ -168,7 +168,7 @@ describe('MetricCard', () => {
})
it('renders a supplied `change` pill fixed across hover', () => {
- const { container, chart } = renderHogChart(
+ const { container, chart } = renderChart(
<MetricCard
title="Revenue"
data={[100, 200, 300, 400]}
@@ -187,7 +187,7 @@ describe('MetricCard', () => {
})
it('formats a supplied `change` via `formatChange` when no label is provided', () => {
- const { container } = renderHogChart(
+ const { container } = renderChart(
<MetricCard
title="Revenue"
data={[100, 200, 300, 400]}
@@ -201,7 +201,7 @@ describe('MetricCard', () => {
})
it('suppresses the pill when change is null', () => {
- const { container } = renderHogChart(
+ const { container } = renderChart(
<MetricCard
title="Revenue"
data={[100, 200, 300, 400]}
@@ -215,7 +215,7 @@ describe('MetricCard', () => {
})
it('uses the supplied subtitle in place of the hover-driven label', () => {
- const { container } = renderHogChart(
+ const { container } = renderChart(
<MetricCard
title="Revenue"
data={[100, 200, 300, 400]}
@@ -230,7 +230,7 @@ describe('MetricCard', () => {
})
it('shows restingSubtitle at rest and yields to the hovered point label on hover', () => {
- const { container, chart } = renderHogChart(
+ const { container, chart } = renderChart(
<MetricCard
title="Revenue"
data={[100, 200, 300, 400]}
@@ -249,7 +249,7 @@ describe('MetricCard', () => {
})
it('lets a supplied subtitle win over restingSubtitle at rest and on hover', () => {
- const { container, chart } = renderHogChart(
+ const { container, chart } = renderChart(
<MetricCard
title="Revenue"
data={[100, 200, 300, 400]}
@@ -268,7 +268,7 @@ describe('MetricCard', () => {
})
it('with hoverChangeFromPreviousPoint, keeps the resting change but shows point-vs-previous on hover', () => {
- const { container, chart } = renderHogChart(
+ const { container, chart } = renderChart(
<MetricCard
title="Revenue"
data={[100, 200, 300, 400]}
@@ -287,7 +287,7 @@ describe('MetricCard', () => {
})
it('with hoverChangeFromPreviousPoint, keeps the pill suppressed across hover when change is null', () => {
- const { container, chart } = renderHogChart(
+ const { container, chart } = renderChart(
<MetricCard
title="Revenue"
data={[100, 200, 300, 400]}
@@ -305,7 +305,7 @@ describe('MetricCard', () => {
})
it('with hoverChangeFromPreviousPoint, hides the pill when hovering the first point', () => {
- const { container, chart } = renderHogChart(
+ const { container, chart } = renderChart(
<MetricCard
title="Revenue"
data={[100, 200, 300, 400]}
@@ -386,7 +386,7 @@ describe('MetricCard', () => {
describe('inline change pill, fill, and subtitle', () => {
it('renders the change pill exactly once with changeInline (no header duplicate)', () => {
- const { container } = renderHogChart(
+ const { container } = renderChart(
<MetricCard
title="Total"
data={[100, 200, 300, 400]}
@@ -402,7 +402,7 @@ describe('MetricCard', () => {
})
it('drops the fixed sparkline height when sparklineFill is set', () => {
- const fixed = renderHogChart(
+ const fixed = renderChart(
<MetricCard
title="Total"
data={[100, 200]}
@@ -415,7 +415,7 @@ describe('MetricCard', () => {
(fixed.container.querySelector('[data-attr="metric-card-sparkline"]') as HTMLElement).style.height
).toBe('120px')
- const filled = renderHogChart(
+ const filled = renderChart(
<MetricCard title="Total" data={[100, 200]} labels={['Jan', 'Feb']} theme={THEME} sparklineFill />
)
expect(
@@ -424,7 +424,7 @@ describe('MetricCard', () => {
})
it('renders the subtitle when provided and omits the row when empty', () => {
- const withSubtitle = renderHogChart(
+ const withSubtitle = renderChart(
<MetricCard
title="Total"
data={[100, 200]}
diff --git a/packages/quill/packages/charts/src/core/hooks/useChartCanvas.test.tsx b/packages/quill/packages/charts/src/core/hooks/useChartCanvas.test.tsx
index bdc8540837e5..2b46753a9bd2 100644
--- a/packages/quill/packages/charts/src/core/hooks/useChartCanvas.test.tsx
+++ b/packages/quill/packages/charts/src/core/hooks/useChartCanvas.test.tsx
@@ -1,6 +1,6 @@
import { act } from '@testing-library/react'
-import { mockRect, renderHogChart } from '../../testing'
+import { mockRect, renderChart } from '../../testing'
import { Chart } from '../Chart'
import type { ChartDrawArgs, ChartScales, ChartTheme, Series } from '../types'
@@ -16,8 +16,8 @@ const createScales = (): ChartScales => ({
yTicks: () => [0, 50, 100],
})
-function renderChart(drawStatic: (args: ChartDrawArgs) => void): HTMLCanvasElement {
- const { chart } = renderHogChart(
+function renderCanvas(drawStatic: (args: ChartDrawArgs) => void): HTMLCanvasElement {
+ const { chart } = renderChart(
<Chart
series={SERIES}
labels={LABELS}
@@ -53,7 +53,7 @@ describe('useChartCanvas', () => {
it('keeps the last frame until the repaint resizes the backing store', () => {
const drawStatic = jest.fn()
- const canvas = renderChart(drawStatic)
+ const canvas = renderCanvas(drawStatic)
const frames: FrameRequestCallback[] = []
const rafSpy = jest.spyOn(globalThis, 'requestAnimationFrame').mockImplementation((cb) => frames.push(cb))
drawStatic.mockClear()
@@ -74,7 +74,7 @@ describe('useChartCanvas', () => {
it('keeps the painted canvas when the wrapper collapses to zero size and comes back', () => {
const drawStatic = jest.fn()
- const canvas = renderChart(drawStatic)
+ const canvas = renderCanvas(drawStatic)
drawStatic.mockClear()
reportWrapperSize(0, 0)
@@ -86,7 +86,7 @@ describe('useChartCanvas', () => {
it('repaints a context restored while the wrapper had zero size once the size comes back', () => {
const drawStatic = jest.fn()
- const canvas = renderChart(drawStatic)
+ const canvas = renderCanvas(drawStatic)
drawStatic.mockClear()
jest.mocked(Element.prototype.getBoundingClientRect).mockReturnValueOnce({ ...mockRect, width: 0, height: 0 })
@@ -101,7 +101,7 @@ describe('useChartCanvas', () => {
it('repaints against a restored backing store after the 2D context is lost', () => {
const drawStatic = jest.fn()
- const canvas = renderChart(drawStatic)
+ const canvas = renderCanvas(drawStatic)
expect(drawStatic).toHaveBeenCalled()
drawStatic.mockClear()
diff --git a/packages/quill/packages/charts/src/docs/CONTRIBUTING.md b/packages/quill/packages/charts/src/docs/CONTRIBUTING.md
index 49ae7250c5ba..74c193bdecb7 100644
--- a/packages/quill/packages/charts/src/docs/CONTRIBUTING.md
+++ b/packages/quill/packages/charts/src/docs/CONTRIBUTING.md
@@ -24,7 +24,7 @@ Where new code goes:
- **`ChartScales` must not expose d3 types.** Public interface is `x(label) => px`, `y(value) => px`, `yTicks() => number[]`. d3 stays inside the chart-type's `createScales`.
- **Canvas functions are stateless.** Pure functions in `canvas-renderer.ts`, no React or side effects. State lives in React; drawing reads it.
- **Overlays use the granular hooks.** `useChartLayout()` doesn't re-render on hover; `useChartHover()` does. Use `useChart()` only when an overlay genuinely needs both — it re-renders on every mousemove.
-- **Pure logic is tested at the `core/` layer.** Chart-level tests assert on the rendered DOM through the `HogChart` accessor — see [TESTING.md](./TESTING.md).
+- **Pure logic is tested at the `core/` layer.** Chart-level tests assert on the rendered DOM through the `ChartAccessor` — see [TESTING.md](./TESTING.md).
## Adding a new chart type
diff --git a/packages/quill/packages/charts/src/docs/TESTING.md b/packages/quill/packages/charts/src/docs/TESTING.md
index 0971b3ada92d..b0e7a6768fc2 100644
--- a/packages/quill/packages/charts/src/docs/TESTING.md
+++ b/packages/quill/packages/charts/src/docs/TESTING.md
@@ -5,27 +5,27 @@ Two audiences:
- **Embedding hog-charts** in your own component or page and writing tests for that surrounding code → [Testing code that uses hog-charts](#testing-code-that-uses-hog-charts).
- **Working on the library itself** — chart types, overlays, the draw loop → [Testing the library itself](#testing-the-library-itself).
-The contract both sections rely on: the `data-attr` selectors and the `HogChart` accessor are stable. Renaming a `data-attr` is a breaking change — it breaks consumers' tests as much as renaming an exported type. JSdom's canvas is a stub, so canvas pixels aren't a viable test surface anyway — assertions go through the DOM.
+The contract both sections rely on: the `data-attr` selectors and the `ChartAccessor` are stable. Renaming a `data-attr` is a breaking change — it breaks consumers' tests as much as renaming an exported type. JSdom's canvas is a stub, so canvas pixels aren't a viable test surface anyway — assertions go through the DOM.
## Testing code that uses hog-charts
-You've rendered a tree that contains a chart somewhere — a dashboard, an insight scene, a custom panel. Use your own `render` (or RTL wrappers like kea-test-utils) and read the chart with `getHogChart(scope)`:
+You've rendered a tree that contains a chart somewhere — a dashboard, an insight scene, a custom panel. Use your own `render` (or RTL wrappers like kea-test-utils) and read the chart with `getChart(scope)`:
```tsx
import { render } from '@testing-library/react'
-import { ensureJsdom, getHogChart, hoverAtIndex, waitForHogChartTooltip } from '@posthog/quill-charts/testing'
+import { ensureJsdom, getChart, hoverAtIndex, waitForChartTooltip } from '@posthog/quill-charts/testing'
ensureJsdom()
it('renders the goal line on the dashboard chart', async () => {
const { container } = render(<Dashboard />)
- const chart = getHogChart(container)
+ const chart = getChart(container)
expect(chart.referenceLines()).toHaveLength(1)
expect(chart.yTicks()).toContain('0')
hoverAtIndex(chart.element, 1, LABELS.length)
- const tooltip = await waitForHogChartTooltip()
+ const tooltip = await waitForChartTooltip()
expect(tooltip.textContent).toContain('Tue')
})
```
@@ -61,17 +61,17 @@ For interactions, use the module-level helpers:
- `hoverAtIndex(wrapper, i, totalLabels)` — `mouseMove` over labels[i].
- `clickAtIndex(wrapper, i, totalLabels)` — hover-then-click. Resolves after the click handler runs.
- `dragSelection(wrapper, fromIndex, toIndex, totalLabels)` — simulates a drag-to-zoom gesture between two label indices.
-- `waitForHogChartTooltip()` — resolves with the rendered tooltip element once it mounts in the `FloatingPortal`.
+- `waitForChartTooltip()` — resolves with the rendered tooltip element once it mounts in the `FloatingPortal`.
-`chart.hoverAtIndex(i)`, `chart.dragSelection(i, j)`, and `chart.waitForTooltip()` (returning a structured `TooltipSnapshot` with `seriesData`, `isPinned`, etc.) need `renderHogChart` — they read label count and the captured `TooltipContext` that only the library's own render wrapper sets up. For most consumer tests, DOM assertions through the accessor are enough.
+`chart.hoverAtIndex(i)`, `chart.dragSelection(i, j)`, and `chart.waitForTooltip()` (returning a structured `TooltipSnapshot` with `seriesData`, `isPinned`, etc.) need `renderChart` — they read label count and the captured `TooltipContext` that only the library's own render wrapper sets up. For most consumer tests, DOM assertions through the accessor are enough.
## Testing the library itself
-Chart-level tests live under `charts/<name>/<Name>.test.tsx` and overlay tests under `overlays/<Name>.test.tsx`. They render the chart at the top level via `renderHogChart` and assert through the `chart` accessor.
+Chart-level tests live under `charts/<name>/<Name>.test.tsx` and overlay tests under `overlays/<Name>.test.tsx`. They render the chart at the top level via `renderChart` and assert through the `chart` accessor.
```tsx
import type { ChartTheme, Series } from '../core/types'
-import { renderHogChart } from '../testing'
+import { renderChart } from '../testing'
import { LineChart } from './LineChart'
const THEME: ChartTheme = { colors: ['#111', '#222'], backgroundColor: '#ffffff' }
@@ -80,7 +80,7 @@ const SERIES: Series[] = [{ key: 'a', label: 'A', data: [1, 2, 3] }]
describe('LineChart', () => {
it('formats percent-stack y-ticks by default', () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<LineChart series={SERIES} labels={LABELS} theme={THEME} config={{ percentStackView: true }} />
)
expect(chart.yTicks().some((t) => t.endsWith('%'))).toBe(true)
@@ -88,7 +88,7 @@ describe('LineChart', () => {
})
```
-`renderHogChart` is `render` plus three things consumers don't need: auto-`ensureJsdom`, tooltip-context capture (so `chart.waitForTooltip()` returns the structured `TooltipContext`), and a cached `labels.length` (so `chart.hoverAtIndex(i)` doesn't take a `totalLabels` argument).
+`renderChart` is `render` plus three things consumers don't need: auto-`ensureJsdom`, tooltip-context capture (so `chart.waitForTooltip()` returns the structured `TooltipContext`), and a cached `labels.length` (so `chart.hoverAtIndex(i)` doesn't take a `totalLabels` argument).
### Interactions and tooltip context
@@ -112,7 +112,7 @@ Prefer the structured fields. Reach for `tooltip.element.textContent` only when
```tsx
it('pins the tooltip on click when pinnable', async () => {
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<LineChart series={SERIES} labels={LABELS} theme={THEME} config={{ tooltip: { pinnable: true } }} />
)
@@ -127,9 +127,7 @@ it('pins the tooltip on click when pinnable', async () => {
```tsx
it('invokes onPointClick with the clicked column', async () => {
const onPointClick = jest.fn()
- const { chart } = renderHogChart(
- <LineChart series={SERIES} labels={LABELS} theme={THEME} onPointClick={onPointClick} />
- )
+ const { chart } = renderChart(<LineChart series={SERIES} labels={LABELS} theme={THEME} onPointClick={onPointClick} />)
await chart.clickAtIndex(1)
expect(onPointClick).toHaveBeenCalledWith(expect.objectContaining({ dataIndex: 1, label: 'Tue', value: 2 }))
@@ -144,7 +142,7 @@ it('renders a right axis when a series opts in', () => {
{ key: 'a', label: 'A', data: [10, 20, 30] },
{ key: 'b', label: 'B', data: [1000, 2000, 3000], yAxisId: 'right' },
]
- const { chart } = renderHogChart(<LineChart series={series} labels={LABELS} theme={THEME} />)
+ const { chart } = renderChart(<LineChart series={series} labels={LABELS} theme={THEME} />)
expect(chart.hasRightAxis).toBe(true)
expect(chart.yRightTicks().length).toBeGreaterThan(0)
@@ -161,7 +159,7 @@ it('reports render errors through onError', () => {
const tooltip = (): React.ReactNode => {
throw new Error('boom')
}
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<LineChart series={SERIES} labels={LABELS} theme={THEME} tooltip={tooltip} onError={onError} />
)
@@ -178,7 +176,7 @@ it('reports render errors through onError', () => {
**Don't inspect canvas pixels.** No `getContext('2d')` spies, no pixel snapshots — JSdom's canvas is a stub anyway.
-**Don't fall back to `container.querySelector('canvas')` for canvas presence.** `renderHogChart` already throws when the canvas is missing. To act on a rendered canvas — asserting its backing store, dispatching a canvas-level event like `contextrestored` — use `chart.canvas` rather than re-querying the DOM. Absence assertions (`expect(container.querySelector('canvas')).toBeNull()`) still need a raw query, since the accessor throws when there's no canvas.
+**Don't fall back to `container.querySelector('canvas')` for canvas presence.** `renderChart` already throws when the canvas is missing. To act on a rendered canvas — asserting its backing store, dispatching a canvas-level event like `contextrestored` — use `chart.canvas` rather than re-querying the DOM. Absence assertions (`expect(container.querySelector('canvas')).toBeNull()`) still need a raw query, since the accessor throws when there's no canvas.
**Don't write `it.each` matrices that only assert "a canvas rendered".** Each row should read at least one observable property of that permutation — `chart.yTicks().some(t => t.endsWith('%'))` for percent layout, `chart.hasRightAxis` for a multi-axis case.
diff --git a/packages/quill/packages/charts/src/docs/tooltips.md b/packages/quill/packages/charts/src/docs/tooltips.md
index a01c0ca1dbb3..8d80d40d7d80 100644
--- a/packages/quill/packages/charts/src/docs/tooltips.md
+++ b/packages/quill/packages/charts/src/docs/tooltips.md
@@ -66,8 +66,8 @@ Mouse hover and click behavior is unchanged; the split lives in `useChartInterac
## Testing
-For a chart mounted through `renderHogChart`, `chart.waitForTooltip()` returns a structured `TooltipSnapshot`.
-For a chart rendered anywhere else (a product scene), read the tooltip from the DOM: `getHogChartTooltip()` and `waitForHogChartTooltip()` return the portal element, and `createHogChartTooltip(el)` wraps it as `{ element, isPinned }`.
+For a chart mounted through `renderChart`, `chart.waitForTooltip()` returns a structured `TooltipSnapshot`.
+For a chart rendered anywhere else (a product scene), read the tooltip from the DOM: `getChartTooltip()` and `waitForChartTooltip()` return the portal element, and `createChartTooltipAccessor(el)` wraps it as `{ element, isPinned }`.
`createDefaultTooltipAccessor(el)` reads a rendered `DefaultTooltip` through its `data-attr="hog-chart-tooltip-*"` hooks: `label()`, `rows()`, `value(seriesLabel)`, `swatchColors()`, `total()`.
Those attributes are a testing contract; keep the accessor and the component in sync.
All helpers come from `@posthog/quill-charts/testing`.
diff --git a/packages/quill/packages/charts/src/testing/accessor.ts b/packages/quill/packages/charts/src/testing/accessor.ts
index e18579d6a171..3af7d9947117 100644
--- a/packages/quill/packages/charts/src/testing/accessor.ts
+++ b/packages/quill/packages/charts/src/testing/accessor.ts
@@ -1,4 +1,4 @@
-// DOM-based inspector for hog-charts. Reads what the chart rendered so tests
+// DOM-based inspector for quill-charts. Reads what the chart rendered so tests
// can assert on overlays (value labels, reference lines, axis ticks) and the
// reported series count without poking at the canvas.
//
@@ -11,7 +11,7 @@ import { act, fireEvent } from '@testing-library/react'
import type { TooltipContext } from '../core/types'
import { dragSelection } from './interactions'
import { clientForIndex } from './jsdom'
-import { type HogChartTooltip, waitForHogChartTooltip } from './tooltip'
+import { type ChartTooltipAccessor, waitForChartTooltip } from './tooltip'
/** A single entry of `TooltipContext.seriesData`. */
type TooltipSeriesEntry<Meta = unknown> = TooltipContext<Meta>['seriesData'][number]
@@ -20,7 +20,7 @@ type TooltipSeriesEntry<Meta = unknown> = TooltipContext<Meta>['seriesData'][num
* plus the rendered portal `element`, an `isPinned` snapshot, and `series` (seriesData indexed
* by series key, for order-independent lookups like `tooltip.series.a.value`). */
export type TooltipSnapshot<Meta = unknown> = TooltipContext<Meta> &
- HogChartTooltip & {
+ ChartTooltipAccessor & {
series: Record<string, TooltipSeriesEntry<Meta>>
}
@@ -61,7 +61,7 @@ interface LegendItemSummary {
secondaryLabel: string | null
}
-export interface HogChart<Meta = unknown> {
+export interface ChartAccessor<Meta = unknown> {
/** The wrapper div of this chart. */
element: HTMLElement
/** The static (data) canvas, as opposed to the `aria-hidden` hover overlay. */
@@ -106,7 +106,7 @@ export interface HogChart<Meta = unknown> {
/** Annotation badges currently rendered. */
annotationBadges(): HTMLElement[]
/** Fire a `mouseMove` over the data point at `index`. Only available when the chart was
- * rendered via `renderHogChart` (it reads label count from `ui.props.labels`); the
+ * rendered via `renderChart` (it reads label count from `ui.props.labels`); the
* module-level `hoverAtIndex(wrapper, index, totalLabels)` is the explicit alternative. */
hoverAtIndex(index: number): void
/** Hover at the index, wait for the tooltip to settle, then click. Mirrors the
@@ -115,12 +115,12 @@ export interface HogChart<Meta = unknown> {
dragSelection(fromIndex: number, toIndex: number): void
/** Wait for the tooltip to mount, then return a snapshot — every `TooltipContext` field
* plus the rendered portal element and an `isPinned` getter. Only available when the
- * chart was rendered via `renderHogChart`; throws otherwise. */
+ * chart was rendered via `renderChart`; throws otherwise. */
waitForTooltip(timeout?: number): Promise<TooltipSnapshot<Meta>>
}
-export interface GetHogChartOptions<Meta = unknown> {
- /** Returns the most recent `TooltipContext` the chart computed (set up by `renderHogChart`'s
+export interface GetChartOptions<Meta = unknown> {
+ /** Returns the most recent `TooltipContext` the chart computed (set up by `renderChart`'s
* capturing tooltip wrapper). When omitted, `chart.waitForTooltip()` throws. */
getLastTooltipContext?: () => TooltipContext<Meta> | null
/** Total label count for `chart.hoverAtIndex` / `chart.clickAtIndex`. When omitted, those
@@ -166,19 +166,19 @@ function readReferenceLine(el: HTMLElement): ReferenceLineSummary {
return { color, orientation, position, label }
}
-export function getHogChart<Meta = unknown>(
+export function getChart<Meta = unknown>(
scope: HTMLElement = document.body,
- options: GetHogChartOptions<Meta> = {}
-): HogChart<Meta> {
+ options: GetChartOptions<Meta> = {}
+): ChartAccessor<Meta> {
const canvas = findCanvas(scope)
if (!canvas) {
- throw new Error('No hog-chart canvas found in scope')
+ throw new Error('No quill-charts canvas found in scope')
}
// The chart wrapper is the canvas's parent — overlays render as siblings
// of the canvas inside that wrapper.
const wrapper = canvas.parentElement
if (!wrapper) {
- throw new Error('hog-chart canvas has no parent wrapper')
+ throw new Error('quill-charts canvas has no parent wrapper')
}
const ariaLabel = canvas.getAttribute('aria-label') ?? ''
@@ -263,32 +263,32 @@ export function getHogChart<Meta = unknown>(
annotationBadges: () => Array.from(wrapper.querySelectorAll<HTMLElement>('.AnnotationsBadge')),
hoverAtIndex(index: number): void {
if (totalLabels === undefined) {
- throw new Error('chart.hoverAtIndex requires renderHogChart (which captures labels.length)')
+ throw new Error('chart.hoverAtIndex requires renderChart (which captures labels.length)')
}
fireEvent.mouseMove(wrapper, clientForIndex(index, totalLabels))
},
async clickAtIndex(index: number): Promise<void> {
if (totalLabels === undefined) {
- throw new Error('chart.clickAtIndex requires renderHogChart (which captures labels.length)')
+ throw new Error('chart.clickAtIndex requires renderChart (which captures labels.length)')
}
fireEvent.mouseMove(wrapper, clientForIndex(index, totalLabels))
// Wait for the hover state to flush — the click handler reads live tooltipCtx
// synchronously to choose between pinning and onPointClick.
- await waitForHogChartTooltip()
+ await waitForChartTooltip()
fireEvent.click(wrapper)
},
dragSelection(fromIndex: number, toIndex: number): void {
if (totalLabels === undefined) {
- throw new Error('chart.dragSelection requires renderHogChart (which captures labels.length)')
+ throw new Error('chart.dragSelection requires renderChart (which captures labels.length)')
}
dragSelection(wrapper, fromIndex, toIndex, totalLabels)
},
async waitForTooltip(timeout?: number): Promise<TooltipSnapshot<Meta>> {
- const element = await waitForHogChartTooltip(timeout)
+ const element = await waitForChartTooltip(timeout)
const ctx = getLastTooltipContext?.() ?? null
if (!ctx) {
throw new Error(
- 'TooltipContext not captured. Render via renderHogChart to enable tooltip context capture.'
+ 'TooltipContext not captured. Render via renderChart to enable tooltip context capture.'
)
}
return {
diff --git a/packages/quill/packages/charts/src/testing/index.ts b/packages/quill/packages/charts/src/testing/index.ts
index 8724ca7dbac3..e432511efe97 100644
--- a/packages/quill/packages/charts/src/testing/index.ts
+++ b/packages/quill/packages/charts/src/testing/index.ts
@@ -1,16 +1,15 @@
export { dimensions, ensureJsdom, makeSeries, mockRect, setupJsdom, setupSyncRaf } from './jsdom'
export { clickAtIndex, dragSelection, hoverAtIndex, hoverUntilTooltip, rawDrag } from './interactions'
-export { getHogChart } from './accessor'
-export type { GetHogChartOptions, HogChart, TooltipSnapshot } from './accessor'
-export { renderHogChart } from './render'
-export type { RenderHogChartOptions } from './render'
+export { getChart } from './accessor'
+export type { GetChartOptions, ChartAccessor, TooltipSnapshot } from './accessor'
+export { renderChart } from './render'
+export type { RenderChartOptions } from './render'
export { makeOverlayContext, renderOverlayInChart } from './overlay'
export type { OverlayContextOverrides } from './overlay'
export {
createDefaultTooltipAccessor,
- createHogChartTooltip,
- getHogChartTooltip,
- HOG_CHARTS_TOOLTIP_SELECTOR,
- waitForHogChartTooltip,
+ createChartTooltipAccessor,
+ getChartTooltip,
+ waitForChartTooltip,
} from './tooltip'
-export type { DefaultTooltipAccessor, HogChartTooltip } from './tooltip'
+export type { DefaultTooltipAccessor, ChartTooltipAccessor } from './tooltip'
diff --git a/packages/quill/packages/charts/src/testing/interactions.ts b/packages/quill/packages/charts/src/testing/interactions.ts
index 2c6e193edd39..29385823f885 100644
--- a/packages/quill/packages/charts/src/testing/interactions.ts
+++ b/packages/quill/packages/charts/src/testing/interactions.ts
@@ -1,7 +1,7 @@
import { act, fireEvent } from '@testing-library/react'
import { clientForIndex } from './jsdom'
-import { waitForHogChartTooltip } from './tooltip'
+import { waitForChartTooltip } from './tooltip'
/** Fire a mouseMove on a chart wrapper element at the pixel position
* corresponding to the given label index. */
@@ -23,7 +23,7 @@ export async function hoverUntilTooltip(
totalLabels: number,
timeout = 3000
): Promise<HTMLElement> {
- return waitForHogChartTooltip(timeout, () => hoverAtIndex(wrapper, index, totalLabels))
+ return waitForChartTooltip(timeout, () => hoverAtIndex(wrapper, index, totalLabels))
}
export async function clickAtIndex(
diff --git a/packages/quill/packages/charts/src/testing/jsdom.ts b/packages/quill/packages/charts/src/testing/jsdom.ts
index 7c90cec324b0..cac844d75279 100644
--- a/packages/quill/packages/charts/src/testing/jsdom.ts
+++ b/packages/quill/packages/charts/src/testing/jsdom.ts
@@ -29,7 +29,7 @@ export function clientForIndex(index: number, totalLabels: number): { clientX: n
}
}
-/** Mock ResizeObserver and getBoundingClientRect so hog-charts components
+/** Mock ResizeObserver and getBoundingClientRect so quill-charts components
* render with real dimensions in jsdom. Call in beforeEach, and call the
* returned cleanup function in afterEach. */
export function setupJsdom(): () => void {
@@ -83,7 +83,7 @@ export function setupSyncRaf(): () => void {
let jsdomReady = false
/** Idempotent sibling of {@link setupJsdom} + {@link setupSyncRaf}. Called automatically by
- * `renderHogChart` so simple tests don't need a beforeEach for the mocks; they're installed
+ * `renderChart` so simple tests don't need a beforeEach for the mocks; they're installed
* once for the test run and never torn down (cheap, and `getBoundingClientRect` stubbing is
* harmless to leave on for non-chart code in the same file). Tests that want fine-grained
* teardown can use the explicit `setupJsdom()` / `setupSyncRaf()` pair instead. */
diff --git a/packages/quill/packages/charts/src/testing/render.tsx b/packages/quill/packages/charts/src/testing/render.tsx
index d073ebd7c32c..f9d1a5a245d8 100644
--- a/packages/quill/packages/charts/src/testing/render.tsx
+++ b/packages/quill/packages/charts/src/testing/render.tsx
@@ -3,29 +3,29 @@ import React, { type ReactElement, type ReactNode } from 'react'
import type { TooltipContext } from '../core/types'
import { DefaultTooltip } from '../overlays/DefaultTooltip'
-import { getHogChart, type HogChart } from './accessor'
+import { getChart, type ChartAccessor } from './accessor'
import { ensureJsdom } from './jsdom'
-import { HOG_CHARTS_TOOLTIP_SELECTOR } from './tooltip'
+import { TOOLTIP_SELECTOR } from './tooltip'
-export interface RenderHogChartOptions {
+export interface RenderChartOptions {
/** Skip the tooltip-prop override so the chart renders its own tooltip. Context capture
* via `chart.waitForTooltip()` is unavailable in this mode. */
nativeTooltip?: boolean
}
-/** Render a hog-charts component and return Testing Library's `RenderResult` with a `chart`
- * accessor attached. Throws if the rendered tree doesn't contain a hog-charts canvas.
+/** Render a quill-charts component and return Testing Library's `RenderResult` with a `chart`
+ * accessor attached. Throws if the rendered tree doesn't contain a quill-charts canvas.
*
* Sets up the jsdom mocks + sync RAF on first call (idempotent), so tests don't need a
* beforeEach for those. Also calls `cleanup()` and removes any leftover tooltip portal
* before each render — RTL's auto-cleanup doesn't always reach `FloatingPortal` children. */
-export function renderHogChart<Meta = unknown>(
+export function renderChart<Meta = unknown>(
ui: ReactElement,
- options: RenderHogChartOptions = {}
-): RenderResult & { chart: HogChart<Meta> } {
+ options: RenderChartOptions = {}
+): RenderResult & { chart: ChartAccessor<Meta> } {
ensureJsdom()
cleanup()
- document.querySelectorAll(HOG_CHARTS_TOOLTIP_SELECTOR).forEach((el) => el.remove())
+ document.querySelectorAll(TOOLTIP_SELECTOR).forEach((el) => el.remove())
const props = ui.props as { tooltip?: (ctx: TooltipContext<Meta>) => ReactNode; labels?: string[] }
@@ -45,7 +45,7 @@ export function renderHogChart<Meta = unknown>(
const result = render(toRender)
return {
...result,
- chart: getHogChart<Meta>(result.container, {
+ chart: getChart<Meta>(result.container, {
getLastTooltipContext: () => lastTooltipContext,
totalLabels: props.labels?.length,
}),
diff --git a/packages/quill/packages/charts/src/testing/tooltip.ts b/packages/quill/packages/charts/src/testing/tooltip.ts
index e7288a4b4128..a5b9dd0a7c0e 100644
--- a/packages/quill/packages/charts/src/testing/tooltip.ts
+++ b/packages/quill/packages/charts/src/testing/tooltip.ts
@@ -1,11 +1,11 @@
import { waitFor } from '@testing-library/react'
-/** Stable selector for the chart tooltip portal — hog-charts renders this on
+/** Stable selector for the chart tooltip portal — quill-charts renders this on
* the document root via FloatingPortal, so it can't be found inside the chart
* wrapper. Kept in sync with overlays/Tooltip.tsx. */
-export const HOG_CHARTS_TOOLTIP_SELECTOR = '[data-hog-charts-tooltip]'
+export const TOOLTIP_SELECTOR = '[data-hog-charts-tooltip]'
-export interface HogChartTooltip {
+export interface ChartTooltipAccessor {
element: HTMLElement
/** True once the user has clicked to pin the tooltip. Reflects the
* `hog-charts-tooltip--pinned` class set by overlays/Tooltip.tsx. */
@@ -15,7 +15,7 @@ export interface HogChartTooltip {
/** Generic tooltip accessor — exposes only the portal element and pinned
* state. Consumers with their own tooltip renderer (e.g. an InsightTooltip
* with a table layout) should layer their own DOM accessor on top of this. */
-export function createHogChartTooltip(element: HTMLElement): HogChartTooltip {
+export function createChartTooltipAccessor(element: HTMLElement): ChartTooltipAccessor {
return {
element,
get isPinned(): boolean {
@@ -27,7 +27,7 @@ export function createHogChartTooltip(element: HTMLElement): HogChartTooltip {
/** Accessor for the built-in `DefaultTooltip` layout, reading its stable `data-attr`
* test hooks. Use when a chart renders `DefaultTooltip` (directly or via a custom
* `tooltip` render prop that wraps it). */
-export interface DefaultTooltipAccessor extends HogChartTooltip {
+export interface DefaultTooltipAccessor extends ChartTooltipAccessor {
/** Header label — typically the hovered x-axis value. */
label(): string
/** Series labels in render order (excludes the total row). */
@@ -50,7 +50,7 @@ export function createDefaultTooltipAccessor(element: HTMLElement): DefaultToolt
const rowEls = (): HTMLElement[] =>
Array.from(element.querySelectorAll<HTMLElement>('[data-attr="hog-chart-tooltip-row"]'))
- return Object.assign(createHogChartTooltip(element), {
+ return Object.assign(createChartTooltipAccessor(element), {
label(): string {
return element.querySelector('[data-attr="hog-chart-tooltip-label"]')?.textContent?.trim() ?? ''
},
@@ -72,14 +72,14 @@ export function createDefaultTooltipAccessor(element: HTMLElement): DefaultToolt
}
/** Currently rendered chart tooltip element, or null if none is mounted. */
-export function getHogChartTooltip(): HTMLElement | null {
- return document.querySelector(HOG_CHARTS_TOOLTIP_SELECTOR)
+export function getChartTooltip(): HTMLElement | null {
+ return document.querySelector(TOOLTIP_SELECTOR)
}
/** Wait until a chart tooltip is present in the document and return it. `beforePoll`, if given,
* runs at the start of each poll attempt — used to re-dispatch a triggering event (e.g. a hover)
* that the chart may have dropped before it became interactive. */
-export async function waitForHogChartTooltip(timeout = 3000, beforePoll?: () => void): Promise<HTMLElement> {
+export async function waitForChartTooltip(timeout = 3000, beforePoll?: () => void): Promise<HTMLElement> {
// Flush pending microtasks so React portal commits complete before polling.
await new Promise((r) => setTimeout(r, 0))
@@ -87,7 +87,7 @@ export async function waitForHogChartTooltip(timeout = 3000, beforePoll?: () =>
await waitFor(
() => {
beforePoll?.()
- const el = getHogChartTooltip()
+ const el = getChartTooltip()
if (!el) {
throw new Error('tooltip not yet rendered')
}
diff --git a/products/error_tracking/frontend/components/VolumeSparkline/VolumeSparkline.test.tsx b/products/error_tracking/frontend/components/VolumeSparkline/VolumeSparkline.test.tsx
index ff908a535880..66c07a51d0c6 100644
--- a/products/error_tracking/frontend/components/VolumeSparkline/VolumeSparkline.test.tsx
+++ b/products/error_tracking/frontend/components/VolumeSparkline/VolumeSparkline.test.tsx
@@ -1,6 +1,6 @@
import { cleanup, fireEvent, render } from '@testing-library/react'
-import { dragSelection, getHogChart, hoverAtIndex, setupJsdom, setupSyncRaf } from '@posthog/quill-charts/testing'
+import { dragSelection, getChart, hoverAtIndex, setupJsdom, setupSyncRaf } from '@posthog/quill-charts/testing'
import { initKeaTests } from '~/test/init'
@@ -40,7 +40,7 @@ function renderChart(props: Partial<React.ComponentProps<typeof VolumeSparkline>
const { container } = render(
<VolumeSparkline sparklineKey={SPARKLINE_KEY} data={buildData()} layout="detailed" xAxis="full" {...props} />
)
- return getHogChart(container).element
+ return getChart(container).element
}
describe('VolumeSparkline', () => {
@@ -113,7 +113,7 @@ describe('VolumeSparkline', () => {
onSpikeClick={onSpikeClick}
/>
)
- const wrapper = getHogChart(container).element
+ const wrapper = getChart(container).element
hoverAtIndex(wrapper, 2, data.length)
// On the outer container, past the chart's own wrapper-level handlers, so the hover
@@ -139,7 +139,7 @@ describe('VolumeSparkline', () => {
onSpikeClick={onSpikeClick}
/>
)
- const wrapper = getHogChart(container).element
+ const wrapper = getChart(container).element
hoverAtIndex(wrapper, 2, data.length)
fireEvent.mouseMove(container.firstElementChild as HTMLElement, { clientX: 123, clientY: 45 })
@@ -242,7 +242,7 @@ describe('VolumeSparkline', () => {
const { container, unmount } = render(
<VolumeSparkline sparklineKey={SPARKLINE_KEY} data={data} layout="detailed" xAxis="full" />
)
- hoverAtIndex(getHogChart(container).element, 2, data.length)
+ hoverAtIndex(getChart(container).element, 2, data.length)
expect(logic.values.hoverSelection).not.toBeNull()
unmount()
diff --git a/products/logs/frontend/components/LogsFilterPreview/LogsFilterVolumeSparkline.test.tsx b/products/logs/frontend/components/LogsFilterPreview/LogsFilterVolumeSparkline.test.tsx
index d1b379eaefb4..bb4537b8ae54 100644
--- a/products/logs/frontend/components/LogsFilterPreview/LogsFilterVolumeSparkline.test.tsx
+++ b/products/logs/frontend/components/LogsFilterPreview/LogsFilterVolumeSparkline.test.tsx
@@ -1,6 +1,6 @@
import { cleanup, render, screen, waitFor } from '@testing-library/react'
-import { getHogChart, setupJsdom, setupSyncRaf } from '@posthog/quill-charts/testing'
+import { getChart, setupJsdom, setupSyncRaf } from '@posthog/quill-charts/testing'
import { useMocks } from '~/mocks/jest'
import { initKeaTests } from '~/test/init'
@@ -58,7 +58,7 @@ describe('LogsFilterVolumeSparkline', () => {
it('loads on mount for a pre-filled group and renders the chart with the total', async () => {
const { container } = render(<LogsFilterVolumeSparkline filterGroup={NON_EMPTY_GROUP} metric="bytes" />)
- await waitFor(() => expect(getHogChart(container).seriesCount).toEqual(1))
+ await waitFor(() => expect(getChart(container).seriesCount).toEqual(1))
expect(sparklineCalls).toEqual(1)
expect(screen.getByText('6.1 KB')).toBeTruthy()
})
diff --git a/products/marketing_analytics/frontend/dashboard/charts/MetricChart.test.tsx b/products/marketing_analytics/frontend/dashboard/charts/MetricChart.test.tsx
index 35933775e115..447042ccfc7a 100644
--- a/products/marketing_analytics/frontend/dashboard/charts/MetricChart.test.tsx
+++ b/products/marketing_analytics/frontend/dashboard/charts/MetricChart.test.tsx
@@ -2,7 +2,7 @@ import {
clickAtIndex,
createDefaultTooltipAccessor,
hoverUntilTooltip,
- renderHogChart,
+ renderChart,
} from '@posthog/quill-charts/testing'
import { MetricChart, MetricChartProps } from './MetricChart'
@@ -28,7 +28,7 @@ describe('MetricChart', () => {
{ key: '', label: 'No channel' },
])('selects the closest of several lines using the raw key "$key"', async ({ key, label }) => {
const onFocus = jest.fn()
- const { chart } = renderHogChart(
+ const { chart } = renderChart(
<MetricChart
{...props}
series={[
@@ -47,7 +47,7 @@ describe('MetricChart', () => {
})
it('formats fractional rates as percentages in the axis and tooltip', async () => {
- const { chart, container } = renderHogChart(
+ const { chart, container } = renderChart(
<MetricChart
{...props}
format="percentage"
@@ -62,7 +62,7 @@ describe('MetricChart', () => {
})
it('shows the supplied error instead of stale data and hides it during retry', () => {
- const { container, rerender, getByText, queryByText } = renderHogChart(
+ const { container, rerender, getByText, queryByText } = renderChart(
<MetricChart {...props} series={[{ key: 'email', label: 'Email', data: [0, 12, 8] }]} />,
{ nativeTooltip: true }
)
diff --git a/products/metrics/frontend/components/MetricsSeriesChart.test.tsx b/products/metrics/frontend/components/MetricsSeriesChart.test.tsx
index f33ddc415444..7fd5c5c2e245 100644
--- a/products/metrics/frontend/components/MetricsSeriesChart.test.tsx
+++ b/products/metrics/frontend/components/MetricsSeriesChart.test.tsx
@@ -2,12 +2,7 @@ import '@testing-library/jest-dom'
import { cleanup, render, screen } from '@testing-library/react'
-import {
- createDefaultTooltipAccessor,
- ensureJsdom,
- getHogChart,
- hoverUntilTooltip,
-} from '@posthog/quill-charts/testing'
+import { createDefaultTooltipAccessor, ensureJsdom, getChart, hoverUntilTooltip } from '@posthog/quill-charts/testing'
import type { MetricsDisplaySettings } from '~/queries/schema/schema-general'
import { initKeaTests } from '~/test/init'
@@ -40,7 +35,7 @@ describe('MetricsSeriesChart', () => {
it('draws one line per series', () => {
renderChart([seriesWith({ service: 'checkout' }, [1, 2, 3]), seriesWith({ service: 'billing' }, [4, 5, 6])])
- expect(getHogChart().seriesCount).toBe(2)
+ expect(getChart().seriesCount).toBe(2)
})
it.each([
@@ -79,7 +74,7 @@ describe('MetricsSeriesChart', () => {
type,
})
- expect(getHogChart().seriesCount).toBe(2)
+ expect(getChart().seriesCount).toBe(2)
expect(screen.getByTestId(`hog-chart-timeseries-${expectedChart}-legend`)).toBeInTheDocument()
})
@@ -105,14 +100,14 @@ describe('MetricsSeriesChart', () => {
// dropping the point instead would silently shift every later value a bucket to the left.
it('charts a null bucket as zero rather than dropping the point', async () => {
renderChart([seriesWith({}, [1, null, 3])])
- const chart = getHogChart()
+ const chart = getChart()
const tooltip = createDefaultTooltipAccessor(await hoverUntilTooltip(chart.element, 1, BUCKETS.length))
expect(tooltip.value('http.requests')).toBe('0')
})
it('formats the x-axis ticks and tooltip label as tz-aware dates', async () => {
renderChart([seriesWith({}, [1, 2, 3])])
- const chart = getHogChart()
+ const chart = getChart()
expect(chart.xTicks()).toEqual(['10:00', '11:00', '12:00'])
const tooltip = createDefaultTooltipAccessor(await hoverUntilTooltip(chart.element, 1, BUCKETS.length))
expect(tooltip.label()).toBe('1 Aug 2026 11:00:00')
diff --git a/products/metrics/frontend/panels/MetricsPanel.test.tsx b/products/metrics/frontend/panels/MetricsPanel.test.tsx
index b9efb91a3ad2..95e018027cb2 100644
--- a/products/metrics/frontend/panels/MetricsPanel.test.tsx
+++ b/products/metrics/frontend/panels/MetricsPanel.test.tsx
@@ -2,12 +2,7 @@ import '@testing-library/jest-dom'
import { cleanup, render, screen } from '@testing-library/react'
-import {
- createDefaultTooltipAccessor,
- ensureJsdom,
- getHogChart,
- hoverUntilTooltip,
-} from '@posthog/quill-charts/testing'
+import { createDefaultTooltipAccessor, ensureJsdom, getChart, hoverUntilTooltip } from '@posthog/quill-charts/testing'
import type { MetricsDisplaySettings } from '~/queries/schema/schema-general'
import { initKeaTests } from '~/test/init'
@@ -46,7 +41,7 @@ describe('MetricsPanel', () => {
it('draws one line per series by default', () => {
renderPanel([seriesWith({ service: 'checkout' }, [1, 2, 3]), seriesWith({ service: 'billing' }, [4, 5, 6])])
- expect(getHogChart().seriesCount).toBe(2)
+ expect(getChart().seriesCount).toBe(2)
})
it.each([
@@ -55,13 +50,13 @@ describe('MetricsPanel', () => {
['renders the bar display as a bar chart', 'bar' as const, 'bar'],
])('%s', (_name, type, expectedChart) => {
renderPanel([seriesWith({ service: 'a' }, [1, 2, 3]), seriesWith({ service: 'b' }, [4, 5, 6])], { type })
- expect(getHogChart().seriesCount).toBe(2)
+ expect(getChart().seriesCount).toBe(2)
expect(screen.getByTestId(`hog-chart-timeseries-${expectedChart}-legend`)).toBeInTheDocument()
})
it('falls back to a line chart for an unknown display type', () => {
renderPanel([seriesWith({ service: 'a' }, [1, 2, 3])], { type: 'pie' as never })
- expect(getHogChart().seriesCount).toBe(1)
+ expect(getChart().seriesCount).toBe(1)
})
it('renders a clickable dot per traced exemplar', () => {
@@ -75,14 +70,14 @@ describe('MetricsPanel', () => {
// until the quill null-data change; dropping it would shift later values a bucket left.
it('charts a null bucket as zero rather than dropping the point', async () => {
renderPanel([seriesWith({}, [1, null, 3])])
- const chart = getHogChart()
+ const chart = getChart()
const tooltip = createDefaultTooltipAccessor(await hoverUntilTooltip(chart.element, 1, BUCKETS.length))
expect(tooltip.value('http.requests')).toBe('0')
})
it('formats the y axis and tooltip with the resolved unit', async () => {
renderPanel([seriesWith({}, [250, 1500, 3000], 'http.duration', 'ms')])
- const chart = getHogChart()
+ const chart = getChart()
expect(chart.yTicks().some((tick) => tick.endsWith(' s'))).toBe(true)
const tooltip = createDefaultTooltipAccessor(await hoverUntilTooltip(chart.element, 0, BUCKETS.length))
expect(tooltip.value('http.duration')).toBe('250 ms')
@@ -90,7 +85,7 @@ describe('MetricsPanel', () => {
it('labels every ratio tick on one scale when the data exceeds 1', () => {
renderPanel([seriesWith({}, [0, 1, 2], 'load', '1')])
- const ticks = getHogChart().yTicks()
+ const ticks = getChart().yTicks()
expect(ticks.length).toBeGreaterThan(1)
expect(ticks.some((tick) => tick.endsWith('%'))).toBe(false)
})
@@ -168,7 +163,7 @@ describe('MetricsPanel', () => {
renderPanel([seriesWith({ pod: 'a' }, [1, 2, 10]), seriesWith({ pod: 'b' }, [1, 2, 20])], {
type: 'bargauge',
})
- expect(getHogChart().seriesCount).toBe(1)
+ expect(getChart().seriesCount).toBe(1)
expect(screen.getByText('pod=a')).toBeInTheDocument()
expect(screen.getByText('pod=b')).toBeInTheDocument()
})
diff --git a/products/product_analytics/frontend/insights/funnels/FunnelLineChart/FunnelLineChart.test.tsx b/products/product_analytics/frontend/insights/funnels/FunnelLineChart/FunnelLineChart.test.tsx
index 57f33c00d543..a2b6f063e205 100644
--- a/products/product_analytics/frontend/insights/funnels/FunnelLineChart/FunnelLineChart.test.tsx
+++ b/products/product_analytics/frontend/insights/funnels/FunnelLineChart/FunnelLineChart.test.tsx
@@ -2,18 +2,11 @@ import '@testing-library/jest-dom'
import { cleanup, configure, screen, waitFor } from '@testing-library/react'
-import { dragSelection, ensureJsdom, waitForHogChartTooltip } from '@posthog/quill-charts/testing'
+import { dragSelection, ensureJsdom, waitForChartTooltip } from '@posthog/quill-charts/testing'
import { FEATURE_FLAGS } from 'lib/constants'
-import {
- buildFunnelsQuery,
- chart,
- getHogChart,
- getQuerySource,
- personsModal,
- renderInsight,
-} from '~/test/insight-testing'
+import { buildFunnelsQuery, chart, getChart, getQuerySource, personsModal, renderInsight } from '~/test/insight-testing'
import { buildAnnotation } from '~/test/insight-testing/test-data'
import { AnnotationScope } from '~/types'
@@ -35,7 +28,7 @@ describe('FunnelLineChart', () => {
const tooltip = await chart.hoverTooltip(2)
- expect(getHogChart().seriesCount).toBe(1)
+ expect(getChart().seriesCount).toBe(1)
expect(tooltip.element.textContent).toContain(FUNNEL_CONVERSION_SERIES_LABEL)
expect(tooltip.element.textContent).toContain('40% (80/200)')
})
@@ -48,11 +41,11 @@ describe('FunnelLineChart', () => {
})
await waitFor(() => {
- expect(getHogChart().seriesCount).toBe(2)
+ expect(getChart().seriesCount).toBe(2)
})
await chart.clickAtIndex(2)
- const tooltip = await waitForHogChartTooltip()
+ const tooltip = await waitForChartTooltip()
expect(tooltip.textContent).toContain('Spike')
expect(tooltip.textContent).toContain('Bramble')
})
@@ -157,7 +150,7 @@ describe('FunnelLineChart', () => {
await screen.findByLabelText(/chart with/i)
await waitFor(() => {
- const texts = getHogChart()
+ const texts = getChart()
.valueLabels()
.map((l) => l.text)
// default fixture data [10, 25, 40, 60, 35] rendered as percentages
diff --git a/products/product_analytics/frontend/insights/stickiness/StickinessLineChart/StickinessLineChart.test.tsx b/products/product_analytics/frontend/insights/stickiness/StickinessLineChart/StickinessLineChart.test.tsx
index fb7365ca467d..c2028f82e2fb 100644
--- a/products/product_analytics/frontend/insights/stickiness/StickinessLineChart/StickinessLineChart.test.tsx
+++ b/products/product_analytics/frontend/insights/stickiness/StickinessLineChart/StickinessLineChart.test.tsx
@@ -6,7 +6,7 @@ import { setupJsdom, setupSyncRaf } from '@posthog/quill-charts/testing'
import { ExportType } from '~/exporter/types'
import { NodeKind } from '~/queries/schema/schema-general'
-import { buildStickinessQuery, chart, getHogChart, personsModal, renderInsight } from '~/test/insight-testing'
+import { buildStickinessQuery, chart, getChart, personsModal, renderInsight } from '~/test/insight-testing'
configure({ asyncUtilTimeout: 5000 })
// With asyncUtilTimeout at 5s, a single legitimate waitFor can exhaust Jest's default
@@ -43,7 +43,7 @@ describe('StickinessLineChart', () => {
await screen.findByLabelText(/chart with 1 data series/i)
await waitFor(() => {
- expect(getHogChart().xTicks()).toEqual(
+ expect(getChart().xTicks()).toEqual(
expect.arrayContaining(['1 day', '2 days', '3 days', '4 days', '5 days'])
)
})
diff --git a/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.test.tsx b/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.test.tsx
index 8835971e974f..5342183d575c 100644
--- a/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.test.tsx
+++ b/products/product_analytics/frontend/insights/trends/TrendsBarChart/TrendsBarChart.test.tsx
@@ -6,7 +6,7 @@ import { dimensions, setupJsdom, setupSyncRaf } from '@posthog/quill-charts/test
import { ExportType } from '~/exporter/types'
import { NodeKind } from '~/queries/schema/schema-general'
-import { buildTrendsQuery, chart, getHogChart, personsModal, renderInsight } from '~/test/insight-testing'
+import { buildTrendsQuery, chart, getChart, personsModal, renderInsight } from '~/test/insight-testing'
import { buildAnnotation } from '~/test/insight-testing/test-data'
import { AnnotationScope, ChartDisplayType } from '~/types'
@@ -253,10 +253,10 @@ describe('TrendsBarChart (ActionsBarValue)', () => {
// Axis titles are a layout-dependent overlay that commits a tick after the
// chart's aria-label appears, so read them through waitFor rather than synchronously.
await waitFor(() => {
- expect(getHogChart().xAxisLabel()).toBe('Total events')
- expect(getHogChart().yAxisLabel()).toBe('Series')
+ expect(getChart().xAxisLabel()).toBe('Total events')
+ expect(getChart().yAxisLabel()).toBe('Series')
expect(
- getHogChart()
+ getChart()
.element.querySelector<SVGTextElement>('[data-attr="hog-chart-axis-title-y"]')
?.getAttribute('transform')
).toContain('rotate(-90')
@@ -294,7 +294,7 @@ describe('TrendsBarChart (ActionsBarValue)', () => {
await waitFor(
() => {
- const ticks = getHogChart().yTicks()
+ const ticks = getChart().yTicks()
expect(ticks).toHaveLength(expectedTicks)
if (containsTick) {
expect(ticks).toEqual(expect.arrayContaining([containsTick]))
@@ -318,11 +318,11 @@ describe('TrendsBarChart (ActionsBarValue)', () => {
await waitFor(
() => {
- expect(getHogChart().valueLabels().length).toBeGreaterThan(1)
+ expect(getChart().valueLabels().length).toBeGreaterThan(1)
},
{ timeout: 5000 }
)
- const pillColors = getHogChart()
+ const pillColors = getChart()
.valueLabels()
.map((l) => l.color)
expect(new Set(pillColors).size).toBeGreaterThan(1)
@@ -366,7 +366,7 @@ describe('TrendsBarChart (ActionsBarValue)', () => {
await waitFor(
() => {
- const ticks = getHogChart().yTicks()
+ const ticks = getChart().yTicks()
if (expectAllRows) {
expect(ticks).toHaveLength(totalRows)
} else {
@@ -524,11 +524,11 @@ describe('TrendsBarChart overlays', () => {
await screen.findByLabelText(/chart with/i, undefined, { timeout: 5000 })
await waitFor(
() => {
- expect(getHogChart().valueLabels().length).toBeGreaterThan(0)
+ expect(getChart().valueLabels().length).toBeGreaterThan(0)
},
{ timeout: 5000 }
)
- const labels = getHogChart()
+ const labels = getChart()
.valueLabels()
.map((l) => l.text)
// Pageview series peaks at 210 — it should appear among the rendered labels.
@@ -554,7 +554,7 @@ describe('TrendsBarChart overlays', () => {
await screen.findByLabelText(/chart with/i, undefined, { timeout: 5000 })
await waitFor(
() => {
- expect(getHogChart().annotationBadges().length).toBeGreaterThan(0)
+ expect(getChart().annotationBadges().length).toBeGreaterThan(0)
},
{ timeout: 5000 }
)
@@ -592,7 +592,7 @@ describe('TrendsBarChart overlays', () => {
await screen.findByLabelText(/chart with/i, undefined, { timeout: 5000 })
await waitFor(
() => {
- const lines = getHogChart().referenceLines()
+ const lines = getChart().referenceLines()
expect(lines.map((l) => l.label)).toEqual(['Target'])
expect(lines[0].orientation).toBe(expectedOrientation)
},
diff --git a/products/product_analytics/frontend/insights/trends/TrendsLineChart/TrendsLineChart.test.tsx b/products/product_analytics/frontend/insights/trends/TrendsLineChart/TrendsLineChart.test.tsx
index 9e9e23411bc6..625b3c760e1b 100644
--- a/products/product_analytics/frontend/insights/trends/TrendsLineChart/TrendsLineChart.test.tsx
+++ b/products/product_analytics/frontend/insights/trends/TrendsLineChart/TrendsLineChart.test.tsx
@@ -16,7 +16,7 @@ import {
buildTrendsQuery,
chart,
createInsightTooltipAccessor,
- getHogChart,
+ getChart,
getQuerySource,
legend,
personsModal,
@@ -374,7 +374,7 @@ describe('TrendsLineChart', () => {
await screen.findByLabelText(/chart with/i)
// Reference lines come exclusively from goalLines in this test (none configured),
// so the count must be 0 — anything here would be a leaked alert overlay.
- expect(getHogChart().referenceLines()).toHaveLength(0)
+ expect(getChart().referenceLines()).toHaveLength(0)
})
})
@@ -413,8 +413,8 @@ describe('TrendsLineChart', () => {
// chart's aria-label appears (like referenceLines/valueLabels below), so read
// them through waitFor rather than synchronously.
await waitFor(() => {
- expect(getHogChart().xAxisLabel()).toBe('Signup date')
- expect(getHogChart().yAxisLabel()).toBe('Unique users')
+ expect(getChart().xAxisLabel()).toBe('Signup date')
+ expect(getChart().yAxisLabel()).toBe('Unique users')
})
})
})
@@ -432,9 +432,9 @@ describe('TrendsLineChart', () => {
})
await waitFor(() => {
- expect(getHogChart().hasRightAxis).toBe(true)
+ expect(getChart().hasRightAxis).toBe(true)
})
- expect(getHogChart().yRightTicks().length).toBeGreaterThan(0)
+ expect(getChart().yRightTicks().length).toBeGreaterThan(0)
})
})
@@ -449,7 +449,7 @@ describe('TrendsLineChart', () => {
await screen.findByLabelText(/chart with/i)
await waitFor(
() => {
- const lines = getHogChart().referenceLines()
+ const lines = getChart().referenceLines()
expect(lines.map((l) => l.label)).toEqual(['Target'])
for (const line of lines) {
expect(line.orientation).toBe('horizontal')
@@ -469,11 +469,11 @@ describe('TrendsLineChart', () => {
})
await waitFor(() => {
- const labels = getHogChart().valueLabels()
+ const labels = getChart().valueLabels()
expect(labels.length).toBeGreaterThan(0)
})
// Pageview series is [45, 82, 134, 210, 95]; all non-zero => 5 labels.
- const labels = getHogChart()
+ const labels = getChart()
.valueLabels()
.map((l) => l.text)
expect(labels).toContain('45')
@@ -496,9 +496,9 @@ describe('TrendsLineChart', () => {
})
await waitFor(() => {
- expect(getHogChart().valueLabels().length).toBeGreaterThan(0)
+ expect(getChart().valueLabels().length).toBeGreaterThan(0)
})
- const labels = getHogChart().valueLabels()
+ const labels = getChart().valueLabels()
for (const l of labels) {
expect(l.text).toMatch(/%/)
}
@@ -900,7 +900,7 @@ describe('TrendsLineChart', () => {
})
await waitFor(() => {
- expect(getHogChart().valueLabels()).toHaveLength(6)
+ expect(getChart().valueLabels()).toHaveLength(6)
})
const leftByText = new Map(
Array.from(document.querySelectorAll<HTMLElement>('[data-attr="hog-chart-value-label"]')).map(
diff --git a/products/product_analytics/frontend/insights/trends/TrendsProportionBar/TrendsProportionBar.test.tsx b/products/product_analytics/frontend/insights/trends/TrendsProportionBar/TrendsProportionBar.test.tsx
index ca078a85fb12..0b7e68face52 100644
--- a/products/product_analytics/frontend/insights/trends/TrendsProportionBar/TrendsProportionBar.test.tsx
+++ b/products/product_analytics/frontend/insights/trends/TrendsProportionBar/TrendsProportionBar.test.tsx
@@ -2,7 +2,7 @@ import '@testing-library/jest-dom'
import { cleanup, waitFor } from '@testing-library/react'
-import { getHogChart, setupJsdom, setupSyncRaf } from '@posthog/quill-charts/testing'
+import { getChart, setupJsdom, setupSyncRaf } from '@posthog/quill-charts/testing'
import { NodeKind } from '~/queries/schema/schema-general'
import { buildTrendsQuery, renderInsight } from '~/test/insight-testing'
@@ -54,7 +54,7 @@ describe('TrendsProportionBar', () => {
timeout: 5000,
})
- expect(getHogChart(container).legendItems()).toEqual(expectedRows)
+ expect(getChart(container).legendItems()).toEqual(expectedRows)
})
it('floors a negative part at 0 in the total below the bar, matching what the bar renders', async () => {
@@ -91,6 +91,6 @@ describe('TrendsProportionBar', () => {
timeout: 5000,
})
- expect(getHogChart(container).legendItems()).toHaveLength(1)
+ expect(getChart(container).legendItems()).toHaveLength(1)
})
})
diff --git a/products/replay_vision/frontend/replay_scanners/components/SpendTrajectoryChart.test.tsx b/products/replay_vision/frontend/replay_scanners/components/SpendTrajectoryChart.test.tsx
index 34df18909bb1..47682d7073e8 100644
--- a/products/replay_vision/frontend/replay_scanners/components/SpendTrajectoryChart.test.tsx
+++ b/products/replay_vision/frontend/replay_scanners/components/SpendTrajectoryChart.test.tsx
@@ -1,7 +1,7 @@
import { cleanup, render, screen } from '@testing-library/react'
import type { ComponentProps } from 'react'
-import { type HogChart, ensureJsdom, getHogChart } from '@posthog/quill-charts/testing'
+import { type ChartAccessor, ensureJsdom, getChart } from '@posthog/quill-charts/testing'
import { dayjs } from 'lib/dayjs'
@@ -19,7 +19,7 @@ function series(total: number, days: number, periodStart: string): SpendSeries {
}))
}
-function renderChart(overrides: Partial<Props> = {}): HogChart {
+function renderChart(overrides: Partial<Props> = {}): ChartAccessor {
const quota = makeQuota({ credit_limit: 10_000, credits_used: 4_000, free_monthly_credits: 2_500 })
const { container } = render(
<SpendTrajectoryChart
@@ -31,7 +31,7 @@ function renderChart(overrides: Partial<Props> = {}): HogChart {
{...overrides}
/>
)
- return getHogChart(container)
+ return getChart(container)
}
describe('SpendTrajectoryChart', () => {
diff --git a/products/signals/frontend/inbox/components/detail/ReportPrimaryMetric.test.tsx b/products/signals/frontend/inbox/components/detail/ReportPrimaryMetric.test.tsx
index c19948433cbf..a06918c28c02 100644
--- a/products/signals/frontend/inbox/components/detail/ReportPrimaryMetric.test.tsx
+++ b/products/signals/frontend/inbox/components/detail/ReportPrimaryMetric.test.tsx
@@ -4,7 +4,7 @@ import '@testing-library/jest-dom'
import { cleanup, render, screen, waitFor, within } from '@testing-library/react'
-import { ensureJsdom, getHogChart } from '@posthog/quill-charts/testing'
+import { ensureJsdom, getChart } from '@posthog/quill-charts/testing'
import { useMocks } from '~/mocks/jest'
import { NodeKind } from '~/queries/schema/schema-general'
@@ -114,7 +114,7 @@ describe('ReportPrimaryMetric', () => {
return element
})
expect(chart).toHaveAttribute('data-chart-type', 'bar')
- expect(getHogChart(chart).yTicks().filter(Boolean)).toEqual(['0', '1'])
+ expect(getChart(chart).yTicks().filter(Boolean)).toEqual(['0', '1'])
await waitFor(() =>
expect(requestedDisplays).toEqual(
expect.arrayContaining([ChartDisplayType.BoldNumber, ChartDisplayType.ActionsBar])
diff --git a/products/tracing/frontend/TracingSparkline.test.tsx b/products/tracing/frontend/TracingSparkline.test.tsx
index b812d8751605..441df904c00d 100644
--- a/products/tracing/frontend/TracingSparkline.test.tsx
+++ b/products/tracing/frontend/TracingSparkline.test.tsx
@@ -1,6 +1,6 @@
import { cleanup, render } from '@testing-library/react'
-import { clickAtIndex, getHogChart, setupJsdom, setupSyncRaf } from '@posthog/quill-charts/testing'
+import { clickAtIndex, getChart, setupJsdom, setupSyncRaf } from '@posthog/quill-charts/testing'
import { initKeaTests } from '~/test/init'
@@ -59,7 +59,7 @@ function renderChart(props: Partial<React.ComponentProps<typeof TracingSparkline
{...props}
/>
)
- return { element: getHogChart(container).element, onDateRangeChange }
+ return { element: getChart(container).element, onDateRangeChange }
}
describe('TracingSparkline', () => {