Skip to content

Commit

Permalink
refacroting test
Browse files Browse the repository at this point in the history
  • Loading branch information
cauemarcondes committed May 13, 2020
1 parent ba5c464 commit 55e63ce
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,14 @@ describe('ErrorMarker', () => {
expectTextsInDocument(component, ['10,000 μs']);
return component;
}
function getKueryDecoded(url: string) {
return decodeURIComponent(url.substring(url.indexOf('kuery='), url.length));
}
it('renders link with trace and transaction', () => {
const component = openPopover(mark);
const errorLink = component.getByTestId('errorLink') as HTMLAnchorElement;
expect(errorLink.href).toEqual(
'http://localhost/#/services/bar/errors/123?rangeFrom=&rangeTo=&refreshPaused=true&refreshInterval=0&kuery=trace.id%2520%253A%2520%2522123%2522%2520and%2520transaction.id%2520%253A%2520%2522456%2522'
expect(getKueryDecoded(errorLink.hash)).toEqual(
'kuery=trace.id : "123" and transaction.id : "456"'
);
});
it('renders link with trace', () => {
Expand All @@ -49,9 +52,7 @@ describe('ErrorMarker', () => {
} as ErrorMark;
const component = openPopover(newMark);
const errorLink = component.getByTestId('errorLink') as HTMLAnchorElement;
expect(errorLink.href).toEqual(
'http://localhost/#/services/bar/errors/123?rangeFrom=&rangeTo=&refreshPaused=true&refreshInterval=0&kuery=trace.id%2520%253A%2520%2522123%2522'
);
expect(getKueryDecoded(errorLink.hash)).toEqual('kuery=trace.id : "123"');
});
it('renders link with transaction', () => {
const { trace, ...withoutTrace } = mark.error;
Expand All @@ -61,8 +62,8 @@ describe('ErrorMarker', () => {
} as ErrorMark;
const component = openPopover(newMark);
const errorLink = component.getByTestId('errorLink') as HTMLAnchorElement;
expect(errorLink.href).toEqual(
'http://localhost/#/services/bar/errors/123?rangeFrom=&rangeTo=&refreshPaused=true&refreshInterval=0&kuery=transaction.id%2520%253A%2520%2522456%2522'
expect(getKueryDecoded(errorLink.hash)).toEqual(
'kuery=transaction.id : "456"'
);
});
it('renders link without trance and transaction', () => {
Expand All @@ -73,8 +74,6 @@ describe('ErrorMarker', () => {
} as ErrorMark;
const component = openPopover(newMark);
const errorLink = component.getByTestId('errorLink') as HTMLAnchorElement;
expect(errorLink.href).toEqual(
'http://localhost/#/services/bar/errors/123?rangeFrom=&rangeTo=&refreshPaused=true&refreshInterval=0&kuery='
);
expect(getKueryDecoded(errorLink.hash)).toEqual('kuery=');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,12 @@ export const ErrorMarker: React.FC<Props> = ({ mark }) => {
const { rangeTo, rangeFrom } = urlParams;

const query = {
kuery: encodeURIComponent(
[
...(error.trace?.id ? [`${TRACE_ID} : "${error.trace?.id}"`] : []),
...(error.transaction?.id
? [`${TRANSACTION_ID} : "${error.transaction?.id}"`]
: [])
].join(' and ')
),
kuery: [
...(error.trace?.id ? [`${TRACE_ID} : "${error.trace?.id}"`] : []),
...(error.transaction?.id
? [`${TRANSACTION_ID} : "${error.transaction?.id}"`]
: [])
].join(' and '),
rangeFrom,
rangeTo
};
Expand Down

0 comments on commit 55e63ce

Please sign in to comment.