: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(aio): stabilize flaky JSON viewer tests (#67455)
Raúl Negrón-Otero5d14c0892a58
diff --git a/products/ai_observability/frontend/ConversationDisplay/ConversationMessagesDisplay.test.tsx b/products/ai_observability/frontend/ConversationDisplay/ConversationMessagesDisplay.test.tsxindex 0e3a91a4c316..5011fbd7808c 100644--- a/products/ai_observability/frontend/ConversationDisplay/ConversationMessagesDisplay.test.tsx+++ b/products/ai_observability/frontend/ConversationDisplay/ConversationMessagesDisplay.test.tsx@@ -12,6 +12,10 @@ import {LLMMessageDisplay,} from './ConversationMessagesDisplay'+// react-json-view is loaded via React.lazy, so the first render suspends on a code-split chunk.+// Under CI contention that resolve can exceed waitFor's 1s default, so give it headroom.+const JSON_VIEWER_TIMEOUT_MS = 5000+describe('LLMMessageDisplay', () => {beforeEach(() => {initKeaTests()@@ -70,9 +74,12 @@ describe('LLMMessageDisplay', () => {</Provider>)- await waitFor(() => {- expect(container.querySelector('.react-json-view')).toBeInTheDocument()- })+ await waitFor(+ () => {+ expect(container.querySelector('.react-json-view')).toBeInTheDocument()+ },+ { timeout: JSON_VIEWER_TIMEOUT_MS }+ )expect(container.textContent).toContain(expectedSubstring)})diff --git a/products/ai_observability/frontend/components/JSONValueDisplay.test.tsx b/products/ai_observability/frontend/components/JSONValueDisplay.test.tsxindex a1e44b17a91d..11658e3b34db 100644--- a/products/ai_observability/frontend/components/JSONValueDisplay.test.tsx+++ b/products/ai_observability/frontend/components/JSONValueDisplay.test.tsx@@ -7,6 +7,10 @@ import { initKeaTests } from '~/test/init'import { JSONValueDisplay } from './JSONValueDisplay'+// react-json-view is loaded via React.lazy, so the first render suspends on a code-split chunk.+// Under CI contention that resolve can exceed waitFor's 1s default, so give it headroom.+const JSON_VIEWER_TIMEOUT_MS = 5000+describe('JSONValueDisplay', () => {beforeEach(() => {initKeaTests()@@ -27,9 +31,12 @@ describe('JSONValueDisplay', () => {it('renders JSON arrays with the JSON viewer', async () => {const { container } = renderValue([{ role: 'user', content: [{ type: 'text', text: 'hello' }] }])- await waitFor(() => {- expect(container.querySelector('.react-json-view')).toBeInTheDocument()- })+ await waitFor(+ () => {+ expect(container.querySelector('.react-json-view')).toBeInTheDocument()+ },+ { timeout: JSON_VIEWER_TIMEOUT_MS }+ )expect(container.textContent).toContain('role')expect(container.textContent).toContain('hello')})@@ -37,9 +44,12 @@ describe('JSONValueDisplay', () => {it('parses stringified JSON arrays before rendering', async () => {const { container } = renderValue(JSON.stringify([{ role: 'user', content: 'hello' }]))- await waitFor(() => {- expect(container.querySelector('.react-json-view')).toBeInTheDocument()- })+ await waitFor(+ () => {+ expect(container.querySelector('.react-json-view')).toBeInTheDocument()+ },+ { timeout: JSON_VIEWER_TIMEOUT_MS }+ )expect(container.textContent).toContain('role')expect(container.textContent).toContain('hello')})