Skip to content

Commit

Permalink
[APM] Fix focus map link on service map (#73338)
Browse files Browse the repository at this point in the history
The link was including `serviceName` from the `urlParams` so it was linking to the wrong service. Overwrite the service name so the link is correct.

Fixes #72911.
  • Loading branch information
smith authored Jul 27, 2020
1 parent 88aebc9 commit 5a47218
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import React from 'react';
import { Buttons } from './Buttons';
import { render } from '@testing-library/react';

describe('Popover Buttons', () => {
it('renders', () => {
expect(() =>
render(<Buttons selectedNodeServiceName="test service name" />)
).not.toThrowError();
});

it('handles focus click', async () => {
const onFocusClick = jest.fn();
const result = render(
<Buttons
onFocusClick={onFocusClick}
selectedNodeServiceName="test service name"
/>
);
const focusButton = await result.findByText('Focus map');

focusButton.click();

expect(onFocusClick).toHaveBeenCalledTimes(1);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ export function Buttons({
onFocusClick = () => {},
selectedNodeServiceName,
}: ButtonsProps) {
const urlParams = useUrlParams().urlParams as APMQueryParams;
// The params may contain the service name. We want to use the selected node's
// service name in the button URLs, so make a copy and set the
// `serviceName` property.
const urlParams = { ...useUrlParams().urlParams } as APMQueryParams;
urlParams.serviceName = selectedNodeServiceName;

const detailsUrl = getAPMHref(
`/services/${selectedNodeServiceName}/transactions`,
'',
Expand Down

0 comments on commit 5a47218

Please sign in to comment.