Skip to content

Commit

Permalink
[User Experience App] Update to make sure env filter is being used (e…
Browse files Browse the repository at this point in the history
…lastic#102063) (elastic#102185)

Co-authored-by: Shahzad <shahzad.muhammad@elastic.co>
  • Loading branch information
kibanamachine and shahzad31 authored Jun 15, 2021
1 parent 1959e30 commit 2cb387b
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 20 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 27 additions & 18 deletions x-pack/plugins/apm/server/lib/rum_client/queries.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { getRumServices } from './get_rum_services';
import { getLongTaskMetrics } from './get_long_task_metrics';
import { getWebCoreVitals } from './get_web_core_vitals';
import { getJSErrors } from './get_js_errors';
import { ENVIRONMENT_ALL } from '../../../common/environment_filter_values';

describe('rum client dashboard queries', () => {
let mock: SearchParamsMock;
Expand All @@ -25,32 +26,38 @@ describe('rum client dashboard queries', () => {
});

it('fetches client metrics', async () => {
mock = await inspectSearchParams((setup) =>
getClientMetrics({
setup,
})
mock = await inspectSearchParams(
(setup) =>
getClientMetrics({
setup,
}),
{ uiFilters: { environment: 'staging' } }
);

expect(mock.params).toMatchSnapshot();
});

it('fetches page view trends', async () => {
mock = await inspectSearchParams((setup) =>
getPageViewTrends({
setup,
})
mock = await inspectSearchParams(
(setup) =>
getPageViewTrends({
setup,
}),
{ uiFilters: { environment: 'staging' } }
);

expect(mock.params).toMatchSnapshot();
});

it('fetches page load distribution', async () => {
mock = await inspectSearchParams((setup) =>
getPageLoadDistribution({
setup,
minPercentile: '0',
maxPercentile: '99',
})
mock = await inspectSearchParams(
(setup) =>
getPageLoadDistribution({
setup,
minPercentile: '0',
maxPercentile: '99',
}),
{ uiFilters: { environment: 'staging' } }
);
expect(mock.params).toMatchSnapshot();
});
Expand All @@ -65,10 +72,12 @@ describe('rum client dashboard queries', () => {
});

it('fetches rum core vitals', async () => {
mock = await inspectSearchParams((setup) =>
getWebCoreVitals({
setup,
})
mock = await inspectSearchParams(
(setup) =>
getWebCoreVitals({
setup,
}),
{ uiFilters: { environment: ENVIRONMENT_ALL.value } }
);
expect(mock.params).toMatchSnapshot();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import { ESFilter } from '../../../../../../../typings/elasticsearch';
import { UIFilters } from '../../../../typings/ui_filters';
import { localUIFilters, localUIFilterNames } from './local_ui_filters/config';
import { environmentQuery } from '../../../utils/queries';

export function getEsFilter(uiFilters: UIFilters) {
const localFilterValues = uiFilters;
Expand All @@ -23,5 +24,5 @@ export function getEsFilter(uiFilters: UIFilters) {
};
}) as ESFilter[];

return mappedFilters;
return [...mappedFilters, ...environmentQuery(uiFilters.environment)];
}
3 changes: 2 additions & 1 deletion x-pack/plugins/apm/server/utils/test_helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ interface Options {
mockResponse?: (
request: ESSearchRequest
) => ESSearchResponse<unknown, ESSearchRequest>;
uiFilters?: Record<string, string>;
}

interface MockSetup {
Expand Down Expand Up @@ -86,7 +87,7 @@ export async function inspectSearchParams(
},
}
) as APMConfig,
uiFilters: {},
uiFilters: options?.uiFilters ?? {},
indices: {
/* eslint-disable @typescript-eslint/naming-convention */
'apm_oss.sourcemapIndices': 'myIndex',
Expand Down

0 comments on commit 2cb387b

Please sign in to comment.