From 5faf830d4620c3e497e800dfec6c9aa377fea0d5 Mon Sep 17 00:00:00 2001 From: Priya Patel Date: Thu, 13 Nov 2025 13:15:54 -0500 Subject: [PATCH] =?UTF-8?q?refactor:=20=F0=9F=92=A1=20updated=20magic=20st?= =?UTF-8?q?rings=20with=20const=20(#3064)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../settings-card/preferred-clients/index.js | 4 +++- .../acceptance/projects/sessions/session-test.js | 9 +++++---- .../tests/acceptance/projects/targets/index-test.js | 11 ++++++----- .../tests/acceptance/projects/targets/target-test.js | 7 ++++--- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/ui/desktop/app/components/settings-card/preferred-clients/index.js b/ui/desktop/app/components/settings-card/preferred-clients/index.js index bf42849f9..12ab116d4 100644 --- a/ui/desktop/app/components/settings-card/preferred-clients/index.js +++ b/ui/desktop/app/components/settings-card/preferred-clients/index.js @@ -6,6 +6,7 @@ import Component from '@glimmer/component'; import { action } from '@ember/object'; import { service } from '@ember/service'; +import { RDP_CLIENT_NONE } from 'desktop/services/rdp'; const PROTOCOL_WINDOWS_RDP = 'windows-rdp'; @@ -32,7 +33,8 @@ export default class SettingsCardPreferredClientsComponent extends Component { get showRecommendedRdpClient() { return ( - this.rdp.rdpClients.length === 1 && this.rdp.rdpClients[0] === 'none' + this.rdp.rdpClients.length === 1 && + this.rdp.rdpClients[0] === RDP_CLIENT_NONE ); } diff --git a/ui/desktop/tests/acceptance/projects/sessions/session-test.js b/ui/desktop/tests/acceptance/projects/sessions/session-test.js index 486ef4bb3..29d969e45 100644 --- a/ui/desktop/tests/acceptance/projects/sessions/session-test.js +++ b/ui/desktop/tests/acceptance/projects/sessions/session-test.js @@ -15,6 +15,7 @@ import setupStubs from 'api/test-support/handlers/cache-daemon-search'; import { setRunOptions } from 'ember-a11y-testing/test-support'; import sinon from 'sinon'; import { TYPE_TARGET_RDP } from 'api/models/target'; +import { RDP_CLIENT_WINDOWS_APP, RDP_CLIENT_NONE } from 'desktop/services/rdp'; module('Acceptance | projects | sessions | session', function (hooks) { setupApplicationTest(hooks); @@ -598,7 +599,7 @@ module('Acceptance | projects | sessions | session', function (hooks) { test('visiting an RDP session should display "open" button when preferred client is set', async function (assert) { this.ipcStub.withArgs('cliExists').returns(true); - this.rdpService.preferredRdpClient = 'windows-app'; + this.rdpService.preferredRdpClient = RDP_CLIENT_WINDOWS_APP; instances.target.update({ type: TYPE_TARGET_RDP }); this.ipcStub.withArgs('connect').returns({ @@ -625,7 +626,7 @@ module('Acceptance | projects | sessions | session', function (hooks) { test('visiting an RDP session should not display "open" button when preferred client is set to none', async function (assert) { this.ipcStub.withArgs('cliExists').returns(true); - this.rdpService.preferredRdpClient = 'none'; + this.rdpService.preferredRdpClient = RDP_CLIENT_NONE; instances.target.update({ type: TYPE_TARGET_RDP }); this.ipcStub.withArgs('connect').returns({ @@ -646,7 +647,7 @@ module('Acceptance | projects | sessions | session', function (hooks) { test('it shows confirm modal when connection error occurs on launching rdp client', async function (assert) { this.ipcStub.withArgs('cliExists').returns(true); - this.rdpService.preferredRdpClient = 'windows-app'; + this.rdpService.preferredRdpClient = RDP_CLIENT_WINDOWS_APP; instances.target.update({ type: TYPE_TARGET_RDP }); this.ipcStub.withArgs('connect').returns({ @@ -674,7 +675,7 @@ module('Acceptance | projects | sessions | session', function (hooks) { test('it displays open button without cancel session permission', async function (assert) { this.ipcStub.withArgs('cliExists').returns(true); - this.rdpService.preferredRdpClient = 'windows-app'; + this.rdpService.preferredRdpClient = RDP_CLIENT_WINDOWS_APP; instances.target.update({ type: TYPE_TARGET_RDP }); instances.rdpSession.update({ authorized_actions: [] }); diff --git a/ui/desktop/tests/acceptance/projects/targets/index-test.js b/ui/desktop/tests/acceptance/projects/targets/index-test.js index 6008e5a4c..483c8c238 100644 --- a/ui/desktop/tests/acceptance/projects/targets/index-test.js +++ b/ui/desktop/tests/acceptance/projects/targets/index-test.js @@ -24,6 +24,7 @@ import { } from 'api/models/session'; import { TYPE_TARGET_RDP } from 'api/models/target'; import sinon from 'sinon'; +import { RDP_CLIENT_NONE, RDP_CLIENT_WINDOWS_APP } from 'desktop/services/rdp'; module('Acceptance | projects | targets | index', function (hooks) { setupApplicationTest(hooks); @@ -719,7 +720,7 @@ module('Acceptance | projects | targets | index', function (hooks) { }); test('shows `Open` button for RDP target with preferred client', async function (assert) { - this.rdpService.preferredRdpClient = 'windows-app'; + this.rdpService.preferredRdpClient = RDP_CLIENT_WINDOWS_APP; instances.target.update({ type: TYPE_TARGET_RDP, }); @@ -731,7 +732,7 @@ module('Acceptance | projects | targets | index', function (hooks) { }); test('shows `Connect` button for RDP target with no preferred client', async function (assert) { - this.rdpService.preferredRdpClient = 'none'; + this.rdpService.preferredRdpClient = RDP_CLIENT_NONE; instances.target.update({ type: TYPE_TARGET_RDP, }); @@ -752,7 +753,7 @@ module('Acceptance | projects | targets | index', function (hooks) { test('clicking `Open` button for RDP target calls launchRdpClient IPC', async function (assert) { this.ipcStub.withArgs('cliExists').returns(true); - this.rdpService.preferredRdpClient = 'windows-app'; + this.rdpService.preferredRdpClient = RDP_CLIENT_WINDOWS_APP; instances.target.update({ type: TYPE_TARGET_RDP }); this.ipcStub.withArgs('connect').returns({ @@ -776,7 +777,7 @@ module('Acceptance | projects | targets | index', function (hooks) { test('clicking `Connect` button for RDP target without preferred client calls connect IPC', async function (assert) { this.ipcStub.withArgs('cliExists').returns(true); - this.rdpService.preferredRdpClient = 'none'; + this.rdpService.preferredRdpClient = RDP_CLIENT_NONE; instances.target.update({ type: TYPE_TARGET_RDP }); this.ipcStub.withArgs('connect').returns({ @@ -797,7 +798,7 @@ module('Acceptance | projects | targets | index', function (hooks) { }); test('shows confirm modal when connection error occurs on launching rdp client', async function (assert) { - this.rdpService.preferredRdpClient = 'windows-app'; + this.rdpService.preferredRdpClient = RDP_CLIENT_WINDOWS_APP; instances.target.update({ type: TYPE_TARGET_RDP }); this.ipcStub.withArgs('cliExists').returns(true); diff --git a/ui/desktop/tests/acceptance/projects/targets/target-test.js b/ui/desktop/tests/acceptance/projects/targets/target-test.js index 8df611fd2..41932ad80 100644 --- a/ui/desktop/tests/acceptance/projects/targets/target-test.js +++ b/ui/desktop/tests/acceptance/projects/targets/target-test.js @@ -19,6 +19,7 @@ import setupStubs from 'api/test-support/handlers/cache-daemon-search'; import { setRunOptions } from 'ember-a11y-testing/test-support'; import { TYPE_TARGET_RDP } from 'api/models/target'; import sinon from 'sinon'; +import { RDP_CLIENT_WINDOWS_APP } from 'desktop/services/rdp'; module('Acceptance | projects | targets | target', function (hooks) { setupApplicationTest(hooks); @@ -635,7 +636,7 @@ module('Acceptance | projects | targets | target', function (hooks) { }); test('shows `Open` and `Connect` button for RDP target with preferred client', async function (assert) { - this.rdpService.preferredRdpClient = 'windows-app'; + this.rdpService.preferredRdpClient = RDP_CLIENT_WINDOWS_APP; instances.target.update({ type: TYPE_TARGET_RDP }); this.stubCacheDaemonSearch(); @@ -661,7 +662,7 @@ module('Acceptance | projects | targets | target', function (hooks) { }); test('clicking `open` button for RDP target triggers launchRdpClient', async function (assert) { - this.rdpService.preferredRdpClient = 'windows-app'; + this.rdpService.preferredRdpClient = RDP_CLIENT_WINDOWS_APP; instances.target.update({ type: TYPE_TARGET_RDP }); this.ipcStub.withArgs('cliExists').returns(true); @@ -709,7 +710,7 @@ module('Acceptance | projects | targets | target', function (hooks) { }); test('shows confirm modal when quickConnectAndLaunchRdp fails', async function (assert) { - this.rdpService.preferredRdpClient = 'windows-app'; + this.rdpService.preferredRdpClient = RDP_CLIENT_WINDOWS_APP; instances.target.update({ type: TYPE_TARGET_RDP }); this.stubCacheDaemonSearch();