From 753258ccb463ff0c1caac15cf61e3273c09eb573 Mon Sep 17 00:00:00 2001 From: Maurizio Casimirri Date: Wed, 10 Jan 2024 18:32:13 +0100 Subject: [PATCH] test(e2e): wait for new telemetry events COMPASS-7573 (#5321) test(e2e): wait for new telemetry events --- .../commands/listen-for-telemetry-events.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/compass-e2e-tests/helpers/commands/listen-for-telemetry-events.ts b/packages/compass-e2e-tests/helpers/commands/listen-for-telemetry-events.ts index 31d406be7b1..7609c04c3e0 100644 --- a/packages/compass-e2e-tests/helpers/commands/listen-for-telemetry-events.ts +++ b/packages/compass-e2e-tests/helpers/commands/listen-for-telemetry-events.ts @@ -13,8 +13,18 @@ export async function listenForTelemetryEvents( return newEvents.find((entry) => entry.event === eventName); } - return (eventName) => { - const ev = lookupNewEvent(eventName); + return async (eventName) => { + let ev: { properties?: any } | undefined; + + await browser.waitUntil(() => { + ev = lookupNewEvent(eventName); + return !!ev; + }); + + if (!ev) { + return; + } + const properties = { ...ev.properties }; delete properties.compass_version; delete properties.compass_full_version;