{"size": 1379, "ext": "js", "max_stars_repo_path": "tests/electron/env_spec.js", "max_stars_repo_name": "952895776/MagicMirror", "max_stars_repo_stars_event_min_datetime": "2022-03-09T22:42:38.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-20T19:28:36.000Z", "max_issues_repo_path": "tests/electron/env_spec.js", "max_issues_repo_name": "952895776/MagicMirror", "max_issues_repo_issues_event_min_datetime": "2022-01-10T08:15:21.000Z", "max_issues_repo_issues_event_max_datetime": "2022-01-26T21:44:46.000Z", "max_forks_repo_path": "tests/electron/env_spec.js", "max_forks_repo_name": "952895776/MagicMirror", "max_forks_repo_forks_event_min_datetime": "2022-02-23T15:33:46.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-23T15:33:46.000Z"}
{"max_stars_count": 2, "max_issues_count": 9, "max_forks_count": 1, "avg_line_length": 29.9782608696, "max_line_length": 75, "alphanum_fraction": 0.6997824511}
// 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);

describe("Electron app environment", function () {
	beforeEach(async function () {
		electronApp = await electron.launch({ args: ["js/electron.js"] });
	});

	afterEach(async function () {
		await electronApp.close();
	});

	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());
		}
	});
});
