refactor: 💡 updated magic strings with const (#3064)

This commit is contained in:
Priya Patel authored and Dharini committed 2025-11-19 14:22:07 -08:00
1 parent d2cf82b85c
commit 5faf830d46
4 files changed
+18 -13

No files matched your search

@@ -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
);
}
@@ -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: [] });
@@ -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);
@@ -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();