mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-12-02 02:51:54 +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
27 lines
959 B
JavaScript
27 lines
959 B
JavaScript
const helpers = require("./helpers/global-setup");
|
|
|
|
const getPage = () => helpers.getPage();
|
|
|
|
describe("Position of modules", () => {
|
|
beforeAll(async () => {
|
|
await helpers.startApplication("tests/configs/modules/positions.js");
|
|
await helpers.getDocument();
|
|
});
|
|
afterAll(async () => {
|
|
await helpers.stopApplication();
|
|
});
|
|
|
|
const positions = ["top_bar", "top_left", "top_center", "top_right", "upper_third", "middle_center", "lower_third", "bottom_left", "bottom_center", "bottom_right", "bottom_bar", "fullscreen_above", "fullscreen_below"];
|
|
|
|
for (const position of positions) {
|
|
const className = position.replace("_", ".");
|
|
it(`should show text in ${position}`, async () => {
|
|
const locator = getPage().locator(`.${className} .module-content`).first();
|
|
await locator.waitFor({ state: "visible" });
|
|
const text = await locator.textContent();
|
|
expect(text).not.toBeNull();
|
|
expect(text).toContain(`Text in ${position}`);
|
|
});
|
|
}
|
|
});
|