mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-12-01 18:42:02 +00:00
### 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
32 lines
978 B
JavaScript
32 lines
978 B
JavaScript
const { expect } = require("playwright/test");
|
|
const helpers = require("./helpers/global-setup");
|
|
|
|
describe("Custom Position of modules", () => {
|
|
let page;
|
|
|
|
beforeAll(async () => {
|
|
await helpers.fixupIndex();
|
|
await helpers.startApplication("tests/configs/customregions.js");
|
|
await helpers.getDocument();
|
|
page = helpers.getPage();
|
|
});
|
|
afterAll(async () => {
|
|
await helpers.stopApplication();
|
|
await helpers.restoreIndex();
|
|
});
|
|
|
|
const positions = ["row3_left", "top3_left1"];
|
|
let i = 0;
|
|
const className1 = positions[i].replace("_", ".");
|
|
let message1 = positions[i];
|
|
it(`should show text in ${message1}`, async () => {
|
|
await expect(page.locator(`.${className1} .module-content`)).toContainText(`Text in ${message1}`);
|
|
});
|
|
i = 1;
|
|
const className2 = positions[i].replace("_", ".");
|
|
let message2 = positions[i];
|
|
it(`should NOT show text in ${message2}`, async () => {
|
|
await expect(page.locator(`.${className2} .module-content`)).toHaveCount(0);
|
|
});
|
|
});
|