[core] refactor: replace XMLHttpRequest with fetch and migrate e2e tests to Playwright (#3950)

### 1. Replace `XMLHttpRequest` with the modern `fetch` API for loading
translation files

#### Changes
- **translator.js**: Use `fetch` with `async/await` instead of XHR
callbacks
- **loader.js**: Align URL handling and add error handling (follow-up to
fetch migration)
- **Tests**: Update infrastructure for `fetch` compatibility

#### Benefits
- Modern standard API
- Cleaner, more readable code
- Better error handling and fallback mechanisms

### 2. Migrate e2e tests to Playwright

This wasn't originally planned for this PR, but is related. While
investigating suspicious log entries which surfaced after the fetch
migration I kept running into JSDOM’s limitations. That pushed me to
migrate the E2E suite to Playwright instead.

#### Changes
- switch e2e harness to Playwright (`tests/e2e/helpers/global-setup.js`)
- rewrite specs to use Playwright locators + shared `expectTextContent`
- install Chromium via `npx playwright install --with-deps` in CI

#### Benefits
- much closer to real browser behaviour
- and no more fighting JSDOM’s quirks
This commit is contained in:
Kristjan ESPERANTO
2025-11-08 21:59:05 +01:00
committed by GitHub
parent 2b08288346
commit f29f424a62
31 changed files with 508 additions and 361 deletions

View File

@@ -4,6 +4,7 @@ import {flatConfigs as importX} from "eslint-plugin-import-x";
import js from "@eslint/js";
import jsdocPlugin from "eslint-plugin-jsdoc";
import packageJson from "eslint-plugin-package-json";
import playwright from "eslint-plugin-playwright";
import stylistic from "@stylistic/eslint-plugin";
import vitest from "eslint-plugin-vitest";
@@ -59,6 +60,20 @@ export default defineConfig([
"import-x/order": "error",
"init-declarations": "off",
"vitest/consistent-test-it": "warn",
"vitest/expect-expect": [
"warn",
{
assertFunctionNames: [
"expect",
"testElementLength",
"testTextContain",
"doTest",
"runAnimationTest",
"waitForAnimationClass",
"assertNoAnimationWithin"
]
}
],
"vitest/prefer-to-be": "warn",
"vitest/prefer-to-have-length": "warn",
"max-lines-per-function": ["warn", 400],
@@ -125,5 +140,12 @@ export default defineConfig([
rules: {
"@stylistic/quotes": "off"
}
},
{
files: ["tests/e2e/**/*.js"],
extends: [playwright.configs["flat/recommended"]],
rules: {
"playwright/no-standalone-expect": "off"
}
}
]);