Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions js/electron.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ const createWindow = () => {

const electronOptions = Object.assign({}, electronOptionsDefaults, config.electronOptions);

if (process.env.mmTestMode) {
electronOptions.show = false;
electronOptions.fullscreen = false;
}

if (process.env.MOCK_DATE !== undefined) {
// if we are running tests and we want to mock the current date
const fakeNow = new Date(process.env.MOCK_DATE).valueOf();
Expand Down Expand Up @@ -143,9 +148,11 @@ const createWindow = () => {
callback({ responseHeaders: curHeaders });
});

mainWindow.once("ready-to-show", () => {
mainWindow.show();
});
if (!process.env.mmTestMode) {
mainWindow.once("ready-to-show", () => {
mainWindow.show();
});
}
};

// Quit when all windows are closed.
Expand Down
1 change: 1 addition & 0 deletions tests/configs/modules/display.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const config = {
address: "0.0.0.0",
ipWhitelist: [],
electronOptions: { width: 640, height: 480, show: true, fullscreen: true },
modules: [
{
module: "helloworld",
Expand Down
9 changes: 9 additions & 0 deletions tests/electron/env_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ describe("Electron app environment", () => {
const moduleContent = await helpers.getElement("#module_0_helloworld .module-content");
await expect(moduleContent.textContent()).resolves.toContain("Test Display Header");
expect(global.electronApp.windows()).toHaveLength(1);
const windowState = await global.electronApp.evaluate(({ BrowserWindow }) => {
const [window] = BrowserWindow.getAllWindows();
return { visible: window.isVisible(), fullscreen: window.isFullScreen(), bounds: window.getBounds() };
});
expect(windowState.visible).toBe(false);
expect(windowState.fullscreen).toBe(false);
expect(windowState.bounds).toMatchObject({ width: 640, height: 480 });
});
});

Expand All @@ -34,5 +41,7 @@ describe("Development console tests", () => {
for (const page of pageArray) {
expect(["MagicMirror²", "DevTools"]).toContain(await page.title());
}
const visible = await global.electronApp.evaluate(({ BrowserWindow }) => BrowserWindow.getAllWindows().some((window) => window.isVisible()));
expect(visible).toBe(false);
});
});
Loading