Skip to content

Commit

Permalink
e2e: Further fix flaky Twitter test (#95672)
Browse files Browse the repository at this point in the history
PR #95579 attempted to adjust the test to accept both the expected
iframe and the fallback link produced when Twitter's API is flaky.
Unfortunately the way Playwright interpreted the code is like
`iframe > ( tweet or link )` rather than `( iframe > tweet ) or link` as
intended, so it's still not finding the link.

Fall back to using `Promise.any()` to combine the two locators instead,
like we do in a bunch of other places.
  • Loading branch information
anomiex authored Oct 24, 2024
1 parent 7b5dcd6 commit aeb8409
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/calypso-e2e/src/lib/blocks/block-flows/twitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ export class TwitterBlockFlow implements BlockFlow {
// In most cases, the iframe will render, so look for that.
const iframeTweetLocator = context.page
.frameLocator( selectors.publishedTwitterIframe )
.locator( `text=${ this.configurationData.expectedTweetText }` );
.locator( `text=${ this.configurationData.expectedTweetText }` )
.first();

// However, sometimes only the bare link renders, so we need to check for that fallback.
const bareTweetLinkLocator = context.page.locator( selectors.publishedTwitterBareLink );
const bareTweetLinkLocator = context.page.locator( selectors.publishedTwitterBareLink ).first();

const tweetLocator = iframeTweetLocator.or( bareTweetLinkLocator ).first();
await tweetLocator.waitFor();
await Promise.any( [ iframeTweetLocator.waitFor(), bareTweetLinkLocator.waitFor() ] );
}
}

0 comments on commit aeb8409

Please sign in to comment.