@@ -19,6 +19,7 @@ import { authenticateSession } from 'ember-simple-auth/test-support';
1919import WindowMockIPC from '../../../helpers/window-mock-ipc' ;
2020import setupStubs from 'api/test-support/handlers/cache-daemon-search' ;
2121import { setRunOptions } from 'ember-a11y-testing/test-support' ;
22+ import { TYPE_TARGET_RDP } from 'api/models/target' ;
2223
2324module ( 'Acceptance | projects | targets | target' , function ( hooks ) {
2425 setupApplicationTest ( hooks ) ;
@@ -28,6 +29,7 @@ module('Acceptance | projects | targets | target', function (hooks) {
2829 const TARGET_RESOURCE_LINK = ( id ) => `[data-test-visit-target="${ id } "]` ;
2930 const TARGET_TABLE_CONNECT_BUTTON = ( id ) =>
3031 `[data-test-targets-connect-button="${ id } "]` ;
32+ const TARGET_TABLE_DETAILS_OPEN_BUTTON = `[data-test-target-detail-open-button]` ;
3133 const TARGET_CONNECT_BUTTON = '[data-test-target-detail-connect-button]' ;
3234 const TARGET_HOST_SOURCE_CONNECT_BUTTON = ( id ) =>
3335 `[data-test-target-connect-button=${ id } ]` ;
@@ -576,6 +578,7 @@ module('Acceptance | projects | targets | target', function (hooks) {
576578 assert . strictEqual ( currentURL ( ) , urls . targetWithOneHost ) ;
577579 assert . dom ( '.aliases' ) . exists ( ) ;
578580 } ) ;
581+
579582 test ( 'user can connect to a target without read permissions for host-set' , async function ( assert ) {
580583 setRunOptions ( {
581584 rules : {
@@ -631,4 +634,80 @@ module('Acceptance | projects | targets | target', function (hooks) {
631634
632635 assert . dom ( APP_STATE_TITLE ) . hasText ( 'Connected' ) ;
633636 } ) ;
637+
638+ test ( 'shows "Open" button for RDP target with preferred client' , async function ( assert ) {
639+ let rdpService = this . owner . lookup ( 'service:rdp' ) ;
640+ rdpService . preferredRdpClient = 'windows-app' ;
641+ instances . target . update ( { type : TYPE_TARGET_RDP } ) ;
642+
643+ this . stubCacheDaemonSearch ( ) ;
644+
645+ await visit ( urls . target ) ;
646+
647+ assert . dom ( TARGET_TABLE_DETAILS_OPEN_BUTTON ) . exists ( ) ;
648+ assert . dom ( TARGET_TABLE_DETAILS_OPEN_BUTTON ) . hasText ( 'Open' ) ;
649+ assert . dom ( '[data-test-icon=external-link]' ) . exists ( ) ;
650+ } ) ;
651+
652+ test ( 'shows "Connect" button for RDP target without preferred client' , async function ( assert ) {
653+ let rdpService = this . owner . lookup ( 'service:rdp' ) ;
654+ rdpService . preferredRdpClient = null ;
655+ instances . target . update ( { type : TYPE_TARGET_RDP } ) ;
656+
657+ this . stubCacheDaemonSearch ( ) ;
658+
659+ await visit ( urls . target ) ;
660+
661+ assert . dom ( TARGET_CONNECT_BUTTON ) . exists ( ) ;
662+ assert . dom ( TARGET_CONNECT_BUTTON ) . hasText ( 'Connect' ) ;
663+ } ) ;
664+
665+ test ( 'clicking `open` button for RDP target triggers launchRdpClient' , async function ( assert ) {
666+ let rdpService = this . owner . lookup ( 'service:rdp' ) ;
667+ rdpService . preferredRdpClient = 'windows-app' ;
668+ instances . target . update ( { type : TYPE_TARGET_RDP } ) ;
669+
670+ this . ipcStub . withArgs ( 'cliExists' ) . returns ( true ) ;
671+ this . ipcStub . withArgs ( 'connect' ) . returns ( {
672+ session_id : instances . session . id ,
673+ address : 'a_123' ,
674+ port : 'p_123' ,
675+ protocol : 'rdp' ,
676+ } ) ;
677+ this . stubCacheDaemonSearch ( ) ;
678+ this . ipcStub . withArgs ( 'launchRdpClient' ) . resolves ( ) ;
679+
680+ const confirmService = this . owner . lookup ( 'service:confirm' ) ;
681+ confirmService . enabled = true ;
682+
683+ await visit ( urls . target ) ;
684+
685+ await click ( TARGET_TABLE_DETAILS_OPEN_BUTTON ) ;
686+
687+ assert . ok ( this . ipcStub . calledWith ( 'launchRdpClient' , instances . session . id ) ) ;
688+ } ) ;
689+
690+ test ( 'shows `Connect` button for rdp target without preferred client' , async function ( assert ) {
691+ let rdpService = this . owner . lookup ( 'service:rdp' ) ;
692+ rdpService . preferredRdpClient = null ;
693+ instances . target . update ( { type : TYPE_TARGET_RDP } ) ;
694+
695+ this . stubCacheDaemonSearch ( ) ;
696+ this . ipcStub . withArgs ( 'cliExists' ) . returns ( true ) ;
697+ this . ipcStub . withArgs ( 'connect' ) . returns ( {
698+ session_id : instances . session . id ,
699+ address : 'a_123' ,
700+ port : 'p_123' ,
701+ protocol : 'rdp' ,
702+ } ) ;
703+ await visit ( urls . target ) ;
704+
705+ assert . dom ( TARGET_CONNECT_BUTTON ) . exists ( ) ;
706+ assert . dom ( TARGET_CONNECT_BUTTON ) . hasText ( 'Connect' ) ;
707+
708+ await click ( TARGET_CONNECT_BUTTON ) ;
709+
710+ assert . ok ( this . ipcStub . calledWith ( 'connect' ) ) ;
711+ assert . notOk ( this . ipcStub . calledWith ( 'launchRdpClient' ) ) ;
712+ } ) ;
634713} ) ;
0 commit comments