/* eslint-env jest */ import { act } from 'react'; import { createRoot, type Root } from 'react-dom/client'; import { PromptsSummaryStrip } from '../TrackedPromptsList'; import type { PromptMetricTrend, PromptResponse, } from '../../../service/visibility/visibility.interface'; ( globalThis as unknown as { IS_REACT_ACT_ENVIRONMENT: boolean } ).IS_REACT_ACT_ENVIRONMENT = true; jest.mock('../../../env', () => ({ recomaze_ai_personalization_env: {} })); let root: Root; let host: HTMLDivElement; beforeEach(() => { host = document.createElement('div'); document.body.appendChild(host); root = createRoot(host); }); afterEach(() => { act(() => root.unmount()); host.remove(); }); const prompt = (id: string): PromptResponse => ({ prompt_id: id, enabled: true, prompt_text: id }) as PromptResponse; const trend = (id: string, score: number): PromptMetricTrend => ({ prompt_id: id, current_week: '2026-W38', current_score: score, delta_score: null, status: 'stable' as PromptMetricTrend['status'], series: [], }); it("names the prompts' average apart from the brand's Visibility score", async () => { await act(async () => { root.render( ); }); expect(host.textContent).toContain('Avg prompt score'); expect(host.textContent).toContain('11 / 100'); expect(host.textContent).not.toContain('Avg visibility score'); });