Skip to content

Fix API test runner to use old headless Chromium mode for WebGL support#472

Open
julianharty wants to merge 1 commit intoflipcomputing:mainfrom
commercetest:main
Open

Fix API test runner to use old headless Chromium mode for WebGL support#472
julianharty wants to merge 1 commit intoflipcomputing:mainfrom
commercetest:main

Conversation

@julianharty
Copy link
Contributor

@julianharty julianharty commented Mar 26, 2026

Playwright 1.44+ switched to a new headless shell binary that drops WebGL support. Tests that use Babylon.js (e.g. babylon, objects, materials) were failing locally on macOS with "WebGL not supported" because flock.scene was never initialised.

Switching to headless:false with --headless=old restores the original headless Chromium mode which retains WebGL/WebGL2 support. This is consistent with what CI has been getting implicitly via the older Playwright build (v1193) it uses.

Also fix tests/tests.html to load mocha and chai from local node_modules instead of unpkg.com CDN, which was blocked by the Vite dev server's Content-Security-Policy. Mocha is loaded as a classic script (UMD, sets window.mocha) and chai is imported as an ES module and assigned to window.chai.

Summary by CodeRabbit

  • Tests

    • Updated browser testing configuration to support WebGL functionality
    • Switched test dependencies to load locally from node_modules instead of CDN
  • Chores

    • Refined test environment setup for improved reliability

Playwright 1.44+ switched to a new headless shell binary that drops WebGL
support. Tests that use Babylon.js (e.g. babylon, objects, materials) were
failing locally on macOS with "WebGL not supported" because flock.scene was
never initialised.

Switching to headless:false with --headless=old restores the original headless
Chromium mode which retains WebGL/WebGL2 support. This is consistent with what
CI has been getting implicitly via the older Playwright build (v1193) it uses.

Also fix tests/tests.html to load mocha and chai from local node_modules
instead of unpkg.com CDN, which was blocked by the Vite dev server's
Content-Security-Policy. Mocha is loaded as a classic script (UMD, sets
window.mocha) and chai is imported as an ES module and assigned to window.chai.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link

coderabbitai bot commented Mar 26, 2026

📝 Walkthrough

Walkthrough

The PR updates the test infrastructure by switching the Playwright browser launch configuration to legacy headless mode for WebGL support and migrating test framework dependencies from CDN-hosted to locally-installed packages via node_modules.

Changes

Cohort / File(s) Summary
Browser Launch Configuration
scripts/run-api-tests.mjs
Modified Playwright Chromium launch to disable headless mode and explicitly pass --headless=old flag via args instead of standard headless mode, intended to preserve WebGL support during testing.
Test Framework Dependencies
tests/tests.html
Replaced CDN-hosted Mocha and Chai scripts with local node_modules versions; added Mocha CSS link tag and switched Chai to inline ES module import from local packages.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 Local packages hop into place,
Headless mode takes a slower pace,
WebGL now shines with --headless=old,
Tests run fast, no CDN delays so cold! 🚀

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the primary change in the pull request: fixing the API test runner to use old headless Chromium mode for WebGL support, which directly matches the main modification in scripts/run-api-tests.mjs.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
tests/tests.html (1)

78-78: Move <link> stylesheet to <head> for HTML validity.

The Mocha stylesheet link is placed in the <body> after the canvas element. While browsers render it, this isn't valid HTML5 and can cause a brief flash of unstyled content (FOUC) when mocha elements first appear.

♻️ Suggested fix

Move line 78 into the <head> section (e.g., after line 11):

     </style>
+    <link rel="stylesheet" href="/node_modules/mocha/mocha.css" />
   </head>
   <body>

And remove line 78 from its current location in the body.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/tests.html` at line 78, The <link rel="stylesheet"
href="/node_modules/mocha/mocha.css" /> tag is currently in the <body> after the
canvas and needs to be moved into the <head> for valid HTML and to avoid FOUC;
remove the duplicate from the body and insert that exact <link> element into the
<head> section (for example, after existing head meta/styles) so the Mocha
stylesheet loads before body content renders.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@tests/tests.html`:
- Line 78: The <link rel="stylesheet" href="/node_modules/mocha/mocha.css" />
tag is currently in the <body> after the canvas and needs to be moved into the
<head> for valid HTML and to avoid FOUC; remove the duplicate from the body and
insert that exact <link> element into the <head> section (for example, after
existing head meta/styles) so the Mocha stylesheet loads before body content
renders.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ccbc03bd-3da1-4e86-b69f-23b3f7a216aa

📥 Commits

Reviewing files that changed from the base of the PR and between 5abfa3d and feea2d4.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (2)
  • scripts/run-api-tests.mjs
  • tests/tests.html

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant