Fix deep-linking and added e2e tests (#140286)

* Fix deep-linking and added e2e tests

* fix url check

* pr suggestions
This commit is contained in:
Miriam 2022-09-09 09:55:05 +01:00 committed by GitHub
parent 7a602e0684
commit b8457c10de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 12 deletions

View file

@ -55,4 +55,14 @@ describe('Transaction details', () => {
.click();
cy.url().should('include', 'opbeans-java/errors');
});
describe('when navigating to a trace sample', () => {
it('keeps the same trace sample after reloading the page', () => {
cy.get('[data-test-subj="pagination-button-last"]').click();
cy.url().then((url) => {
cy.reload();
cy.url().should('eq', url);
});
});
});
});

View file

@ -22,6 +22,7 @@ import { failedTransactionsCorrelationsTab } from './failed_transactions_correla
import { latencyCorrelationsTab } from './latency_correlations_tab';
import { traceSamplesTab } from './trace_samples_tab';
import { useSampleChartSelection } from '../../../hooks/use_sample_chart_selection';
import { FETCH_STATUS } from '../../../hooks/use_fetcher';
const tabs = [
traceSamplesTab,
@ -69,7 +70,7 @@ export function TransactionDetailsTabs() {
sample.transactionId === transactionId && sample.traceId === traceId
);
if (!selectedSample) {
if (traceSamplesStatus === FETCH_STATUS.SUCCESS && !selectedSample) {
// selected sample was not found. select a new one:
const preferredSample = maybe(traceSamples[0]);
@ -84,7 +85,7 @@ export function TransactionDetailsTabs() {
}),
});
}
}, [history, traceSamples, transactionId, traceId]);
}, [history, traceSamples, transactionId, traceId, traceSamplesStatus]);
return (
<>

View file

@ -91,12 +91,14 @@ export function WaterfallWithSummary({
</EuiTitle>
</EuiFlexItem>
<EuiFlexItem>
<EuiPagination
pageCount={traceSamples?.length ?? 0}
activePage={sampleActivePage}
onPageClick={goToSample}
compressed
/>
{traceSamples.length > 0 && (
<EuiPagination
pageCount={traceSamples.length}
activePage={sampleActivePage}
onPageClick={goToSample}
compressed
/>
)}
</EuiFlexItem>
<EuiFlexItem>
<EuiFlexGroup justifyContent="flexEnd">

View file

@ -46,9 +46,9 @@ export function useTransactionTraceSamplesFetcher({
status,
error,
} = useFetcher(
async (callApmApi) => {
(callApmApi) => {
if (serviceName && start && end && transactionType && transactionName) {
const response = await callApmApi(
return callApmApi(
'GET /internal/apm/services/{serviceName}/transactions/traces/samples',
{
params: {
@ -70,8 +70,6 @@ export function useTransactionTraceSamplesFetcher({
},
}
);
return response;
}
},
// the samples should not be refetched if the transactionId or traceId changes