Skip to content
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
21 changes: 4 additions & 17 deletions x-pack/legacy/plugins/apm/public/utils/testHelpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,23 +151,10 @@ export async function inspectSearchParams(
const mockSetup = {
start: 1528113600000,
end: 1528977600000,
client: {
search: spy
} as any,
internalClient: {
search: spy
} as any,
config: new Proxy(
{},
{
get: () => 'myIndex'
}
) as APMConfig,
uiFiltersES: [
{
term: { 'service.environment': 'prod' }
}
],
client: { search: spy } as any,
internalClient: { search: spy } as any,
config: new Proxy({}, { get: () => 'myIndex' }) as APMConfig,
uiFiltersES: [{ term: { 'my.custom.ui.filter': 'foo-bar' } }],
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Collapsed these for readability and changed term: { 'service.environment': 'prod' } to term: { 'my.custom.ui.filter': 'foo-bar' to make it clear in the snapshots that it's the ui filter value.

indices: {
'apm_oss.sourcemapIndices': 'myIndex',
'apm_oss.errorIndices': 'myIndex',
Expand Down

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

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

Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export async function getErrorGroup({

let transaction;
if (transactionId && traceId) {
transaction = await getTransaction(transactionId, traceId, setup);
transaction = await getTransaction({ transactionId, traceId, setup });
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using destructuring for consistency with other functions.

}

return {
Expand Down

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

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

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

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

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

Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@ import {
} from '../../helpers/setup_request';
import { ProcessorEvent } from '../../../../common/processor_event';

export async function getTransaction(
transactionId: string,
traceId: string,
setup: Setup & SetupTimeRange & SetupUIFilters
) {
const { start, end, uiFiltersES, client, indices } = setup;
export async function getTransaction({
transactionId,
traceId,
setup
}: {
transactionId: string;
traceId: string;
setup: Setup & SetupTimeRange & SetupUIFilters;
}) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I converted the function signature to use a destructured object. Therefore the noise.

const { start, end, client, indices } = setup;

const params = {
index: indices['apm_oss.transactionIndices'],
Expand All @@ -35,8 +39,7 @@ export async function getTransaction(
{ term: { [PROCESSOR_EVENT]: ProcessorEvent.transaction } },
{ term: { [TRANSACTION_ID]: transactionId } },
{ term: { [TRACE_ID]: traceId } },
{ range: rangeFilter(start, end) },
...uiFiltersES
{ range: rangeFilter(start, end) }
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer, look here: this is the meat of the PR. ...uiFiltersES was removed.

]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ describe('transaction queries', () => {

it('fetches a transaction', async () => {
mock = await inspectSearchParams(setup =>
getTransaction('foo', 'bar', setup)
getTransaction({ transactionId: 'foo', traceId: 'bar', setup })
);

expect(mock.params).toMatchSnapshot();
Expand Down

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