From 9483310630bd7d562740637ef9b5b6232964008b Mon Sep 17 00:00:00 2001 From: Hadeel Al-Ammari Date: Sat, 5 Sep 2026 17:35:36 +0000 Subject: [PATCH 1/2] Refactor session tab switch destination checks --- .../timeline/session-tab-switch-metrics.ts | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/packages/app/e2e/performance/timeline/session-tab-switch-metrics.ts b/packages/app/e2e/performance/timeline/session-tab-switch-metrics.ts index 5298b9b0..ea1f888e 100644 --- a/packages/app/e2e/performance/timeline/session-tab-switch-metrics.ts +++ b/packages/app/e2e/performance/timeline/session-tab-switch-metrics.ts @@ -38,13 +38,27 @@ export function classifySessionSwitch(samples: SessionSwitchSample[]) { } } +function hasValidBottomAnchor(sample: SessionSwitchSample) { + if (sample.bottomAnchorRequired === false) { + return true + } + + return Math.abs(sample.bottomErrorPx ?? Infinity) <= 1 +} + export function isCorrectDestination(sample: SessionSwitchSample) { + const hasDestination = sample.destination.length > 0 + const hasNoSource = sample.source.length === 0 + const isLastSample = sample.last + const requiredPartIsVisible = sample.requiredPartVisible !== false + const bottomAnchorIsValid = hasValidBottomAnchor(sample) + return ( - sample.destination.length > 0 && - sample.source.length === 0 && - sample.last && - sample.requiredPartVisible !== false && - (sample.bottomAnchorRequired === false || Math.abs(sample.bottomErrorPx ?? Infinity) <= 1) + hasDestination && + hasNoSource && + isLastSample && + requiredPartIsVisible && + bottomAnchorIsValid ) } From a9a86ada415c7f215bfbd20fc91874df4cdb760f Mon Sep 17 00:00:00 2001 From: Hadeel Al-Ammari Date: Sun, 6 Sep 2026 00:46:18 +0000 Subject: [PATCH 2/2] Simplify session tab switch destination checks --- .../timeline/session-tab-switch-metrics.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/packages/app/e2e/performance/timeline/session-tab-switch-metrics.ts b/packages/app/e2e/performance/timeline/session-tab-switch-metrics.ts index ea1f888e..5dd34d15 100644 --- a/packages/app/e2e/performance/timeline/session-tab-switch-metrics.ts +++ b/packages/app/e2e/performance/timeline/session-tab-switch-metrics.ts @@ -53,13 +53,11 @@ export function isCorrectDestination(sample: SessionSwitchSample) { const requiredPartIsVisible = sample.requiredPartVisible !== false const bottomAnchorIsValid = hasValidBottomAnchor(sample) - return ( - hasDestination && - hasNoSource && - isLastSample && - requiredPartIsVisible && - bottomAnchorIsValid - ) + if (!hasDestination || !hasNoSource || !isLastSample || !requiredPartIsVisible) { + return false + } + + return bottomAnchorIsValid } export function isStableSessionSwitch(samples: SessionSwitchSample[]) {