Skip to content

Commit 930478a

Browse files
committed
test(platform): read the rollout where the handoff reads it
waitForRollout reads the surface API, whose route bundle has its own AppConfig cache. The layout's bundle still held the rollback for one more read, so a single navigation right after the API agreed stayed on /o. The proxy's zone verdict was never negative in that phase.
1 parent 3444b1b commit 930478a

2 files changed

Lines changed: 18 additions & 5 deletions

File tree

‎apps/sim/platform/checks/live/rollout/per-organization.spec.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ import {
66
signIn,
77
signInAsAdmin,
88
} from '@/platform/checks/live/session'
9-
import { ROLLOUT_TEST_TIMEOUT_MS, waitForRollout } from '@/platform/checks/live/support/rollout'
9+
import {
10+
expectHandoff,
11+
ROLLOUT_TEST_TIMEOUT_MS,
12+
waitForRollout,
13+
} from '@/platform/checks/live/support/rollout'
1014
import {
1115
expectMainAppSurface,
1216
expectPlatformSurface,
@@ -24,8 +28,7 @@ test('a targeted organization is handed to the Platform', async ({ page }) => {
2428
const route = `/o/${organizationId()}/home`
2529
await signInAsAdmin(page, route)
2630
await waitForRollout(page, true)
27-
await page.goto(route)
28-
await expect(page).toHaveURL(/\/org\/home/)
31+
await expectHandoff(page, route, /\/org\/home/)
2932
await expectPlatformSurface(page)
3033
})
3134

‎apps/sim/platform/checks/live/support/rollout.ts‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import { requireEnv } from '@/platform/checks/live/session'
33

44
/**
55
* Longer than a poll of AppConfig, whose in-process answer holds for 30s and is served once more
6-
* while it refreshes, so a change reaches the app at some point in this window.
6+
* while it refreshes, so a change reaches the app at some point in this window. Next bundles the
7+
* module into each route, so each holds its own answer on its own clock: a route agreeing says
8+
* nothing about another, and a page has to be read until it does.
79
*/
810
const ROLLOUT_PROPAGATION_MS = 100_000
911

@@ -17,7 +19,7 @@ export async function targetOrganizations(request: APIRequestContext, orgIds: re
1719
expect(response.status()).toBe(204)
1820
}
1921

20-
/** Waits until the main app answers `expected` for the signed-in viewer's organization. */
22+
/** Waits until the surface API answers `expected` for the signed-in viewer's organization. */
2123
export async function waitForRollout(page: Page, expected: boolean) {
2224
await expect
2325
.poll(
@@ -30,3 +32,11 @@ export async function waitForRollout(page: Page, expected: boolean) {
3032
)
3133
.toBe(expected)
3234
}
35+
36+
/** Opens `route` until this page's own read of the rollout hands it to the Platform. */
37+
export async function expectHandoff(page: Page, route: string, destination: RegExp) {
38+
await expect(async () => {
39+
await page.goto(route)
40+
await expect(page).toHaveURL(destination, { timeout: 2_000 })
41+
}).toPass({ timeout: ROLLOUT_PROPAGATION_MS })
42+
}

0 commit comments

Comments
 (0)