Open-source agentic AI Search Execution Platform. Track AI visibility, find opportunities, and let agents turn signals into prioritized actions and drafted fixes across ChatGPT, Claude, Gemini, Google AI Overviews, Google AI Mode, Perplexity, Grok, and Microsoft Copilot.
TypeScript aeoai-agentai-searchanswer-engine-optimizationbrand-monitoringchatgptclaudecopilotdockergeminigeogoogle-ai-overviewsgrokmcpnextjsopen-sourceperplexityseosupabasetypescript
fix(shopping): take the charts' series names from the translations, and test the trend legend's dash (#1670)
Cihanb14b11748c16
diff --git a/web/messages/en.json b/web/messages/en.jsonindex e0efec68b..4a7a4015f 100644--- a/web/messages/en.json+++ b/web/messages/en.json@@ -7560,6 +7560,9 @@"kpiTopMerchantSub": "Most frequent merchant domain","platformBreakdownTitle": "Card rate by platform","trendTitle": "Your shopping presence — last 30 days",+ "seriesCardRate": "Card rate",+ "seriesOwnCards": "Your cards",+ "seriesAllCards": "All cards","amazonShareDropAlert": "Amazon's share fell from {from}% to {to}% over the last seven days. AI may be leaving Amazon out; your own store link matters more.","filterRegion": "Region","filterPlatform": "Platform",diff --git a/web/src/app/[locale]/(dashboard)/dashboard/shopping/page.tsx b/web/src/app/[locale]/(dashboard)/dashboard/shopping/page.tsxindex 04206b2f2..11776c66a 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/shopping/page.tsx+++ b/web/src/app/[locale]/(dashboard)/dashboard/shopping/page.tsx@@ -1072,14 +1072,20 @@ function PlatformCardRateChart({{loading ? (<Skeleton className="h-[220px] w-full" />) : (- <ResponsiveBarChart data={chartData} />+ <ResponsiveBarChart data={chartData} label={t('seriesCardRate')} />)}</CardContent></Card>);}-function ResponsiveBarChart({ data }: { data: Array<{ platform: string; rate: number }> }) {+function ResponsiveBarChart({+ data,+ label,+}: {+ data: Array<{ platform: string; rate: number }>;+ label: string;+}) {const ref = useRef<HTMLDivElement>(null);const [width, setWidth] = useState(0);useEffect(() => {@@ -1093,7 +1099,7 @@ function ResponsiveBarChart({ data }: { data: Array<{ platform: string; rate: nu}, []);return (<div ref={ref} style={{ width: '100%', height: 220 }}>- {width > 0 && <DynamicPlatformCardRateChart width={width} data={data} />}+ {width > 0 && <DynamicPlatformCardRateChart width={width} data={data} label={label} />}</div>);}@@ -1113,7 +1119,14 @@ function OwnPresenceTrendChart({<CardTitle className="text-sm font-medium">{t('trendTitle')}</CardTitle></CardHeader><CardContent>- {loading ? <Skeleton className="h-[220px] w-full" /> : <ResponsiveLineChart data={data} />}+ {loading ? (+ <Skeleton className="h-[220px] w-full" />+ ) : (+ <ResponsiveLineChart+ data={data}+ labels={{ own: t('seriesOwnCards'), all: t('seriesAllCards') }}+ />+ )}</CardContent></Card>);@@ -1121,8 +1134,10 @@ function OwnPresenceTrendChart({function ResponsiveLineChart({data,+ labels,}: {data: Array<{ date: string; ownCards: number; totalCards: number }>;+ labels: { own: string; all: string };}) {const ref = useRef<HTMLDivElement>(null);const [width, setWidth] = useState(0);@@ -1137,7 +1152,7 @@ function ResponsiveLineChart({}, []);return (<div ref={ref} style={{ width: '100%', height: 220 }}>- {width > 0 && <DynamicShoppingTrendChart width={width} data={data} />}+ {width > 0 && <DynamicShoppingTrendChart width={width} data={data} labels={labels} />}</div>);}diff --git a/web/src/app/[locale]/(dashboard)/dashboard/shopping/shopping_charts.test.tsx b/web/src/app/[locale]/(dashboard)/dashboard/shopping/shopping_charts.test.tsxnew file mode 100644index 000000000..838855f13--- /dev/null+++ b/web/src/app/[locale]/(dashboard)/dashboard/shopping/shopping_charts.test.tsx@@ -0,0 +1,69 @@+import { act } from 'react';+import { createRoot, type Root } from 'react-dom/client';+import { afterEach, beforeEach, describe, expect, it } from 'vitest';+import { PlatformCardRateChartView, ShoppingTrendChartView } from './shopping_charts';++/**+ * The Shopping page's charts (#1597): drawn at a fixed width, so Recharts+ * renders them in jsdom (only ResponsiveContainer measures zero there).+ */++(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT =+ true;++let container: HTMLDivElement;+let root: Root;++beforeEach(() => {+ container = document.createElement('div');+ document.body.appendChild(container);+ root = createRoot(container);+});+afterEach(() => {+ act(() => root.unmount());+ container.remove();+});++const days = [+ { date: '2026-10-20', ownCards: 2, totalCards: 9 },+ { date: '2026-10-21', ownCards: 3, totalCards: 11 },+];++describe('ShoppingTrendChartView', () => {+ it("draws the legend's two lines, the All cards one dashed as its series, named as given", () => {+ act(() =>+ root.render(+ <ShoppingTrendChartView+ width={600}+ data={days}+ labels={{ own: 'Tus tarjetas', all: 'Todas las tarjetas' }}+ />,+ ),+ );+ const icons = [...container.querySelectorAll('.recharts-legend-icon')];+ expect(icons).toHaveLength(2);+ expect(icons.filter((icon) => icon.getAttribute('stroke-dasharray') === '4 3')).toHaveLength(1);+ const legend = container.querySelector('.recharts-legend-wrapper')!.textContent;+ expect(legend).toContain('Tus tarjetas');+ expect(legend).toContain('Todas las tarjetas');+ expect(legend).not.toContain('All cards');+ });+});++describe('PlatformCardRateChartView', () => {+ it('draws a bar a platform', () => {+ act(() =>+ root.render(+ <PlatformCardRateChartView+ width={600}+ data={[+ { platform: 'ChatGPT', rate: 40 },+ { platform: 'Perplexity', rate: 25 },+ ]}+ label="Card rate"+ />,+ ),+ );+ expect(container.querySelectorAll('.recharts-bar-rectangle')).toHaveLength(2);+ });+});diff --git a/web/src/app/[locale]/(dashboard)/dashboard/shopping/shopping_charts.tsx b/web/src/app/[locale]/(dashboard)/dashboard/shopping/shopping_charts.tsxindex 7d24fea5f..7322a49df 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/shopping/shopping_charts.tsx+++ b/web/src/app/[locale]/(dashboard)/dashboard/shopping/shopping_charts.tsx@@ -38,9 +38,11 @@ type PlatformCardRateChartViewProps = {platform: string;rate: number;}>;+ /** The series' name, as its tooltip shows it (the page's translation). */+ label: string;};-export function PlatformCardRateChartView({ width, data }: PlatformCardRateChartViewProps) {+export function PlatformCardRateChartView({ width, data, label }: PlatformCardRateChartViewProps) {return (<BarChartwidth={width}@@ -56,7 +58,7 @@ export function PlatformCardRateChartView({ width, data }: PlatformCardRateChart<Tooltip contentStyle={TOOLTIP_STYLE} cursor={{ fill: 'var(--muted)', opacity: 0.3 }} />- <Bar dataKey="rate" name="Card rate" fill={INK} radius={[4, 4, 0, 0]} />+ <Bar dataKey="rate" name={label} fill={INK} radius={[4, 4, 0, 0]} /></BarChart>);}@@ -68,9 +70,11 @@ type ShoppingTrendChartViewProps = {ownCards: number;totalCards: number;}>;+ /** The two series' names, as the legend and tooltip show them (the page's translations). */+ labels: { own: string; all: string };};-export function ShoppingTrendChartView({ width, data }: ShoppingTrendChartViewProps) {+export function ShoppingTrendChartView({ width, data, labels }: ShoppingTrendChartViewProps) {return (<ComposedChartwidth={width}@@ -109,7 +113,7 @@ export function ShoppingTrendChartView({ width, data }: ShoppingTrendChartViewPr<Areatype="monotone"dataKey="ownCards"- name="Your cards"+ name={labels.own}legendType="plainline"stroke={INK}strokeWidth={2}@@ -121,7 +125,7 @@ export function ShoppingTrendChartView({ width, data }: ShoppingTrendChartViewPr<Linetype="monotone"dataKey="totalCards"- name="All cards"+ name={labels.all}// The legend draws its icon with the series' dash (plainline), so the two read apart.legendType="plainline"stroke={SECOND}