From 96ae76897f8651827266af91896633dfdb2b6b81 Mon Sep 17 00:00:00 2001 From: Jonatan Heyman Date: Mon, 9 Dec 2024 13:11:10 +0100 Subject: [PATCH] Update Playwright to latest version Should fix broken tests in Github actions. Add workaround for platform detection when running Playwright tests on Mac which no longer works in latest version. --- package-lock.json | 34 +++++++++++++++++++--------------- package.json | 2 +- webapp/bridge.js | 39 +++++++++++++++++++++++++-------------- 3 files changed, 45 insertions(+), 30 deletions(-) diff --git a/package-lock.json b/package-lock.json index db7dde7..8eacc25 100644 --- a/package-lock.json +++ b/package-lock.json @@ -40,7 +40,7 @@ "@electron/asar": "^3.2.2", "@lezer/generator": "^1.5.1", "@lezer/markdown": "^1.1.2", - "@playwright/test": "^1.40.1", + "@playwright/test": "^1.49.0", "@replit/codemirror-lang-csharp": "^6.2.0", "@rollup/plugin-node-resolve": "^15.0.1", "@types/node": "^20.10.5", @@ -1249,18 +1249,19 @@ } }, "node_modules/@playwright/test": { - "version": "1.40.1", - "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.40.1.tgz", - "integrity": "sha512-EaaawMTOeEItCRvfmkI9v6rBkF1svM8wjl/YPRrg2N2Wmp+4qJYkWtJsbew1szfKKDm6fPLy4YAanBhIlf9dWw==", + "version": "1.49.0", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.49.0.tgz", + "integrity": "sha512-DMulbwQURa8rNIQrf94+jPJQ4FmOVdpE5ZppRNvWVjvhC+6sOeo28r8MgIpQRYouXRtt/FCCXU7zn20jnHR4Qw==", "dev": true, + "license": "Apache-2.0", "dependencies": { - "playwright": "1.40.1" + "playwright": "1.49.0" }, "bin": { "playwright": "cli.js" }, "engines": { - "node": ">=16" + "node": ">=18" } }, "node_modules/@replit/codemirror-lang-csharp": { @@ -4971,33 +4972,35 @@ } }, "node_modules/playwright": { - "version": "1.40.1", - "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.40.1.tgz", - "integrity": "sha512-2eHI7IioIpQ0bS1Ovg/HszsN/XKNwEG1kbzSDDmADpclKc7CyqkHw7Mg2JCz/bbCxg25QUPcjksoMW7JcIFQmw==", + "version": "1.49.0", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.49.0.tgz", + "integrity": "sha512-eKpmys0UFDnfNb3vfsf8Vx2LEOtflgRebl0Im2eQQnYMA4Aqd+Zw8bEOB+7ZKvN76901mRnqdsiOGKxzVTbi7A==", "dev": true, + "license": "Apache-2.0", "dependencies": { - "playwright-core": "1.40.1" + "playwright-core": "1.49.0" }, "bin": { "playwright": "cli.js" }, "engines": { - "node": ">=16" + "node": ">=18" }, "optionalDependencies": { "fsevents": "2.3.2" } }, "node_modules/playwright-core": { - "version": "1.40.1", - "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.40.1.tgz", - "integrity": "sha512-+hkOycxPiV534c4HhpfX6yrlawqVUzITRKwHAmYfmsVreltEl6fAZJ3DPfLMOODw0H3s1Itd6MDCWmP1fl/QvQ==", + "version": "1.49.0", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.49.0.tgz", + "integrity": "sha512-R+3KKTQF3npy5GTiKH/T+kdhoJfJojjHESR1YEWhYuEKRVfVaxH3+4+GvXE5xyCngCxhxnykk0Vlah9v8fs3jA==", "dev": true, + "license": "Apache-2.0", "bin": { "playwright-core": "cli.js" }, "engines": { - "node": ">=16" + "node": ">=18" } }, "node_modules/playwright/node_modules/fsevents": { @@ -5006,6 +5009,7 @@ "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", "dev": true, "hasInstallScript": true, + "license": "MIT", "optional": true, "os": [ "darwin" diff --git a/package.json b/package.json index 785f5f6..1963c6b 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "@electron/asar": "^3.2.2", "@lezer/generator": "^1.5.1", "@lezer/markdown": "^1.1.2", - "@playwright/test": "^1.40.1", + "@playwright/test": "^1.49.0", "@replit/codemirror-lang-csharp": "^6.2.0", "@rollup/plugin-node-resolve": "^15.0.1", "@types/node": "^20.10.5", diff --git a/webapp/bridge.js b/webapp/bridge.js index 21866c5..7d34251 100644 --- a/webapp/bridge.js +++ b/webapp/bridge.js @@ -18,25 +18,36 @@ let autoUpdateCallbacks = null let currencyData = null let platform -const uaPlatform = window.navigator?.userAgentData?.platform || window.navigator.platform -if (uaPlatform.indexOf("Win") !== -1) { - platform = { - isMac: false, - isWindows: true, - isLinux: false, - } -} else if (uaPlatform.indexOf("Linux") !== -1) { - platform = { - isMac: false, - isWindows: false, - isLinux: true, - } -} else { + +// In the latest version of Playwright, the window.navigator.userAgentData.platform is not reported correctly on Mac, +// wo we'll fallback to deprecated window.navigator.platform which still works +if (__TESTS__ && window.navigator.platform.indexOf("Mac") !== -1) { platform = { isMac: true, isWindows: false, isLinux: false, } +} else { + const uaPlatform = window.navigator?.userAgentData?.platform || window.navigator.platform + if (uaPlatform.indexOf("Win") !== -1) { + platform = { + isMac: false, + isWindows: true, + isLinux: false, + } + } else if (uaPlatform.indexOf("Linux") !== -1) { + platform = { + isMac: false, + isWindows: false, + isLinux: true, + } + } else { + platform = { + isMac: true, + isWindows: false, + isLinux: false, + } + } } platform.isWebApp = true