@@ -79,7 +79,19 @@ describe('when on the hosts page', () => {
7979 } ) ;
8080
8181 describe ( 'when there is a selected host in the url' , ( ) => {
82+ let hostDetails : HostMetadata ;
8283 beforeEach ( ( ) => {
84+ const { host, ...details } = mockHostDetailsApiResult ( ) ;
85+ hostDetails = {
86+ ...details ,
87+ host : {
88+ ...host ,
89+ id : '1' ,
90+ } ,
91+ } ;
92+
93+ coreStart . application . getUrlForApp . mockReturnValue ( '/app/logs' ) ;
94+
8395 reactTestingLibrary . act ( ( ) => {
8496 history . push ( {
8597 ...history . location ,
@@ -89,10 +101,14 @@ describe('when on the hosts page', () => {
89101 reactTestingLibrary . act ( ( ) => {
90102 store . dispatch ( {
91103 type : 'serverReturnedHostDetails' ,
92- payload : mockHostDetailsApiResult ( ) ,
104+ payload : hostDetails ,
93105 } ) ;
94106 } ) ;
95107 } ) ;
108+ afterEach ( ( ) => {
109+ jest . clearAllMocks ( ) ;
110+ } ) ;
111+
96112 it ( 'should show the flyout' , ( ) => {
97113 const renderResult = render ( ) ;
98114 return renderResult . findByTestId ( 'hostDetailsFlyout' ) . then ( flyout => {
@@ -103,6 +119,17 @@ describe('when on the hosts page', () => {
103119 const renderResult = render ( ) ;
104120 const linkToLogs = await renderResult . findByTestId ( 'hostDetailsLinkToLogs' ) ;
105121 expect ( linkToLogs ) . not . toBeNull ( ) ;
122+ expect ( linkToLogs . textContent ) . toEqual ( 'Endpoint Logs' ) ;
123+ expect ( linkToLogs . attributes . href . value ) . toEqual (
124+ "/app/logs/stream?logFilter=(expression:'host.id:1',kind:kuery)"
125+ ) ;
126+ } ) ;
127+ it . skip ( 'should navigate to logs without full page refresh' , async ( ) => {
128+ const renderResult = render ( ) ;
129+ const linkToLogs = await renderResult . findByTestId ( 'hostDetailsLinkToLogs' ) ;
130+ expect ( coreStart . application . navigateToApp . mock . calls ) . toHaveLength ( 0 ) ;
131+ fireEvent . click ( linkToLogs ) ;
132+ expect ( coreStart . application . navigateToApp . mock . calls ) . toHaveLength ( 1 ) ;
106133 } ) ;
107134 } ) ;
108135} ) ;
0 commit comments