MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / scenarioBoundary

Function scenarioBoundary

apps/api/e2e/session-e2e.ts:115–142  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

113}
114
115async function scenarioBoundary() {
116 scenario('boundary split → first session closes, second opens');
117 const ip = `10.${(runId >> 16) & 255}.2.${runId & 255 || 1}`;
118
119 const a = await screenView(ip, '/x');
120 console.log(` …waiting ${IDLE_WAIT_MS}ms so the next event crosses the boundary`);
121 await sleep(IDLE_WAIT_MS);
122 const b = await screenView(ip, '/y');
123
124 check(
125 'second event opened a NEW session id',
126 a.sessionId !== b.sessionId && !!b.sessionId,
127 `${a.sessionId} vs ${b.sessionId}`
128 );
129
130 const startsA = await pollUntil(async () =>
131 (await countByName([a.sessionId], 'session_start')) > 0 ? true : null
132 );
133 check('clickhouse: session_start for first session', !!startsA);
134 const startsB = await pollUntil(async () =>
135 (await countByName([b.sessionId], 'session_start')) > 0 ? true : null
136 );
137 check('clickhouse: session_start for second session', !!startsB);
138 const endsA = await pollUntil(async () =>
139 (await countByName([a.sessionId], 'session_end')) > 0 ? true : null
140 );
141 check('clickhouse: first session got a session_end', !!endsA);
142}
143
144async function scenarioNonScreenViewFirst() {
145 scenario('session opened by a non-screen_view event');

Callers 1

mainFunction · 0.85

Calls 7

scenarioFunction · 0.90
screenViewFunction · 0.90
sleepFunction · 0.90
checkFunction · 0.90
pollUntilFunction · 0.90
countByNameFunction · 0.90
logMethod · 0.45

Tested by

no test coverage detected