Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: service operations fetch by URL query params #932

Merged
merged 3 commits into from
Apr 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ export class SearchTracePageImpl extends Component {
fetchMultipleTraces(needForDiffs);
}
fetchServices();
const { service } = store.get('lastSearch') || {};
let { service } = store.get('lastSearch') || {};
if (urlQueryParams && urlQueryParams.service) {
service = urlQueryParams.service;
}
if (service && service !== '-') {
fetchServiceOperations(service);
}
Expand Down
17 changes: 17 additions & 0 deletions packages/jaeger-ui/src/components/SearchTracePage/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,22 @@ describe('<SearchTracePage>', () => {
});

it('loads the services and operations if a service is stored', () => {
props.fetchServices.mockClear();
props.fetchServiceOperations.mockClear();
const oldFn = store.get;
store.get = jest.fn(() => ({ service: 'svc-b' }));
wrapper = mount(
<MemoryRouter>
<SearchTracePage {...{ ...props, urlQueryParams: {} }} />
</MemoryRouter>
);
expect(props.fetchServices.mock.calls.length).toBe(1);
expect(props.fetchServiceOperations.mock.calls.length).toBe(1);
expect(props.fetchServiceOperations.mock.calls[0][0]).toBe('svc-b');
store.get = oldFn;
});

it('loads the operations linked to the URL service parameter if present', () => {
props.fetchServices.mockClear();
props.fetchServiceOperations.mockClear();
const oldFn = store.get;
Expand All @@ -84,6 +100,7 @@ describe('<SearchTracePage>', () => {
);
expect(props.fetchServices.mock.calls.length).toBe(1);
expect(props.fetchServiceOperations.mock.calls.length).toBe(1);
expect(props.fetchServiceOperations.mock.calls[0][0]).toBe('svc-a');
store.get = oldFn;
});

Expand Down