From 9fd13cc996cf34a902e72b578414f2f1ff378c6a Mon Sep 17 00:00:00 2001 From: Mikk Tendermann Date: Fri, 4 Aug 2023 14:28:48 +0300 Subject: [PATCH 1/3] Do not hardcode component rendering url to localhost --- .../commands/launchComponentRenderer.js | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/nightwatch/commands/launchComponentRenderer.js b/nightwatch/commands/launchComponentRenderer.js index aea1b29..75028a6 100644 --- a/nightwatch/commands/launchComponentRenderer.js +++ b/nightwatch/commands/launchComponentRenderer.js @@ -1,19 +1,20 @@ module.exports = class Command { async command() { - let launchUrl = ''; - const {vite_dev_server, vite_port} = this.client.settings; + let launchUrl = new URL(this.api.globals.launchUrl ?? this.client.settings.launchUrl ?? 'http://localhost:5173'); + const { vite_dev_server, vite_port } = this.client.settings; if (vite_dev_server) { - const port = vite_dev_server.port || 5173; - launchUrl = `http://localhost:${port}`; - } else if (this.api.globals.launchUrl) { - launchUrl = this.api.globals.launchUrl; + launchUrl.port = vite_port || 5173 } if (global.viteServer) { - launchUrl = `http://localhost:${global.viteServer.config.port}`; + launchUrl.port = global.viteServer.config.port; } - return this.api.navigateTo(`${launchUrl}/_nightwatch/`); + launchUrl.pathname = '/_nightwatch/'; + + console.log(launchUrl.toString()); + + return this.api.navigateTo(launchUrl.toString()); } -}; \ No newline at end of file +}; From 8cb3a92b1362bfff3e4b2e85653d488fd4e522fa Mon Sep 17 00:00:00 2001 From: Mikk Tendermann Date: Fri, 4 Aug 2023 14:41:27 +0300 Subject: [PATCH 2/3] this console.log is not needed --- nightwatch/commands/launchComponentRenderer.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/nightwatch/commands/launchComponentRenderer.js b/nightwatch/commands/launchComponentRenderer.js index 75028a6..c49e77e 100644 --- a/nightwatch/commands/launchComponentRenderer.js +++ b/nightwatch/commands/launchComponentRenderer.js @@ -13,8 +13,6 @@ module.exports = class Command { launchUrl.pathname = '/_nightwatch/'; - console.log(launchUrl.toString()); - return this.api.navigateTo(launchUrl.toString()); } }; From 9fa6048e4e7916b13f8f52176f584d49daf203f3 Mon Sep 17 00:00:00 2001 From: Mikk Tendermann Date: Thu, 26 Sep 2024 15:30:52 +0300 Subject: [PATCH 3/3] lets use viteServer protocol then --- nightwatch/commands/launchComponentRenderer.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nightwatch/commands/launchComponentRenderer.js b/nightwatch/commands/launchComponentRenderer.js index c49e77e..250c7f9 100644 --- a/nightwatch/commands/launchComponentRenderer.js +++ b/nightwatch/commands/launchComponentRenderer.js @@ -9,6 +9,8 @@ module.exports = class Command { if (global.viteServer) { launchUrl.port = global.viteServer.config.port; + const protocol = global.viteServer.config.server.https ? "https" : "http"; + launchUrl.protocol = protocol; } launchUrl.pathname = '/_nightwatch/';