mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-11 10:31:47 +00:00
Merge pull request #813 from th-ch/fix-tests
Bump electron and fix tests in CI
This commit is contained in:
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@ -91,6 +91,8 @@ jobs:
|
||||
|
||||
- name: Test
|
||||
uses: GabrielBB/xvfb-action@v1
|
||||
env:
|
||||
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
|
||||
with:
|
||||
run: yarn test
|
||||
|
||||
|
||||
@ -67,7 +67,8 @@
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"test": "jest",
|
||||
"test": "playwright test",
|
||||
"test:debug": "DEBUG=pw:browser* playwright test",
|
||||
"start": "electron .",
|
||||
"start:debug": "ELECTRON_ENABLE_LOGGING=1 electron .",
|
||||
"icon": "rimraf assets/generated && electron-icon-maker --input=assets/youtube-music.png --output=assets/generated",
|
||||
@ -120,13 +121,13 @@
|
||||
"ytpl": "^2.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@playwright/test": "^1.25.1",
|
||||
"auto-changelog": "^2.4.0",
|
||||
"electron": "^18.2.3",
|
||||
"electron": "^20.1.1",
|
||||
"electron-builder": "^23.0.3",
|
||||
"electron-devtools-installer": "^3.1.1",
|
||||
"electron-icon-maker": "0.0.5",
|
||||
"jest": "^27.3.1",
|
||||
"playwright": "^1.17.1",
|
||||
"playwright": "^1.25.1",
|
||||
"rimraf": "^3.0.2",
|
||||
"xo": "^0.45.0"
|
||||
},
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
const { test, expect } = require("@playwright/test");
|
||||
|
||||
const { sortSegments } = require("../segments");
|
||||
|
||||
test("Segment sorting", () => {
|
||||
|
||||
@ -1,30 +0,0 @@
|
||||
const path = require("path");
|
||||
|
||||
const NodeEnvironment = require("jest-environment-node");
|
||||
const { _electron: electron } = require("playwright");
|
||||
|
||||
class TestEnvironment extends NodeEnvironment {
|
||||
constructor(config) {
|
||||
super(config);
|
||||
}
|
||||
|
||||
async setup() {
|
||||
await super.setup();
|
||||
|
||||
const appPath = path.resolve(__dirname, "..");
|
||||
this.global.__APP__ = await electron.launch({ args: [appPath] });
|
||||
}
|
||||
|
||||
async teardown() {
|
||||
if (this.global.__APP__) {
|
||||
await this.global.__APP__.close();
|
||||
}
|
||||
await super.teardown();
|
||||
}
|
||||
|
||||
runScript(script) {
|
||||
return super.runScript(script);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = TestEnvironment;
|
||||
@ -1,16 +1,27 @@
|
||||
/**
|
||||
* @jest-environment ./tests/environment
|
||||
*/
|
||||
const path = require("path");
|
||||
|
||||
describe("YouTube Music App", () => {
|
||||
const app = global.__APP__;
|
||||
const { _electron: electron } = require("playwright");
|
||||
const { test, expect } = require("@playwright/test");
|
||||
|
||||
const appPath = path.resolve(__dirname, "..");
|
||||
|
||||
test("YouTube Music App - With default settings, app is launched and visible", async () => {
|
||||
const app = await electron.launch({
|
||||
args: [
|
||||
"--no-sandbox",
|
||||
"--disable-gpu",
|
||||
"--whitelisted-ips=",
|
||||
"--disable-dev-shm-usage",
|
||||
appPath,
|
||||
],
|
||||
});
|
||||
|
||||
test("With default settings, app is launched and visible", async () => {
|
||||
const window = await app.firstWindow();
|
||||
const title = await window.title();
|
||||
expect(title).toEqual("YouTube Music");
|
||||
|
||||
const url = window.url();
|
||||
expect(url.startsWith("https://music.youtube.com")).toBe(true);
|
||||
});
|
||||
|
||||
await app.close();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user