Skip to content

: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.

test(customer-analytics): de-flake accounts tile limit test (#61495)

Raúl Negrón-Otero7b23261dd57d
diff --git a/products/customer_analytics/frontend/components/Accounts/accountsOverviewTilesLogic.test.ts b/products/customer_analytics/frontend/components/Accounts/accountsOverviewTilesLogic.test.ts
index 9a3fe8f7ae75..228b1152f7e9 100644
--- a/products/customer_analytics/frontend/components/Accounts/accountsOverviewTilesLogic.test.ts
+++ b/products/customer_analytics/frontend/components/Accounts/accountsOverviewTilesLogic.test.ts
@@ -1,5 +1,3 @@
-import { expectLogic } from 'kea-test-utils'
-
import { NodeKind } from '~/queries/schema/schema-general'
import { initKeaTests } from '~/test/init'
@@ -199,11 +197,13 @@ describe('addTile limit', () => {
logic.unmount()
})
- it(`stops adding tiles once ${MAX_ACCOUNTS_OVERVIEW_TILES} exist`, async () => {
+ // addTile is a pure reducer — assert synchronously. toFinishAllListeners() would
+ // wait on the connected logics' on-mount loaders (a global pending-promise map),
+ // which made this flaky whenever those XHRs were slow to settle.
+ it(`stops adding tiles once ${MAX_ACCOUNTS_OVERVIEW_TILES} exist`, () => {
for (let i = 0; i < MAX_ACCOUNTS_OVERVIEW_TILES + 2; i++) {
logic.actions.addTile({ label: `Tile ${i}`, metric: { type: 'count' } })
}
- await expectLogic(logic).toFinishAllListeners()
expect(logic.values.tiles).toHaveLength(MAX_ACCOUNTS_OVERVIEW_TILES)
})
})