: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
fix(ci): resolve three flaky test failures (#61244)
mendral-app[bot]8ef51cf0a370
diff --git a/frontend/src/lib/utils/eventUsageLogic.ts b/frontend/src/lib/utils/eventUsageLogic.tsindex ff64cd270e7f..fb78c61e07e8 100644--- a/frontend/src/lib/utils/eventUsageLogic.ts+++ b/frontend/src/lib/utils/eventUsageLogic.ts@@ -1134,7 +1134,7 @@ export const eventUsageLogic = kea<eventUsageLogicType>([let custom_properties_count = 0let posthog_properties_count = 0- for (const prop of Object.keys(person.properties)) {+ for (const prop of Object.keys(person.properties ?? {})) {if (PROPERTY_KEYS.includes(prop)) {posthog_properties_count += 1} else {@@ -1143,9 +1143,9 @@ export const eventUsageLogic = kea<eventUsageLogicType>([}const properties = {- properties_count: Object.keys(person.properties).length,- has_email: !!person.properties.email,- has_name: !!person.properties.name,+ properties_count: Object.keys(person.properties ?? {}).length,+ has_email: !!person.properties?.email,+ has_name: !!person.properties?.name,custom_properties_count,posthog_properties_count,}diff --git a/playwright/e2e/experiments/experiment-lifecycle.spec.ts b/playwright/e2e/experiments/experiment-lifecycle.spec.tsindex c9b9e3ef8ab7..4f08f40f9460 100644--- a/playwright/e2e/experiments/experiment-lifecycle.spec.ts+++ b/playwright/e2e/experiments/experiment-lifecycle.spec.ts@@ -88,13 +88,17 @@ test.describe('Experiment lifecycle', () => {await expect(page.locator('[aria-current="step"]', { hasText: 'Analytics' })).toBeVisible()await expect(page.getByText('How to measure impact?')).toBeVisible()+ // Wait for the step transition to fully settle before interacting+ const saveButton = page.getByRole('button', { name: 'Save as draft' })+ await expect(saveButton).toBeEnabled({ timeout: 10000 })+// This click occasionally doesn't produce a navigation. Possible causes:// the click not reaching React's event handler after the step transition,// or the backend response being slow. Retry until navigation confirms success.await expect(async () => {- await page.getByRole('button', { name: 'Save as draft' }).click()- await page.waitForURL(/\/experiments\/\d+$/, { timeout: 5000 })- }).toPass({ timeout: 30000 })+ await saveButton.click()+ await page.waitForURL(/\/experiments\/\d+$/, { timeout: 15000 })+ }).toPass({ timeout: 45000 })await expect(page.getByTestId('launch-experiment')).toBeVisible()// Verify the custom split is preserveddiff --git a/playwright/page-models/notebookPage.ts b/playwright/page-models/notebookPage.tsindex 62aed5e3fb7b..c0935b3536ad 100644--- a/playwright/page-models/notebookPage.ts+++ b/playwright/page-models/notebookPage.ts@@ -122,9 +122,25 @@ export class NotebookPage {async removeInsightNode(): Promise<void> {const node = this.insightNodes.first()- await node.click()+ // Click the top-left corner of the node to ensure ProseMirror treats it+ // as a NodeSelection (not a content selection inside the node)+ await node.click({ position: { x: 2, y: 2 } })await this.page.keyboard.press('Backspace')await this.page.keyboard.press('Backspace')++ // Wait briefly for ProseMirror to flush the DOM update before checking.+ // Without this, Locator.count() can see a stale snapshot and trigger+ // the fallback spuriously.+ await this.insightNodes.first().waitFor({ state: 'detached', timeout: 2000 }).catch(() => {})++ // If the node wasn't removed (click landed inside content), retry by+ // clicking the node and pressing Backspace again (avoids selectAll which+ // could wipe other notebook content)+ if ((await this.insightNodes.count()) > 0) {+ await this.insightNodes.first().click({ position: { x: 2, y: 2 } })+ await this.page.keyboard.press('Backspace')+ await this.page.keyboard.press('Backspace')+ }}async deleteFromList(notebookName: string): Promise<void> {diff --git a/products/product_analytics/frontend/insights/stickiness/StickinessBarChart/StickinessBarChart.test.tsx b/products/product_analytics/frontend/insights/stickiness/StickinessBarChart/StickinessBarChart.test.tsxindex b13e1fae5a7e..96de24ad1ffe 100644--- a/products/product_analytics/frontend/insights/stickiness/StickinessBarChart/StickinessBarChart.test.tsx+++ b/products/product_analytics/frontend/insights/stickiness/StickinessBarChart/StickinessBarChart.test.tsx@@ -41,9 +41,12 @@ describe('StickinessBarChart', () => {featureFlags: HOG_CHARTS_FLAG,})- await waitFor(() => {- expect(screen.getByTestId('stickiness-bar-graph')).toBeInTheDocument()- })+ await waitFor(+ () => {+ expect(screen.getByTestId('stickiness-bar-graph')).toBeInTheDocument()+ },+ { timeout: 5000 }+ )})it('renders one series per event', async () => {@@ -57,9 +60,12 @@ describe('StickinessBarChart', () => {featureFlags: HOG_CHARTS_FLAG,})- await waitFor(() => {- expect(screen.getByRole('img', { name: /chart with 2 data series/i })).toBeInTheDocument()- })+ await waitFor(+ () => {+ expect(screen.getByRole('img', { name: /chart with 2 data series/i })).toBeInTheDocument()+ },+ { timeout: 5000 }+ )})it('y-axis: renders percent ticks (legacy `${value.toFixed(1)}%` parity)', async () => {@@ -92,9 +98,12 @@ describe('StickinessBarChart', () => {featureFlags: HOG_CHARTS_FLAG,})- await waitFor(() => {- expect(screen.getByTestId('insight-empty-state')).toBeInTheDocument()- })+ await waitFor(+ () => {+ expect(screen.getByTestId('insight-empty-state')).toBeInTheDocument()+ },+ { timeout: 5000 }+ )expect(screen.queryByRole('img', { name: /chart with/i })).not.toBeInTheDocument()})@@ -103,9 +112,12 @@ describe('StickinessBarChart', () => {await chart.clickAtIndex(2)- await waitFor(() => {- expect(personsModal.get()).toBeInTheDocument()- })+ await waitFor(+ () => {+ expect(personsModal.get()).toBeInTheDocument()+ },+ { timeout: 5000 }+ )expect(personsModal.title()).toMatch(/stickiness on day 3/i)expect(personsModal.title()).toMatch(/Pageview/i)})@@ -120,9 +132,12 @@ describe('StickinessBarChart', () => {await chart.clickAtIndex(2)- await waitFor(() => {- expect(onDataPointClick).toHaveBeenCalledTimes(1)- })+ await waitFor(+ () => {+ expect(onDataPointClick).toHaveBeenCalledTimes(1)+ },+ { timeout: 5000 }+ )const [seriesArg] = onDataPointClick.mock.calls[0]expect(seriesArg.day).toBe(3)expect(personsModal.get()).not.toBeInTheDocument()diff --git a/products/product_analytics/frontend/insights/trends/TrendsLifecycleChart/TrendsLifecycleChart.test.tsx b/products/product_analytics/frontend/insights/trends/TrendsLifecycleChart/TrendsLifecycleChart.test.tsxindex 4285081e7a54..3c326fa4f1ef 100644--- a/products/product_analytics/frontend/insights/trends/TrendsLifecycleChart/TrendsLifecycleChart.test.tsx+++ b/products/product_analytics/frontend/insights/trends/TrendsLifecycleChart/TrendsLifecycleChart.test.tsx@@ -70,12 +70,18 @@ describe('TrendsLifecycleChart', () => {mocks: { additionalMockResponses: lifecycleMocks },})- await waitFor(() => {- expect(screen.getByTestId('trend-lifecycle-graph')).toBeInTheDocument()- })- await waitFor(() => {- expect(screen.getByRole('img', { name: /chart with 4 data series/i })).toBeInTheDocument()- })+ await waitFor(+ () => {+ expect(screen.getByTestId('trend-lifecycle-graph')).toBeInTheDocument()+ },+ { timeout: 5000 }+ )+ await waitFor(+ () => {+ expect(screen.getByRole('img', { name: /chart with 4 data series/i })).toBeInTheDocument()+ },+ { timeout: 5000 }+ )})it('shows the shortened lifecycle status in the tooltip rows', async () => {@@ -127,9 +133,12 @@ describe('TrendsLifecycleChart', () => {},})- await waitFor(() => {- expect(screen.getByTestId('insight-empty-state')).toBeInTheDocument()- })+ await waitFor(+ () => {+ expect(screen.getByTestId('insight-empty-state')).toBeInTheDocument()+ },+ { timeout: 5000 }+ )})it('renders the legend items in the same order as the rendered series', async () => {@@ -166,8 +175,11 @@ describe('TrendsLifecycleChart', () => {// Without the flag the hog-charts data-attr is never rendered; the Chart.js LineGraph// renders a <canvas> instead.- await waitFor(() => {- expect(screen.queryByTestId('trend-lifecycle-graph')).not.toBeInTheDocument()- })+ await waitFor(+ () => {+ expect(screen.queryByTestId('trend-lifecycle-legend')).not.toBeInTheDocument()+ },+ { timeout: 5000 }+ )})})