Skip to content

Commit

Permalink
[APM] Fix focus map link on service map (elastic#73338) (elastic#73359)
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 elastic#72911.
  • Loading branch information
kibanamachine authored Jul 28, 2020
1 parent c62f9e8 commit a3c79fb
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 a3c79fb

Please sign in to comment.