mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-08-21 12:55:22 +00:00
added new electron tests supporting date mocking (#2947)
first PR for #2942 - added new electron tests for calendar which test new css classes from https://github.com/MichMich/MagicMirror/pull/2939 - moved some compliments tests from `e2e` to `electron` because of date mocking - removed mock stuff from compliments module
This commit is contained in:
@@ -1,42 +1,32 @@
|
||||
// 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";
|
||||
jest.retryTimes(3);
|
||||
const helpers = require("./helpers/global-setup");
|
||||
|
||||
describe("Electron app environment", () => {
|
||||
beforeEach(async () => {
|
||||
electronApp = await electron.launch({ args: ["js/electron.js"] });
|
||||
await helpers.startApplication("tests/configs/modules/display.js");
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await electronApp.close();
|
||||
await helpers.stopApplication();
|
||||
});
|
||||
|
||||
it("should open browserwindow", async () => {
|
||||
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();
|
||||
const module = await helpers.getElement("#module_0_helloworld");
|
||||
expect(await module.textContent()).toContain("Test Display Header");
|
||||
expect(await global.electronApp.windows().length).toBe(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Development console tests", () => {
|
||||
beforeEach(async () => {
|
||||
electronApp = await electron.launch({ args: ["js/electron.js", "dev"] });
|
||||
await helpers.startApplication("tests/configs/modules/display.js", null, ["js/electron.js", "dev"]);
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await electronApp.close();
|
||||
await helpers.stopApplication();
|
||||
});
|
||||
|
||||
it("should open browserwindow and dev console", async () => {
|
||||
const pageArray = await electronApp.windows();
|
||||
const pageArray = await global.electronApp.windows();
|
||||
expect(pageArray.length).toBe(2);
|
||||
for (const page of pageArray) {
|
||||
expect(["MagicMirror²", "DevTools"]).toContain(await page.title());
|
||||
|
Reference in New Issue
Block a user