diff --git a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/details/host_details.tsx b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/details/host_details.tsx index fdd122ab3479ae..80c4e2f379c7c6 100644 --- a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/details/host_details.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/details/host_details.tsx @@ -106,7 +106,7 @@ export const HostDetails = memo(({ details }: { details: HostMetadata }) => { }, [details.host.id, formatUrl, queryParams]); const agentDetailsWithFlyoutPath = `${agentDetailsAppPath}${openReassignFlyoutSearch}`; - const agentDetailsWithFlyoutUrl = `${agentDetailsUrl}${openReassignFlyoutSearch};`; + const agentDetailsWithFlyoutUrl = `${agentDetailsUrl}${openReassignFlyoutSearch}`; const handleReassignEndpointsClick = useNavigateToAppEventHandler< AgentDetailsReassignConfigAction >(ingestAppId, { diff --git a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/index.test.tsx b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/index.test.tsx index 9690ac5c1b9bf9..d49b4db5c71e24 100644 --- a/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/index.test.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/endpoint_hosts/view/index.test.tsx @@ -210,6 +210,7 @@ describe('when on the hosts page', () => { describe('when there is a selected host in the url', () => { let hostDetails: HostInfo; + let agentId: string; const dispatchServerReturnedHostPolicyResponse = ( overallStatus: HostPolicyResponseActionStatus = HostPolicyResponseActionStatus.success ) => { @@ -274,6 +275,8 @@ describe('when on the hosts page', () => { }, }; + agentId = hostDetails.metadata.elastic.agent.id; + coreStart.http.get.mockReturnValue(Promise.resolve(hostDetails)); coreStart.application.getUrlForApp.mockReturnValue('/app/logs'); @@ -404,6 +407,32 @@ describe('when on the hosts page', () => { ).not.toBeNull(); }); + it('should include the link to reassignment in Ingest', async () => { + coreStart.application.getUrlForApp.mockReturnValue('/app/ingestManager'); + const renderResult = render(); + const linkToLogs = await renderResult.findByTestId('hostDetailsLinkToIngest'); + expect(linkToLogs).not.toBeNull(); + expect(linkToLogs.textContent).toEqual('Reassign Policy'); + expect(linkToLogs.getAttribute('href')).toEqual( + `/app/ingestManager#/fleet/agents/${agentId}/activity?openReassignFlyout=true` + ); + }); + + describe('when link to reassignment in Ingest is clicked', () => { + beforeEach(async () => { + coreStart.application.getUrlForApp.mockReturnValue('/app/ingestManager'); + const renderResult = render(); + const linkToLogs = await renderResult.findByTestId('hostDetailsLinkToIngest'); + reactTestingLibrary.act(() => { + reactTestingLibrary.fireEvent.click(linkToLogs); + }); + }); + + it('should navigate to logs without full page refresh', () => { + expect(coreStart.application.navigateToApp.mock.calls).toHaveLength(1); + }); + }); + it('should include the link to logs', async () => { const renderResult = render(); const linkToLogs = await renderResult.findByTestId('hostDetailsLinkToLogs');