Skip to content

Commit

Permalink
Fix link in scatter plot when embed mode #282
Browse files Browse the repository at this point in the history
Signed-off-by: Alberto Gutierrez <aljesusg@gmail.com>
  • Loading branch information
aljesusg committed Nov 28, 2018
1 parent f50592b commit e1bbe6d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
6 changes: 4 additions & 2 deletions packages/jaeger-ui/src/components/SearchTracePage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import { fetchedState } from '../../constants';
import { sortTraces } from '../../model/search';
import getLastXformCacher from '../../utils/get-last-xform-cacher';
import prefixUrl from '../../utils/prefix-url';
import { isEmbed } from '../../utils/embedded';
import { isEmbed, VERSION_API } from '../../utils/embedded';

import './index.css';
import JaegerLogo from '../../img/jaeger-logo.svg';
Expand Down Expand Up @@ -61,7 +61,9 @@ export class SearchTracePageImpl extends Component {
}

goToTrace = traceID => {
const url = this.props.embed ? `/trace/${traceID}?embed` : `/trace/${traceID}`;
const url = this.props.embed
? `/trace/${traceID}?embed=${VERSION_API}&fromSearch=${encodeURIComponent(this.getSearchURL())}`
: `/trace/${traceID}`;
this.props.history.push(prefixUrl(url));
};

Expand Down
29 changes: 25 additions & 4 deletions packages/jaeger-ui/src/components/SearchTracePage/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import queryString from 'query-string';

jest.mock('redux-form', () => {
function reduxForm() {
return component => component;
Expand All @@ -30,6 +28,7 @@ jest.mock('store');

/* eslint-disable import/first */
import React from 'react';
import queryString from 'query-string';
import { shallow, mount } from 'enzyme';
import store from 'store';

Expand All @@ -40,6 +39,7 @@ import { fetchedState } from '../../constants';
import traceGenerator from '../../demo/trace-generators';
import { MOST_RECENT } from '../../model/order-by';
import transformTraceData from '../../model/transform-trace-data';
import { VERSION_API } from '../../utils/embedded';

describe('<SearchTracePage>', () => {
let wrapper;
Expand Down Expand Up @@ -84,11 +84,32 @@ describe('<SearchTracePage>', () => {
});

it('return the searchpath if call getSearchURL', () => {
const query = "end=1542906238737000&limit=20&lookback=1h&maxDuration&minDuration&service=productpage&start=1542902638737000"
wrapper = mount(<SearchTracePage {...props} query={query}/>);
const query =
'end=1542906238737000&limit=20&lookback=1h&maxDuration&minDuration&service=productpage&start=1542902638737000';
wrapper = mount(<SearchTracePage {...props} query={query} />);
expect(wrapper.instance().getSearchURL()).toBe(`/search?${queryString.stringify(query)}`);
});

it('Push to history the correct url when goToTrace', () => {
const query =
'end=1542906238737000&limit=20&lookback=1h&maxDuration&minDuration&service=productpage&start=1542902638737000';
const historyMock = { push: jest.fn() };
const traceID = '15810714d6a27450';
wrapper = mount(<SearchTracePage {...props} history={historyMock} query={query} />);
wrapper.instance().goToTrace(traceID);
expect(historyMock.push.mock.calls.length).toBe(1);
expect(historyMock.push.mock.calls[0][0]).toBe(`/trace/${traceID}`);

// Embed Mode
wrapper.setProps({ embed: true });
wrapper.instance().goToTrace(traceID);
expect(historyMock.push.mock.calls[1][0]).toBe(
`/trace/${traceID}?embed=${VERSION_API}&fromSearch=${encodeURIComponent(
wrapper.instance().getSearchURL()
)}`
);
});

it('shows a loading indicator if loading services', () => {
wrapper.setProps({ loadingServices: true });
expect(wrapper.find(LoadingIndicator).length).toBe(1);
Expand Down

0 comments on commit e1bbe6d

Please # to comment.