From 46d0e58661ce500a27681cfab3abecbc1d5d1f1b Mon Sep 17 00:00:00 2001 From: abose Date: Fri, 30 Jan 2026 20:04:04 +0530 Subject: [PATCH 1/8] chore: f12 to open devtools in electron test runner window --- test/SpecRunner.html | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/SpecRunner.html b/test/SpecRunner.html index 9d910e9be..ce16c266d 100644 --- a/test/SpecRunner.html +++ b/test/SpecRunner.html @@ -207,6 +207,13 @@ }); } setupElectronBootVars(); + // F12 to toggle dev tools in Electron + document.addEventListener('keydown', function(e) { + if (e.key === 'F12') { + e.preventDefault(); + window.electronAPI.toggleDevTools(); + } + }); } From 55a79fd13aa547a42accea19bc437c82517ff9a9 Mon Sep 17 00:00:00 2001 From: abose Date: Fri, 30 Jan 2026 20:26:10 +0530 Subject: [PATCH 2/8] fix: add missing electon test api injection --- src/index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/src/index.html b/src/index.html index 136ec1f45..7f6159b56 100644 --- a/src/index.html +++ b/src/index.html @@ -175,6 +175,7 @@ console.warn("Phoenix is loaded in iframe, attempting to use electron APIs from window.top"); window.electronAppAPI = window.top.window.electronAppAPI; window.electronFSAPI = window.top.window.electronFSAPI; + window.electronAPI = window.top.window.electronAPI; } if(window.__TAURI__ || window.__ELECTRON__) { window.__IS_NATIVE_SHELL__ = true; From b6d257b00f5fb66a46feeafcc23827d74555f8e1 Mon Sep 17 00:00:00 2001 From: abose Date: Fri, 30 Jan 2026 20:33:03 +0530 Subject: [PATCH 3/8] fix: integ tests starts running in dev mode --- src/index.html | 1 + 1 file changed, 1 insertion(+) diff --git a/src/index.html b/src/index.html index 7f6159b56..a804594e2 100644 --- a/src/index.html +++ b/src/index.html @@ -173,6 +173,7 @@ // this means that we are loaded in an iframe in the specrunner. Electron doesnt expose APIs // in its iframes, so we directly use the top most windows electron api objects for tests to run properly. console.warn("Phoenix is loaded in iframe, attempting to use electron APIs from window.top"); + window.__ELECTRON__ = true; window.electronAppAPI = window.top.window.electronAppAPI; window.electronFSAPI = window.top.window.electronFSAPI; window.electronAPI = window.top.window.electronAPI; From 65387b9a29176446e617de4f8adab9144cb8be56 Mon Sep 17 00:00:00 2001 From: abose Date: Fri, 30 Jan 2026 21:20:19 +0530 Subject: [PATCH 4/8] test: test runner cli processing in electron --- test/UnitTestReporter.js | 30 +++++++++++++++++++------ test/index-dist-test.html | 46 +++++++++++++++++++++++++++++++-------- 2 files changed, 60 insertions(+), 16 deletions(-) diff --git a/test/UnitTestReporter.js b/test/UnitTestReporter.js index 995b62306..e1a541e19 100644 --- a/test/UnitTestReporter.js +++ b/test/UnitTestReporter.js @@ -65,18 +65,34 @@ define(function (require, exports, module) { return ''; } + function hasCliFlag(args, flagName) { + return args.some(arg => arg === `--${flagName}` || arg.startsWith(`--${flagName}=`)); + } + function quitIfNeeded(exitStatus) { - if(!window.__TAURI__){ + const isTauri = !!window.__TAURI__; + const isElectron = !!window.electronAppAPI?.isElectron; + + if (!isTauri && !isElectron) { return; } + const WAIT_TIME_TO_COMPLETE_TEST_LOGGING_SEC = 10; console.log("Scheduled Quit in Seconds: ", WAIT_TIME_TO_COMPLETE_TEST_LOGGING_SEC); - setTimeout(()=>{ - window.__TAURI__.cli.getMatches().then(matches=>{ - if(matches && matches.args["quit-when-done"] && matches.args["quit-when-done"].occurrences) { - window.__TAURI__.process.exit(exitStatus); - } - }); + setTimeout(() => { + if (isTauri) { + window.__TAURI__.cli.getMatches().then(matches => { + if (matches && matches.args["quit-when-done"] && matches.args["quit-when-done"].occurrences) { + window.__TAURI__.process.exit(exitStatus); + } + }); + } else if (isElectron) { + window.electronAppAPI.getCliArgs().then(args => { + if (hasCliFlag(args, 'quit-when-done')) { + window.electronAppAPI.quitApp(exitStatus); + } + }); + } }, WAIT_TIME_TO_COMPLETE_TEST_LOGGING_SEC * 1000); } diff --git a/test/index-dist-test.html b/test/index-dist-test.html index b0390820b..63dbe9ba7 100644 --- a/test/index-dist-test.html +++ b/test/index-dist-test.html @@ -4,20 +4,48 @@ Starting tests... From a6ace79880f9a5aee2fa3db973308f0efcd2e919 Mon Sep 17 00:00:00 2001 From: abose Date: Fri, 30 Jan 2026 21:38:08 +0530 Subject: [PATCH 5/8] chore: test framework didnt exist with -q cli flag --- test/UnitTestReporter.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/test/UnitTestReporter.js b/test/UnitTestReporter.js index e1a541e19..9894b543d 100644 --- a/test/UnitTestReporter.js +++ b/test/UnitTestReporter.js @@ -65,8 +65,12 @@ define(function (require, exports, module) { return ''; } - function hasCliFlag(args, flagName) { - return args.some(arg => arg === `--${flagName}` || arg.startsWith(`--${flagName}=`)); + function hasCliFlag(args, flagName, shortFlag) { + return args.some(arg => + arg === `--${flagName}` || + arg.startsWith(`--${flagName}=`) || + (shortFlag && arg === `-${shortFlag}`) + ); } function quitIfNeeded(exitStatus) { @@ -88,7 +92,7 @@ define(function (require, exports, module) { }); } else if (isElectron) { window.electronAppAPI.getCliArgs().then(args => { - if (hasCliFlag(args, 'quit-when-done')) { + if (hasCliFlag(args, 'quit-when-done', 'q')) { window.electronAppAPI.quitApp(exitStatus); } }); From 68aba25b9034047b3f45fbec0258494152f8c82a Mon Sep 17 00:00:00 2001 From: abose Date: Fri, 30 Jan 2026 22:54:54 +0530 Subject: [PATCH 6/8] fix: unit tests should work in electron as well part 1 --- test/SpecRunner.html | 4 ++++ test/spec/ExtensionInstallation-test.js | 5 +++-- test/spec/ExtensionLoader-test.js | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/test/SpecRunner.html b/test/SpecRunner.html index ce16c266d..1665f48c2 100644 --- a/test/SpecRunner.html +++ b/test/SpecRunner.html @@ -213,6 +213,10 @@ e.preventDefault(); window.electronAPI.toggleDevTools(); } + if (e.key === 'F5') { + e.preventDefault(); + location.reload(); + } }); } diff --git a/test/spec/ExtensionInstallation-test.js b/test/spec/ExtensionInstallation-test.js index 8c91e42ca..b8d2120ba 100644 --- a/test/spec/ExtensionInstallation-test.js +++ b/test/spec/ExtensionInstallation-test.js @@ -31,7 +31,8 @@ define(function (require, exports, module) { const testFilePath = SpecRunnerUtils.getTestPath("/spec/extension-test-files"); - const tempDirectory = window.__TAURI__ ? Phoenix.VFS.getTauriAssetServeDir() + "tests": SpecRunnerUtils.getTempDirectory(); + const tempDirectory = Phoenix.isNativeApp ? + Phoenix.VFS.getTauriAssetServeDir() + "tests": SpecRunnerUtils.getTempDirectory(); const extensionsRoot = tempDirectory + "/extensions"; const basicValidSrc = testFilePath + "/basic-valid-extension.zip", @@ -79,7 +80,7 @@ define(function (require, exports, module) { beforeAll(async function () { await SpecRunnerUtils.ensureExistsDirAsync(tempDirectory); - if(window.__TAURI__){ + if(Phoenix.isNativeApp){ basicValid = tempDirectory + "/basic-valid-extension.zip"; missingNameVersion = tempDirectory + "/missing-name-version.zip"; missingNameVersion = tempDirectory + "/missing-name-version.zip"; diff --git a/test/spec/ExtensionLoader-test.js b/test/spec/ExtensionLoader-test.js index 0b06581e3..291b3efed 100644 --- a/test/spec/ExtensionLoader-test.js +++ b/test/spec/ExtensionLoader-test.js @@ -32,7 +32,7 @@ define(function (require, exports, module) { SpecRunnerUtils = require("spec/SpecRunnerUtils"); const testPathSrc = SpecRunnerUtils.getTestPath("/spec/ExtensionLoader-test-files"); - const testPath = window.__TAURI__ ? Phoenix.VFS.getTauriAssetServeDir() + "tests": SpecRunnerUtils.getTempDirectory(); + const testPath = Phoenix.isNativeApp ? Phoenix.VFS.getTauriAssetServeDir() + "tests": SpecRunnerUtils.getTempDirectory(); describe("ExtensionLoader", function () { From 5c0cf59cc63a59a207a04f5066ddd46c1083d342 Mon Sep 17 00:00:00 2001 From: abose Date: Fri, 30 Jan 2026 23:04:55 +0530 Subject: [PATCH 7/8] fix: all unit tests working in electron --- test/spec/ExtensionManager-test.js | 2 +- test/spec/LowLevelFileIO-test.js | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/spec/ExtensionManager-test.js b/test/spec/ExtensionManager-test.js index 722982895..5322c8099 100644 --- a/test/spec/ExtensionManager-test.js +++ b/test/spec/ExtensionManager-test.js @@ -49,7 +49,7 @@ define(function (require, exports, module) { mockExtensionList = require("text!spec/ExtensionManager-test-files/mockExtensionList.json"), mockRegistry; - const testPath = window.__TAURI__ ? + const testPath = Phoenix.isNativeApp ? Phoenix.VFS.getTauriAssetServeDir() + "tests" : SpecRunnerUtils.getTempDirectory(); const testSrc = SpecRunnerUtils.getTestPath("/spec/ExtensionManager-test-files"); diff --git a/test/spec/LowLevelFileIO-test.js b/test/spec/LowLevelFileIO-test.js index 5fe7063fd..3ec05e1cf 100644 --- a/test/spec/LowLevelFileIO-test.js +++ b/test/spec/LowLevelFileIO-test.js @@ -797,7 +797,7 @@ define(function (require, exports, module) { describe("specialDirectories", function () { it("should have an application support directory", async function () { // these tests are here as these are absolute unchanging dir convention used by phoenix. - if(window.__TAURI__){ + if(Phoenix.isNativeApp){ const appSupportDIR = window.fs.getTauriVirtualPath(window._tauriBootVars.appLocalDir); expect(brackets.app.getApplicationSupportDirectory().startsWith("/tauri/")).toBeTrue(); expect(brackets.app.getApplicationSupportDirectory()).toBe(appSupportDIR); @@ -807,7 +807,7 @@ define(function (require, exports, module) { }); it("should have a user documents directory", function () { // these tests are here as these are absolute unchanging dir convention used by phoenix. - if(window.__TAURI__){ + if(Phoenix.isNativeApp){ const documentsDIR = window.fs.getTauriVirtualPath(window._tauriBootVars.documentDir); expect(brackets.app.getUserDocumentsDirectory().startsWith("/tauri/")).toBeTrue(); expect(brackets.app.getUserDocumentsDirectory()).toBe(documentsDIR); @@ -817,7 +817,7 @@ define(function (require, exports, module) { }); it("should have a user projects directory", function () { // these tests are here as these are absolute unchanging dir convention used by phoenix. - if(window.__TAURI__){ + if(Phoenix.isNativeApp){ const documentsDIR = window.fs.getTauriVirtualPath(window._tauriBootVars.documentDir); const appName = window._tauriBootVars.appname; const userProjectsDir = `${documentsDIR}${appName}/`; @@ -829,7 +829,7 @@ define(function (require, exports, module) { }); it("should have a temp directory", function () { // these tests are here as these are absolute unchanging dir convention used by phoenix. - if(window.__TAURI__){ + if(Phoenix.isNativeApp){ let tempDIR = window.fs.getTauriVirtualPath(window._tauriBootVars.tempDir); if(!tempDIR.endsWith("/")){ tempDIR = `${tempDIR}/`; @@ -844,7 +844,7 @@ define(function (require, exports, module) { }); it("should have extensions directory", function () { // these tests are here as these are absolute unchanging dir convention used by phoenix. - if(window.__TAURI__){ + if(Phoenix.isNativeApp){ const appSupportDIR = window.fs.getTauriVirtualPath(window._tauriBootVars.appLocalDir); const extensionsDir = `${appSupportDIR}assets/extensions/`; expect(brackets.app.getExtensionsDirectory().startsWith("/tauri/")).toBeTrue(); @@ -855,7 +855,7 @@ define(function (require, exports, module) { }); it("should get virtual serving directory from virtual serving URL in browser", async function () { - if(window.__TAURI__){ + if(Phoenix.isNativeApp){ return; } expect(brackets.VFS.getPathForVirtualServingURL(`${window.fsServerUrl}blinker`)).toBe("/blinker"); @@ -866,7 +866,7 @@ define(function (require, exports, module) { }); it("should not get virtual serving directory from virtual serving URL in tauri", async function () { - if(!window.__TAURI__){ + if(!Phoenix.isNativeApp){ return; } expect(window.fsServerUrl).not.toBeDefined(); From 31c6708a626eb7f9467351c17fa8fc0c9c510a75 Mon Sep 17 00:00:00 2001 From: abose Date: Fri, 30 Jan 2026 23:10:43 +0530 Subject: [PATCH 8/8] fix: test suite non clickable after test run --- test/spec/ExtensionManager-test.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/spec/ExtensionManager-test.js b/test/spec/ExtensionManager-test.js index 5322c8099..2571c3328 100644 --- a/test/spec/ExtensionManager-test.js +++ b/test/spec/ExtensionManager-test.js @@ -808,6 +808,12 @@ define(function (require, exports, module) { }); }); + afterEach(function () { + // Clean up any lingering dialogs + Dialogs.cancelModalDialogIfOpen("install-extension-dialog"); + $(".modal-wrapper").remove(); + }); + it("should set flag to keep local files for new installs", async function () { var filename = "/path/to/downloaded/file.zip", file = FileSystem.getFileForPath(filename),