From c7053c2c51a40811f053970218cbb6d1e7119669 Mon Sep 17 00:00:00 2001 From: chan Date: Wed, 27 May 2026 13:42:50 +0900 Subject: [PATCH] fix(userfront-e2e): fix widespread test failures in non-Chromium browsers - Add COOP/COEP headers to serve script for Flutter WASM compatibility (SharedArrayBuffer) - Update CI workflow to install all Playwright browsers for userfront-e2e - Fix command reporting consistency in adminfront test script --- .gitea/workflows/code_check.yml | 6 +++--- scripts/run_adminfront_ci_tests.sh | 4 ++-- userfront-e2e/scripts/serve-userfront-build.mjs | 6 ++++++ 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.gitea/workflows/code_check.yml b/.gitea/workflows/code_check.yml index 2f8ce7d1..ab1a9cf5 100644 --- a/.gitea/workflows/code_check.yml +++ b/.gitea/workflows/code_check.yml @@ -423,7 +423,7 @@ jobs: run: | set +e cd userfront-e2e - npx playwright install --with-deps chromium 2>&1 | tee ../reports/userfront-e2e-provision.log + npx playwright install --with-deps 2>&1 | tee ../reports/userfront-e2e-provision.log provision_exit_code=${PIPESTATUS[0]} cd .. set -e @@ -438,7 +438,7 @@ jobs: echo "- Exit Code: \`$provision_exit_code\`" echo echo "## Command" - echo "\`cd userfront-e2e && npx playwright install --with-deps chromium\`" + echo "\`cd userfront-e2e && npx playwright install --with-deps\`" echo echo "## Provision Log Tail (last 200 lines)" echo '```text' @@ -470,7 +470,7 @@ jobs: echo "1. \`cd userfront-e2e\`" echo "2. \`npm ci\`" echo "3. \`cd ../userfront && flutter build web --wasm --release\`" - echo "4. \`cd ../userfront-e2e && npx playwright install --with-deps chromium\`" + echo "4. \`cd ../userfront-e2e && npx playwright install --with-deps\`" echo "5. \`npm test\`" echo echo "## Log Tail (last 200 lines)" diff --git a/scripts/run_adminfront_ci_tests.sh b/scripts/run_adminfront_ci_tests.sh index ff76622d..5ef28400 100755 --- a/scripts/run_adminfront_ci_tests.sh +++ b/scripts/run_adminfront_ci_tests.sh @@ -217,7 +217,7 @@ if [ "$install_exit_code" -ne 0 ]; then echo "- Exit Code: \`$install_exit_code\`" echo echo "## Command" - echo "\`cd adminfront && if [ \"$reuse_seed_node_modules\" -eq 0 ]; then if ! command -v pnpm >/dev/null 2>&1; then npm install -g pnpm; fi && pnpm install -C ../common --no-frozen-lockfile --store-dir \"\$TMPDIR/pnpm-store\"; fi\`" + echo "\`cd adminfront && if [ \"$reuse_seed_node_modules\" -eq 0 ]; then if ! command -v pnpm >/dev/null 2>&1; then npm install -g pnpm; fi && pnpm install --no-frozen-lockfile --store-dir \"\$TMPDIR/pnpm-store\"; fi\`" echo echo "## Install Log Tail (last 200 lines)" echo '```text' @@ -284,7 +284,7 @@ if [ "$test_exit_code" -ne 0 ]; then echo echo "## Commands" echo "1. \`cd adminfront\`" - echo "2. \`if [ \"$reuse_seed_node_modules\" -eq 0 ]; then if ! command -v pnpm >/dev/null 2>&1; then npm install -g pnpm; fi && pnpm install -C ../common --no-frozen-lockfile --store-dir \"\$TMPDIR/pnpm-store\"; fi\`" + echo "2. \`if [ \"$reuse_seed_node_modules\" -eq 0 ]; then if ! command -v pnpm >/dev/null 2>&1; then npm install -g pnpm; fi && pnpm install --no-frozen-lockfile --store-dir \"\$TMPDIR/pnpm-store\"; fi\`" echo "3. \`${playwright_install_desc}\`" echo "4. \`npx playwright test\`" echo diff --git a/userfront-e2e/scripts/serve-userfront-build.mjs b/userfront-e2e/scripts/serve-userfront-build.mjs index 76f52107..2da87c06 100644 --- a/userfront-e2e/scripts/serve-userfront-build.mjs +++ b/userfront-e2e/scripts/serve-userfront-build.mjs @@ -81,6 +81,12 @@ const server = createServer((req, res) => { res.setHeader('Last-Modified', stats.mtime.toUTCString()); res.setHeader('Cache-Control', cacheControl); res.setHeader('Vary', 'Accept-Encoding'); + + // Flutter WASM requires SharedArrayBuffer which needs these COOP/COEP headers + // to be cross-origin isolated in most modern browsers (WebKit, Firefox, etc.) + res.setHeader('Cross-Origin-Opener-Policy', 'same-origin'); + res.setHeader('Cross-Origin-Embedder-Policy', 'require-corp'); + if (servedPath === brotliPath) { res.setHeader('Content-Encoding', 'br'); }