Skip to content

test(video-player): wait for widget after tab clicks, fix poster race#2232

Open
samuelreichert wants to merge 1 commit into
mainfrom
fix/video-player-e2e-flakiness
Open

test(video-player): wait for widget after tab clicks, fix poster race#2232
samuelreichert wants to merge 1 commit into
mainfrom
fix/video-player-e2e-flakiness

Conversation

@samuelreichert
Copy link
Copy Markdown
Contributor

Pull request type

Test related change (New E2E test, test automation, etc.)


Description

Fixes intermittent nightly failures in video-player-web E2E tests introduced after the e2e-reliability-and-performance merge.

Three root causes:

  1. Tab page tests — after .click() on a tab, tests asserted toBeVisible() on iframes immediately. Mendix renders tab content asynchronously; the fixture's waitForMendixApp only patches page.goto, not tab navigation clicks. Added waitForWidget after each tab click.

  2. Aspect ratio test — same tab-click race: boundingBox() called on elements in tabs 2 and 3 without waiting for them to be present in the DOM.

  3. Poster screenshotpage.evaluate with a standalone new Image() resolves when the image loads into memory, not when the <video> element has painted the poster frame. Switched to videoLocator.evaluate(el => ...) to tie the wait to the actual element. Also added scrollIntoViewIfNeeded so the widget is in viewport before screenshotting.

@samuelreichert samuelreichert requested a review from a team as a code owner May 26, 2026 14:21
@samuelreichert samuelreichert force-pushed the fix/video-player-e2e-flakiness branch from e3a1a96 to 5728e28 Compare May 26, 2026 14:24
@github-actions
Copy link
Copy Markdown

AI Code Review

⚠️ Approved with suggestions — low-severity items only, safe to merge


What was reviewed

File Change
packages/pluggableWidgets/video-player-web/e2e/VideoPlayer.spec.js Replaced waitForDataReady with waitForWidget in tab tests; replaced page.evaluate poster-wait approach with videoLocator.evaluate; added scrollIntoViewIfNeeded before screenshot

Skipped (out of scope): dist/, pnpm-lock.yaml

CI checks were unavailable during this review (command required manual approval). No failing checks were observed based on available information.


Findings

⚠️ Low — afterEach session logout not present

File: packages/pluggableWidgets/video-player-web/e2e/VideoPlayer.spec.js
Note: The skill guidelines require an afterEach session logout in every E2E file to avoid hitting Mendix's 5-session limit in CI. However, fixtures.mjs shows the page fixture already handles this automatically — await page.evaluate(() => window.mx?.session?.logout?.()).catch(() => {}) is called in the mendixSession worker-scoped teardown. This is fine as-is, but is worth documenting in the test file or the E2E guidelines to avoid confusion for future contributors who look for the explicit afterEach block.


⚠️ Low — Poster-load guard resolves on image decode, not on <video> paint

File: packages/pluggableWidgets/video-player-web/e2e/VideoPlayer.spec.js line 122–131
Note: The replacement approach — using videoLocator.evaluate to hook Image.onload — is significantly better than the previous waitForDataReady (which just polled networkidle). However, Image.onload fires when the image is fully decoded in memory, which is still not a guarantee that the browser has composited the poster frame into the video element's paint layer before Playwright takes the screenshot. A short waitForTimeout is an anti-pattern, but consider whether page.waitForFunction polling a canvas draw or an explicit page.clock.runFor(100) in the test env would be more deterministic if this screenshot continues to be flaky. This is a low-risk suggestion for a future iteration, not a blocker.


Positives

  • Correctly switched from waitForDataReady (networkidle-based) to waitForWidget (locator-assertion-based) — this matches the E2E guidelines' preference for Playwright locator assertions over hardcoded waits.
  • All tab-click tests now have a waitForWidget call immediately after .click(), eliminating the race condition between Mendix async tab rendering and the subsequent toBeVisible assertions.
  • Selectors consistently use .mx-name-* pattern throughout — correct per the selector preference order in guidelines.
  • Aspect ratio test was correctly updated to replace three toBeVisible polls with waitForWidget, ensuring DOM readiness before boundingBox() is called.
  • PR description is detailed and accurately identifies three separate root causes with clear before/after reasoning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant