From 8fdd865cb1a205d8a03f11e6fb5a407c7d5531fb Mon Sep 17 00:00:00 2001 From: Karsten Hassel Date: Sun, 5 Jan 2025 11:07:34 +0100 Subject: [PATCH] electron tests: fixes for running under new github image ubuntu-24.04 (#3680) and replace xserver with labwc, fixes #3676 --- .github/workflows/automated-tests.yaml | 14 ++++++++++---- CHANGELOG.md | 3 ++- tests/electron/env_spec.js | 2 +- tests/electron/helpers/global-setup.js | 4 +++- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.github/workflows/automated-tests.yaml b/.github/workflows/automated-tests.yaml index f75e17b3d0..b6ab34a6ad 100644 --- a/.github/workflows/automated-tests.yaml +++ b/.github/workflows/automated-tests.yaml @@ -34,12 +34,14 @@ jobs: npm run test:css npm run test:markdown test: - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 timeout-minutes: 30 strategy: matrix: node-version: [20.18.1, 20.x, 22.x, 23.x] steps: + - name: Install electron dependencies and labwc + run: sudo apt-get install -y libnss3 libasound2t64 labwc - name: "Checkout code" uses: actions/checkout@v4 - name: "Use Node.js ${{ matrix.node-version }}" @@ -48,12 +50,16 @@ jobs: node-version: ${{ matrix.node-version }} check-latest: true cache: "npm" - - name: "Install dependencies" + - name: "Install MagicMirror²" run: | npm run install-mm:dev - name: "Run tests" run: | - Xvfb :99 -screen 0 1024x768x16 & - export DISPLAY=:99 + # Fix chrome-sandbox permissions: + sudo chown root:root ./node_modules/electron/dist/chrome-sandbox + sudo chmod 4755 ./node_modules/electron/dist/chrome-sandbox + # Start labwc + WLR_BACKENDS=headless WLR_LIBINPUT_NO_DEVICES=1 WLR_RENDERER=pixman labwc & + export WAYLAND_DISPLAY=wayland-0 touch css/custom.css npm run test diff --git a/CHANGELOG.md b/CHANGELOG.md index ddba26071d..fc5627a88f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,7 +25,8 @@ planned for 2025-04-01 ### Fixed -- [calendar] fix clipping events being broadcast (#3678) +- [calendar] Fix clipping events being broadcast (#3678) +- [tests] Electron tests: Fixes for running under new github image ubuntu-24.04, replace xserver with labwc (#3676) ## [2.30.0] - 2025-01-01 diff --git a/tests/electron/env_spec.js b/tests/electron/env_spec.js index b0e28789a6..b0f07c1853 100644 --- a/tests/electron/env_spec.js +++ b/tests/electron/env_spec.js @@ -19,7 +19,7 @@ describe("Electron app environment", () => { describe("Development console tests", () => { beforeEach(async () => { - await helpers.startApplication("tests/configs/modules/display.js", null, ["js/electron.js", "dev"]); + await helpers.startApplication("tests/configs/modules/display.js", null, ["dev"]); }); afterEach(async () => { diff --git a/tests/electron/helpers/global-setup.js b/tests/electron/helpers/global-setup.js index 505cb5e3c0..7561e5ecea 100644 --- a/tests/electron/helpers/global-setup.js +++ b/tests/electron/helpers/global-setup.js @@ -3,7 +3,7 @@ // https://www.anycodings.com/1questions/958135/can-i-set-the-date-for-playwright-browser const { _electron: electron } = require("playwright"); -exports.startApplication = async (configFilename, systemDate = null, electronParams = ["js/electron.js"], timezone = "GMT") => { +exports.startApplication = async (configFilename, systemDate = null, electronParams = [], timezone = "GMT") => { global.electronApp = null; global.page = null; process.env.MM_CONFIG_FILE = configFilename; @@ -13,6 +13,8 @@ exports.startApplication = async (configFilename, systemDate = null, electronPar } process.env.mmTestMode = "true"; + electronParams.unshift("js/electron.js", "--enable-features=UseOzonePlatform", "--ozone-platform=wayland"); + global.electronApp = await electron.launch({ args: electronParams }); await global.electronApp.firstWindow();