[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

@@ -8,28 +8,21 @@ import {defineConfig} from "vitest/config";
*
* Parallel execution would require dynamic ports and isolated fixtures,
* so we intentionally cap Vitest at a single worker for now.
*
* Projects separate unit, e2e (Playwright), and electron tests with
* appropriate timeouts for each test type.
*/
export default defineConfig({
test: {
// Global settings
// Shared settings for all test types
globals: true,
environment: "node",
// Setup files for require aliasing
setupFiles: ["./tests/utils/vitest-setup.js"],
// Increased from 20s to 60s for E2E tests, 120s for Electron tests
testTimeout: 120000,
// Increase hook timeout for Electron cleanup
hookTimeout: 30000,
// Stop test execution on first failure
bail: 1,
bail: 3,
// File patterns
include: [
"tests/**/*_spec.js",
// Legacy regression test without the _spec suffix
"tests/unit/modules/default/calendar/calendar_fetcher_utils_bad_rrule.js"
],
// Shared exclude patterns
exclude: [
"**/node_modules/**",
"**/dist/**",
@@ -42,6 +35,46 @@ export default defineConfig({
"tests/utils/**"
],
// Projects with specific configurations per test type
projects: [
{
test: {
name: "unit",
globals: true,
environment: "node",
setupFiles: ["./tests/utils/vitest-setup.js"],
include: [
"tests/unit/**/*_spec.js",
"tests/unit/modules/default/calendar/calendar_fetcher_utils_bad_rrule.js"
],
testTimeout: 20000,
hookTimeout: 10000
}
},
{
test: {
name: "e2e",
globals: true,
environment: "node",
setupFiles: ["./tests/utils/vitest-setup.js"],
include: ["tests/e2e/**/*_spec.js"],
testTimeout: 60000,
hookTimeout: 30000
}
},
{
test: {
name: "electron",
globals: true,
environment: "node",
setupFiles: ["./tests/utils/vitest-setup.js"],
include: ["tests/electron/**/*_spec.js"],
testTimeout: 120000,
hookTimeout: 30000
}
}
],
// Coverage configuration
coverage: {
provider: "v8",