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(action-center): keep the KPIs status filter from crashing the page (#1067)
Cihan044704fd7949
diff --git a/web/src/app/[locale]/(dashboard)/dashboard/action-center/kpis/page.test.tsx b/web/src/app/[locale]/(dashboard)/dashboard/action-center/kpis/page.test.tsxnew file mode 100644index 000000000..a1960321c--- /dev/null+++ b/web/src/app/[locale]/(dashboard)/dashboard/action-center/kpis/page.test.tsx@@ -0,0 +1,88 @@+import { act } from 'react';+import { createRoot } from 'react-dom/client';+import { afterEach, describe, expect, it, vi } from 'vitest';+import type { Brand } from '@/types';++(+ globalThis as typeof globalThis & {+ IS_REACT_ACT_ENVIRONMENT: boolean;+ }+).IS_REACT_ACT_ENVIRONMENT = true;++const brand: Brand = {+ id: 'brand-id',+ organizationId: 'organization-id',+ name: 'Acme',+ slug: 'acme',+ industry: 'Technology',+ region: 'US',+ shoppingModeEnabled: false,+ isActive: true,+ domains: [],+ createdAt: '2026-01-01T00:00:00.000Z',+ updatedAt: '2026-01-01T00:00:00.000Z',+};++vi.mock('next-intl', () => ({+ useTranslations: () => (key: string) => key,+}));++vi.mock('@/stores/use-brand-store', () => ({+ useBrandStore: (selector: (state: { getActiveBrand: () => Brand }) => unknown) =>+ selector({ getActiveBrand: () => brand }),+}));++vi.mock('@/lib/actions/kpis', () => ({+ getKpiSnapshots: vi.fn().mockResolvedValue({ configured: true, kpis: [] }),+ removeKpi: vi.fn(),+}));++vi.mock('@/components/action-center/action-center-tabs', () => ({+ ActionCenterTabs: () => null,+}));++vi.mock('@/components/action-center/kpi-framework-drawer', () => ({+ KpiFrameworkDrawer: () => null,+}));++vi.mock('@/components/action-center/kpi-table', () => ({+ KpiTable: () => null,+}));++vi.mock('sonner', () => ({+ toast: {+ error: vi.fn(),+ },+}));++import ActionCenterKpisPage from './page';++afterEach(() => {+ document.body.replaceChildren();+});++describe('KPIs status filter', () => {+ it('opens the menu with its status label and options', async () => {+ const container = document.createElement('div');+ document.body.append(container);+ const root = createRoot(container);++ await act(async () => {+ root.render(<ActionCenterKpisPage />);+ });++ const trigger = Array.from(container.querySelectorAll('button')).find(+ (button) => button.textContent === 'filters',+ );+ expect(trigger).toBeDefined();++ await act(async () => trigger?.click());++ // The menu is portaled to <body>; a label outside a group would throw here.+ const menu = document.body.querySelector('[role="menu"]');+ expect(menu?.textContent).toContain('table.status');+ expect(menu?.querySelectorAll('[role="menuitemcheckbox"]')).toHaveLength(4);++ await act(async () => root.unmount());+ });+});diff --git a/web/src/app/[locale]/(dashboard)/dashboard/action-center/kpis/page.tsx b/web/src/app/[locale]/(dashboard)/dashboard/action-center/kpis/page.tsxindex abdc46155..4f5bfb378 100644--- a/web/src/app/[locale]/(dashboard)/dashboard/action-center/kpis/page.tsx+++ b/web/src/app/[locale]/(dashboard)/dashboard/action-center/kpis/page.tsx@@ -18,6 +18,7 @@ import {DropdownMenu,DropdownMenuCheckboxItem,DropdownMenuContent,+ DropdownMenuGroup,DropdownMenuLabel,DropdownMenuSeparator,DropdownMenuTrigger,@@ -226,17 +227,19 @@ function KpisContent({ brand }: { brand: Brand }) {)}</DropdownMenuTrigger><DropdownMenuContent align="end">- <DropdownMenuLabel>{t('table.status')}</DropdownMenuLabel>- <DropdownMenuSeparator />- {KPI_STATUSES.map((status) => (- <DropdownMenuCheckboxItem- key={status}- checked={statusFilter.has(status)}- onCheckedChange={() => toggleStatus(status)}- >- {t(`status.${status}`)}- </DropdownMenuCheckboxItem>- ))}+ <DropdownMenuGroup>+ <DropdownMenuLabel>{t('table.status')}</DropdownMenuLabel>+ <DropdownMenuSeparator />+ {KPI_STATUSES.map((status) => (+ <DropdownMenuCheckboxItem+ key={status}+ checked={statusFilter.has(status)}+ onCheckedChange={() => toggleStatus(status)}+ >+ {t(`status.${status}`)}+ </DropdownMenuCheckboxItem>+ ))}+ </DropdownMenuGroup></DropdownMenuContent></DropdownMenu><div