Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added navigator mock before tests to allow tests in headless mode #785

Merged
merged 12 commits into from
Jul 23, 2024
Prev Previous commit
Next Next commit
KKERTI test runs
  • Loading branch information
kkerti committed Jul 22, 2024
commit d5a60af869d5dd14d9340936fb78718e86a09efb
5 changes: 5 additions & 0 deletions playwright-tests/tests/virtualModule.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import { test, expect } from "@playwright/test";
import { VirtualModulePage } from "../pages/virtualModulePage";
import { PAGE_PATH } from "../utility";

test.beforeEach(({ page }) => {
// mocks navigator.serial, so headless UI tests can run!
page.addInitScript("Object.defineProperty(navigator,'serial',{set: () => undefined, get: () => undefined})")
})

test("add bu", async ({ page }) => {
const VirtualModule = new VirtualModulePage(page);

Expand Down
Binary file modified screenshotDIRECT.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 25 additions & 25 deletions src/renderer/preload-window-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ if (import.meta.env.VITE_WEB_MODE == "true") {
// handle non-chromium based browsers
if (window.chrome == null) {
navigator.serial = {
addEventListener: () => {},
addEventListener: () => { },
};
}
window.ctxProcess = {
Expand All @@ -50,11 +50,11 @@ if (import.meta.env.VITE_WEB_MODE == "true") {
};
window.electron = {
window: {
close: () => {},
maximize: () => {},
minimize: () => {},
restore: () => {},
isMaximized: () => {},
close: () => { },
maximize: () => { },
minimize: () => { },
restore: () => { },
isMaximized: () => { },
},
clipboard: {
writeText: () => {
Expand All @@ -64,54 +64,54 @@ if (import.meta.env.VITE_WEB_MODE == "true") {
},
},
persistentStorage: {
set: () => {},
set: () => { },
get: async () => {
return {
key: "value",
};
},
},
serial: {
restartSerialCheckInterval: async () => {},
restartSerialCheckInterval: async () => { },
},
websocket: {
onReceive: async () => {},
onTransmit: async () => {},
onReceive: async () => { },
onTransmit: async () => { },
},
auth: {
onExternalResponse: async () => {},
onExternalResponse: async () => { },
},
configs: {
onExternalResponse: async () => {},
startConfigsWatch: async () => {},
stopConfigsWatch: async () => {},
onSendConfigsToRenderer: async () => {},
onExternalResponse: async () => { },
startConfigsWatch: async () => { },
stopConfigsWatch: async () => { },
onSendConfigsToRenderer: async () => { },
saveConfig: () => {
return new Promise((resolve, reject) => {
reject("This feature is not yet supported in web mode.");
});
},
},
updater: {
onAppUpdate: async () => {},
onAppUpdate: async () => { },
},
firmware: {
onFirmwareUpdate: async () => {},
findBootloaderPath: async () => {},
onFirmwareUpdate: async () => { },
findBootloaderPath: async () => { },
},
stopOfflineProfileCloud: async () => {},
fetchUrlJSON: async () => {},
stopOfflineProfileCloud: async () => { },
fetchUrlJSON: async () => { },
getLatestVideo: async () => {
return {
videLink: "",
videoId: "",
};
},
restartPackageManager: () => {},
resetAppSettings: () => {},
openInBrowser: () => {},
overlay: () => {},
restartPackageManager: () => { },
resetAppSettings: () => { },
openInBrowser: () => { },
overlay: () => { },
};
}

export {};
export { };
Loading