mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-07-05 15:17:49 +00:00
Merge pull request #2715 from khassel/playwright
This commit is contained in:
commit
559970c95d
@ -20,6 +20,7 @@ _This release is scheduled to be released on 2022-01-01._
|
||||
- Cleaned up `alert` module and switched to nunjuck template.
|
||||
- Moved weather tests from category `electron` to `e2e`.
|
||||
- Updated github actions.
|
||||
- Replace spectron with playwright, update dependencies including electron update to v16.
|
||||
|
||||
### Fixed
|
||||
|
||||
|
7760
package-lock.json
generated
7760
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
37
package.json
37
package.json
@ -47,33 +47,33 @@
|
||||
"homepage": "https://magicmirror.builders",
|
||||
"devDependencies": {
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-plugin-jest": "^25.2.2",
|
||||
"eslint-plugin-jsdoc": "^36.1.1",
|
||||
"eslint-plugin-jest": "^25.3.0",
|
||||
"eslint-plugin-jsdoc": "^37.0.3",
|
||||
"eslint-plugin-prettier": "^4.0.0",
|
||||
"express-basic-auth": "^1.2.0",
|
||||
"husky": "^7.0.2",
|
||||
"jest": "^27.2.5",
|
||||
"jsdom": "^18.0.0",
|
||||
"husky": "^7.0.4",
|
||||
"jest": "^27.3.1",
|
||||
"jsdom": "^18.1.1",
|
||||
"lodash": "^4.17.21",
|
||||
"nyc": "^15.1.0",
|
||||
"prettier": "^2.4.1",
|
||||
"pretty-quick": "^3.1.1",
|
||||
"sinon": "^11.1.2",
|
||||
"spectron": "^15.0.0",
|
||||
"stylelint": "^13.13.1",
|
||||
"playwright": "^1.16.3",
|
||||
"prettier": "^2.5.0",
|
||||
"pretty-quick": "^3.1.2",
|
||||
"sinon": "^12.0.1",
|
||||
"stylelint": "^14.1.0",
|
||||
"stylelint-config-prettier": "^9.0.3",
|
||||
"stylelint-config-standard": "^22.0.0",
|
||||
"stylelint-prettier": "^1.2.0",
|
||||
"stylelint-config-standard": "^24.0.0",
|
||||
"stylelint-prettier": "^2.0.0",
|
||||
"suncalc": "^1.8.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"electron": "^13.5.2"
|
||||
"electron": "^16.0.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"colors": "^1.4.0",
|
||||
"console-stamp": "^3.0.3",
|
||||
"digest-fetch": "^1.2.1",
|
||||
"eslint": "^7.32.0",
|
||||
"eslint": "^8.3.0",
|
||||
"express": "^4.17.1",
|
||||
"express-ipfilter": "^1.2.0",
|
||||
"feedme": "^2.0.2",
|
||||
@ -81,9 +81,9 @@
|
||||
"iconv-lite": "^0.6.3",
|
||||
"module-alias": "^2.2.2",
|
||||
"moment": "^2.29.1",
|
||||
"node-fetch": "^2.6.5",
|
||||
"node-ical": "^0.13.0",
|
||||
"socket.io": "^4.3.1"
|
||||
"node-fetch": "^2.6.6",
|
||||
"node-ical": "^0.14.1",
|
||||
"socket.io": "^4.4.0"
|
||||
},
|
||||
"_moduleAliases": {
|
||||
"node_helper": "js/node_helper.js",
|
||||
@ -112,9 +112,6 @@
|
||||
"displayName": "electron",
|
||||
"testMatch": [
|
||||
"**/tests/electron/**/*.[jt]s?(x)"
|
||||
],
|
||||
"testPathIgnorePatterns": [
|
||||
"<rootDir>/tests/electron/global-setup.js"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -1,11 +0,0 @@
|
||||
/* Magic Mirror Test config sample environment
|
||||
*
|
||||
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
|
||||
* MIT Licensed.
|
||||
*/
|
||||
let config = require(process.cwd() + "/tests/configs/default.js").configFactory();
|
||||
|
||||
/*************** DO NOT EDIT THE LINE BELOW ***************/
|
||||
if (typeof module !== "undefined") {
|
||||
module.exports = config;
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
const helpers = require("./global-setup");
|
||||
|
||||
describe("Development console tests", function () {
|
||||
helpers.setupTimeout(this);
|
||||
|
||||
let app = null;
|
||||
|
||||
beforeAll(function () {
|
||||
// Set config sample for use in test
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/env.js";
|
||||
});
|
||||
|
||||
describe("Without 'dev' commandline argument", function () {
|
||||
beforeAll(function () {
|
||||
return helpers
|
||||
.startApplication({
|
||||
args: ["js/electron.js"]
|
||||
})
|
||||
.then(function (startedApp) {
|
||||
app = startedApp;
|
||||
});
|
||||
});
|
||||
|
||||
afterAll(function () {
|
||||
return helpers.stopApplication(app);
|
||||
});
|
||||
|
||||
it("should not open dev console when absent", async function () {
|
||||
await app.client.waitUntilWindowLoaded();
|
||||
return expect(await app.browserWindow.isDevToolsOpened()).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("With 'dev' commandline argument", function () {
|
||||
beforeAll(function () {
|
||||
return helpers
|
||||
.startApplication({
|
||||
args: ["js/electron.js", "dev"]
|
||||
})
|
||||
.then(function (startedApp) {
|
||||
app = startedApp;
|
||||
});
|
||||
});
|
||||
|
||||
afterAll(function () {
|
||||
return helpers.stopApplication(app);
|
||||
});
|
||||
|
||||
it("should open dev console when provided", async function () {
|
||||
expect(await app.client.getWindowCount()).toBe(2);
|
||||
});
|
||||
});
|
||||
});
|
@ -1,40 +1,44 @@
|
||||
const helpers = require("./global-setup");
|
||||
// see https://playwright.dev/docs/api/class-electronapplication
|
||||
|
||||
const { _electron: electron } = require("playwright");
|
||||
|
||||
let electronApp = null;
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/modules/display.js";
|
||||
|
||||
describe("Electron app environment", function () {
|
||||
helpers.setupTimeout(this);
|
||||
|
||||
let app = null;
|
||||
|
||||
beforeAll(function () {
|
||||
// Set config sample for use in test
|
||||
process.env.MM_CONFIG_FILE = "tests/configs/env.js";
|
||||
beforeEach(async function () {
|
||||
electronApp = await electron.launch({ args: ["js/electron.js"] });
|
||||
});
|
||||
|
||||
beforeEach(function () {
|
||||
return helpers
|
||||
.startApplication({
|
||||
args: ["js/electron.js"]
|
||||
})
|
||||
.then(function (startedApp) {
|
||||
app = startedApp;
|
||||
});
|
||||
afterEach(async function () {
|
||||
await electronApp.close();
|
||||
});
|
||||
|
||||
afterEach(function () {
|
||||
return helpers.stopApplication(app);
|
||||
});
|
||||
|
||||
it("should open a browserwindow", async function () {
|
||||
await app.client.waitUntilWindowLoaded();
|
||||
app.browserWindow.focus();
|
||||
expect(await app.client.getWindowCount()).toBe(1);
|
||||
expect(await app.browserWindow.isMinimized()).toBe(false);
|
||||
expect(await app.browserWindow.isDevToolsOpened()).toBe(false);
|
||||
expect(await app.browserWindow.isVisible()).toBe(true);
|
||||
expect(await app.browserWindow.isFocused()).toBe(true);
|
||||
const bounds = await app.browserWindow.getBounds();
|
||||
expect(bounds.width).toBeGreaterThan(0);
|
||||
expect(bounds.height).toBeGreaterThan(0);
|
||||
expect(await app.browserWindow.getTitle()).toBe("MagicMirror²");
|
||||
it("should open browserwindow", async function () {
|
||||
expect(await electronApp.windows().length).toBe(1);
|
||||
const page = await electronApp.firstWindow();
|
||||
expect(await page.title()).toBe("MagicMirror²");
|
||||
expect(await page.isVisible("body")).toBe(true);
|
||||
const module = page.locator("#module_0_helloworld");
|
||||
await module.waitFor();
|
||||
expect(await module.textContent()).toContain("Test Display Header");
|
||||
});
|
||||
});
|
||||
|
||||
describe("Development console tests", function () {
|
||||
beforeEach(async function () {
|
||||
electronApp = await electron.launch({ args: ["js/electron.js", "dev"] });
|
||||
});
|
||||
|
||||
afterEach(async function () {
|
||||
await electronApp.close();
|
||||
});
|
||||
|
||||
it("should open browserwindow and dev console", async function () {
|
||||
const pageArray = await electronApp.windows();
|
||||
expect(pageArray.length).toBe(2);
|
||||
for (const page of pageArray) {
|
||||
expect(["MagicMirror²", "DevTools"]).toContain(await page.title());
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Magic Mirror Global Setup Test Suite
|
||||
*
|
||||
* By Rodrigo Ramírez Norambuena https://rodrigoramirez.com
|
||||
* MIT Licensed.
|
||||
*/
|
||||
const Application = require("spectron").Application;
|
||||
const assert = require("assert");
|
||||
const path = require("path");
|
||||
const EventEmitter = require("events");
|
||||
|
||||
exports.getElectronPath = function () {
|
||||
let electronPath = path.join(__dirname, "..", "..", "node_modules", ".bin", "electron");
|
||||
if (process.platform === "win32") {
|
||||
electronPath += ".cmd";
|
||||
}
|
||||
return electronPath;
|
||||
};
|
||||
|
||||
// Set timeout - if this is run as CI Job, increase timeout
|
||||
exports.setupTimeout = function (test) {
|
||||
if (process.env.CI) {
|
||||
jest.setTimeout(30000);
|
||||
} else {
|
||||
jest.setTimeout(10000);
|
||||
}
|
||||
};
|
||||
|
||||
exports.startApplication = function (options) {
|
||||
const emitter = new EventEmitter();
|
||||
emitter.setMaxListeners(100);
|
||||
|
||||
options.path = exports.getElectronPath();
|
||||
if (process.env.CI) {
|
||||
options.startTimeout = 30000;
|
||||
}
|
||||
|
||||
const app = new Application(options);
|
||||
return app.start().then(function () {
|
||||
assert.strictEqual(app.isRunning(), true);
|
||||
return app;
|
||||
});
|
||||
};
|
||||
|
||||
exports.stopApplication = function (app) {
|
||||
if (!app || !app.isRunning()) {
|
||||
return;
|
||||
}
|
||||
|
||||
return app.stop().then(function () {
|
||||
assert.strictEqual(app.isRunning(), false);
|
||||
});
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user