electron tests: fixes for running under new github image ubuntu-24.04 (#3680)

and replace xserver with labwc, fixes #3676
This commit is contained in:
Karsten Hassel 2025-01-05 11:07:34 +01:00 committed by GitHub
parent 0f6efac8e6
commit 8fdd865cb1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 16 additions and 7 deletions

View File

@ -34,12 +34,14 @@ jobs:
npm run test:css npm run test:css
npm run test:markdown npm run test:markdown
test: test:
runs-on: ubuntu-22.04 runs-on: ubuntu-24.04
timeout-minutes: 30 timeout-minutes: 30
strategy: strategy:
matrix: matrix:
node-version: [20.18.1, 20.x, 22.x, 23.x] node-version: [20.18.1, 20.x, 22.x, 23.x]
steps: steps:
- name: Install electron dependencies and labwc
run: sudo apt-get install -y libnss3 libasound2t64 labwc
- name: "Checkout code" - name: "Checkout code"
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: "Use Node.js ${{ matrix.node-version }}" - name: "Use Node.js ${{ matrix.node-version }}"
@ -48,12 +50,16 @@ jobs:
node-version: ${{ matrix.node-version }} node-version: ${{ matrix.node-version }}
check-latest: true check-latest: true
cache: "npm" cache: "npm"
- name: "Install dependencies" - name: "Install MagicMirror²"
run: | run: |
npm run install-mm:dev npm run install-mm:dev
- name: "Run tests" - name: "Run tests"
run: | run: |
Xvfb :99 -screen 0 1024x768x16 & # Fix chrome-sandbox permissions:
export DISPLAY=:99 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 touch css/custom.css
npm run test npm run test

View File

@ -25,7 +25,8 @@ planned for 2025-04-01
### Fixed ### 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 ## [2.30.0] - 2025-01-01

View File

@ -19,7 +19,7 @@ describe("Electron app environment", () => {
describe("Development console tests", () => { describe("Development console tests", () => {
beforeEach(async () => { 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 () => { afterEach(async () => {

View File

@ -3,7 +3,7 @@
// https://www.anycodings.com/1questions/958135/can-i-set-the-date-for-playwright-browser // https://www.anycodings.com/1questions/958135/can-i-set-the-date-for-playwright-browser
const { _electron: electron } = require("playwright"); 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.electronApp = null;
global.page = null; global.page = null;
process.env.MM_CONFIG_FILE = configFilename; process.env.MM_CONFIG_FILE = configFilename;
@ -13,6 +13,8 @@ exports.startApplication = async (configFilename, systemDate = null, electronPar
} }
process.env.mmTestMode = "true"; process.env.mmTestMode = "true";
electronParams.unshift("js/electron.js", "--enable-features=UseOzonePlatform", "--ozone-platform=wayland");
global.electronApp = await electron.launch({ args: electronParams }); global.electronApp = await electron.launch({ args: electronParams });
await global.electronApp.firstWindow(); await global.electronApp.firstWindow();