From 0d4d54881ec2571ccb327ac744472b15c5eecd4e Mon Sep 17 00:00:00 2001 From: Shane Osbourne Date: Thu, 1 Aug 2024 10:52:45 +0100 Subject: [PATCH] remove flakiness from release-notes tests --- packages/special-pages/tests/page-objects/release-notes.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/special-pages/tests/page-objects/release-notes.js b/packages/special-pages/tests/page-objects/release-notes.js index d4e80a723..feb4fb781 100644 --- a/packages/special-pages/tests/page-objects/release-notes.js +++ b/packages/special-pages/tests/page-objects/release-notes.js @@ -96,6 +96,10 @@ export class ReleaseNotesPage { * @param {boolean} [options.privacyPro] */ async sendSubscriptionMessage (messageType, options) { + // Wait for the subscription handler to appear before trying to simulate push events. + // This prevents a race condition where playwright is sending data before `.subscribe` was called + await this.page.waitForFunction(() => 'onUpdate' in window && typeof window.onUpdate === 'function') + const data = options?.privacyPro ? { ...sampleData[messageType] } : { ...sampleData[messageType], releaseNotesPrivacyPro: null }