2024-01-08 17:45:54 +01:00
|
|
|
const events = require("node:events");
|
2023-04-04 20:44:32 +02:00
|
|
|
const helpers = require("./helpers/global-setup");
|
2021-11-27 00:19:26 +01:00
|
|
|
|
2023-01-01 18:09:08 +01:00
|
|
|
describe("Electron app environment", () => {
|
|
|
|
|
beforeEach(async () => {
|
|
|
|
|
await helpers.startApplication("tests/configs/modules/display.js");
|
2021-11-27 00:19:26 +01:00
|
|
|
});
|
2021-09-13 22:28:27 +02:00
|
|
|
|
2023-01-01 18:09:08 +01:00
|
|
|
afterEach(async () => {
|
|
|
|
|
await helpers.stopApplication();
|
2021-11-27 00:19:26 +01:00
|
|
|
});
|
2021-09-13 22:28:27 +02:00
|
|
|
|
2023-01-01 18:09:08 +01:00
|
|
|
it("should open browserwindow", async () => {
|
|
|
|
|
const module = await helpers.getElement("#module_0_helloworld");
|
2024-01-01 15:38:08 +01:00
|
|
|
await expect(module.textContent()).resolves.toContain("Test Display Header");
|
|
|
|
|
expect(global.electronApp.windows()).toHaveLength(1);
|
2021-09-13 22:28:27 +02:00
|
|
|
});
|
2021-11-27 00:19:26 +01:00
|
|
|
});
|
2021-09-13 22:28:27 +02:00
|
|
|
|
2023-01-01 18:09:08 +01:00
|
|
|
describe("Development console tests", () => {
|
|
|
|
|
beforeEach(async () => {
|
2025-01-05 11:07:34 +01:00
|
|
|
await helpers.startApplication("tests/configs/modules/display.js", null, ["dev"]);
|
2021-09-13 22:28:27 +02:00
|
|
|
});
|
|
|
|
|
|
2023-01-01 18:09:08 +01:00
|
|
|
afterEach(async () => {
|
|
|
|
|
await helpers.stopApplication();
|
2021-09-13 22:28:27 +02:00
|
|
|
});
|
|
|
|
|
|
2023-01-01 18:09:08 +01:00
|
|
|
it("should open browserwindow and dev console", async () => {
|
|
|
|
|
while (global.electronApp.windows().length < 2) await events.once(global.electronApp, "window");
|
|
|
|
|
const pageArray = await global.electronApp.windows();
|
2024-01-01 15:38:08 +01:00
|
|
|
expect(pageArray).toHaveLength(2);
|
2021-11-27 00:19:26 +01:00
|
|
|
for (const page of pageArray) {
|
|
|
|
|
expect(["MagicMirror²", "DevTools"]).toContain(await page.title());
|
|
|
|
|
}
|
2021-09-13 22:28:27 +02:00
|
|
|
});
|
|
|
|
|
});
|