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): say "1 prompt" and "1 day" in action history (#1092)
Cihan5b8b87483400
diff --git a/web/messages/en.json b/web/messages/en.jsonindex 629713f32..27337e556 100644--- a/web/messages/en.json+++ b/web/messages/en.json@@ -1408,13 +1408,13 @@"dismissed": "Dismissed"},"affected": {- "prompt": "{count} prompts",- "url": "{count} pages",- "citation": "{count} signals",- "keyword": "{count} keywords",- "topic": "{count} topics",+ "prompt": "{count, plural, one {# prompt} other {# prompts}}",+ "url": "{count, plural, one {# page} other {# pages}}",+ "citation": "{count, plural, one {# signal} other {# signals}}",+ "keyword": "{count, plural, one {# keyword} other {# keywords}}",+ "topic": "{count, plural, one {# topic} other {# topics}}","competitor": "Competitor",- "platform": "{count} platforms"+ "platform": "{count, plural, one {# platform} other {# platforms}}"},"range": {"7d": "7d",@@ -1465,7 +1465,7 @@"netChange": "net change","ofAffected": "of affected","fromStart": "from start",- "days": "{n} days",+ "days": "{n, plural, one {# day} other {# days}}","affected": "Affected","noAffected": "Nothing recorded.","tasks": "Tasks ({completed}/{total})",diff --git a/web/src/components/action-center/history-table.test.tsx b/web/src/components/action-center/history-table.test.tsxnew file mode 100644index 000000000..fde538b72--- /dev/null+++ b/web/src/components/action-center/history-table.test.tsx@@ -0,0 +1,131 @@+import { act, type ReactNode } from 'react';+import { createRoot } from 'react-dom/client';+import { NextIntlClientProvider } from 'next-intl';+import { afterEach, describe, expect, it, vi } from 'vitest';+import type { ActionHistoryItem, AffectedEntity } from '@/lib/action-center/history';+import messages from '../../../messages/en.json';++(+ globalThis as typeof globalThis & {+ IS_REACT_ACT_ENVIRONMENT: boolean;+ }+).IS_REACT_ACT_ENVIRONMENT = true;++vi.mock('@/i18n/navigation', () => ({+ useRouter: () => ({ push: vi.fn() }),+}));++import { HistoryTable } from './history-table';+import { HistoryDrawer } from './history-drawer';++const item = (overrides: Partial<ActionHistoryItem> = {}): ActionHistoryItem => ({+ id: 'action-id',+ actionNo: 1,+ kind: 'recover_visibility',+ type: 'recover',+ impact: 'high',+ status: 'completed',+ outcome: 'pending_measurement',+ payload: {},+ kpiKeys: [],+ sources: [],+ triggerSignals: [],+ affected: [],+ results: [],+ positionOutcome: null,+ tasks: [],+ assignee: null,+ createdAt: '2026-01-01T00:00:00.000Z',+ completedAt: '2026-01-05T00:00:00.000Z',+ timeToCloseDays: 4,+ ...overrides,+});++const counted = (type: AffectedEntity['type'], count: number): AffectedEntity => ({+ id: `${type}-count`,+ type,+ name: type,+ count,+});++async function render(node: ReactNode) {+ const container = document.createElement('div');+ document.body.append(container);+ const root = createRoot(container);+ await act(async () => {+ root.render(+ <NextIntlClientProvider locale="en" messages={messages} timeZone="UTC">+ {node}+ </NextIntlClientProvider>,+ );+ });+ return root;+}++/** The value printed under a drawer label, e.g. the badges under "Affected". */+function textAfterLabel(label: string) {+ const heading = Array.from(document.body.querySelectorAll('p')).find(+ (p) => p.textContent === label,+ );+ return heading?.nextElementSibling?.textContent;+}++afterEach(() => {+ document.body.replaceChildren();+});++describe('HistoryTable', () => {+ it.each([+ ['prompt', 1, '1 prompt'],+ ['prompt', 3, '3 prompts'],+ ['url', 1, '1 page'],+ ['url', 3, '3 pages'],+ ['citation', 1, '1 signal'],+ ['citation', 3, '3 signals'],+ ['keyword', 1, '1 keyword'],+ ['keyword', 3, '3 keywords'],+ ['topic', 1, '1 topic'],+ ['topic', 3, '3 topics'],+ ['platform', 1, '1 platform'],+ ['platform', 3, '3 platforms'],+ ] as const)('shows %s × %i as "%s" in the Affected column', async (type, count, text) => {+ const root = await render(+ <HistoryTable+ items={[item({ affected: [counted(type, count)] })]}+ selectedId={null}+ onSelect={() => {}}+ />,+ );+ const headers = Array.from(document.body.querySelectorAll('th')).map((th) => th.textContent);+ const cells = document.body.querySelectorAll('tbody td');+ expect(cells[headers.indexOf('Affected')]?.textContent).toBe(text);+ await act(async () => root.unmount());+ });+});++describe('HistoryDrawer', () => {+ it.each([+ [1, '1 signal'],+ [3, '3 signals'],+ ])('shows %i affected signal(s) as "%s"', async (count, text) => {+ const root = await render(+ <HistoryDrawer+ item={item({ affected: [counted('citation', count)] })}+ onOpenChange={() => {}}+ />,+ );+ expect(textAfterLabel('Affected')).toBe(text);+ await act(async () => root.unmount());+ });++ it.each([+ [1, '1 day'],+ [4, '4 days'],+ ])('shows a time to close of %i as "%s"', async (days, text) => {+ const root = await render(+ <HistoryDrawer item={item({ timeToCloseDays: days })} onOpenChange={() => {}} />,+ );+ expect(textAfterLabel('Time to Close')).toBe(text);+ await act(async () => root.unmount());+ });+});