Skip to content

Commit

Permalink
ref(js): Make performance/trends compatible with react-router 6 (#76446)
Browse files Browse the repository at this point in the history
  • Loading branch information
evanpurkhiser committed Aug 26, 2024
1 parent 11e64a4 commit 7a5535f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
20 changes: 12 additions & 8 deletions static/app/views/performance/trends/changedTransactions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -625,18 +625,22 @@ function TransactionSummaryLink(props: TransactionSummaryLinkProps) {
},
});

const handleClick = useCallback(() => {
onTransactionSelection(transaction.transaction);
trackAnalytics('performance_views.performance_change_explorer.open', {
organization,
transaction: transaction.transaction,
});
}, [onTransactionSelection, transaction.transaction, organization]);
const handleClick = useCallback<React.MouseEventHandler>(
event => {
event.preventDefault();
onTransactionSelection(transaction.transaction);
trackAnalytics('performance_views.performance_change_explorer.open', {
organization,
transaction: transaction.transaction,
});
},
[onTransactionSelection, transaction.transaction, organization]
);

if (organization.features.includes('performance-change-explorer')) {
return (
<ItemTransactionName
to=""
to={location}
data-test-id="item-transaction-name"
onClick={handleClick}
>
Expand Down
13 changes: 11 additions & 2 deletions static/app/views/performance/trends/index.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ function initializeTrendsData(
organization,
router: {
location: {
pathname: '/trends/',
query: newQuery,
},
},
Expand Down Expand Up @@ -365,7 +366,10 @@ describe('Performance > Trends', function () {

const summaryLink = within(firstTransaction).getByTestId('item-transaction-name');

expect(summaryLink.closest('a')).not.toHaveAttribute('href');
expect(summaryLink.closest('a')).toHaveAttribute(
'href',
'/trends/?project=1&query=tpm%28%29%3A%3E0.01%20transaction.duration%3A%3E0%20transaction.duration%3A%3C15min'
);

await clickEl(summaryLink);
await waitFor(() => {
Expand Down Expand Up @@ -400,6 +404,7 @@ describe('Performance > Trends', function () {
await clickEl(menuAction);

expect(browserHistory.push).toHaveBeenCalledWith({
pathname: '/trends/',
query: expect.objectContaining({
project: expect.anything(),
query: `tpm():>0.01 transaction.duration:>0 transaction.duration:<${DEFAULT_MAX_DURATION} !transaction:/organizations/:orgId/performance/`,
Expand All @@ -424,7 +429,7 @@ describe('Performance > Trends', function () {

await waitFor(() =>
expect(browserHistory.push).toHaveBeenCalledWith({
pathname: undefined,
pathname: '/trends/',
query: expect.objectContaining({
project: ['1'],
query: 'transaction.duration:>9000',
Expand Down Expand Up @@ -458,6 +463,7 @@ describe('Performance > Trends', function () {
await clickEl(menuAction);

expect(browserHistory.push).toHaveBeenCalledWith({
pathname: '/trends/',
query: expect.objectContaining({
project: expect.anything(),
query: 'tpm():>0.01 transaction.duration:>0 transaction.duration:<=863',
Expand Down Expand Up @@ -488,6 +494,7 @@ describe('Performance > Trends', function () {
await clickEl(menuAction);

expect(browserHistory.push).toHaveBeenCalledWith({
pathname: '/trends/',
query: expect.objectContaining({
project: expect.anything(),
query: 'tpm():>0.01 transaction.duration:<15min transaction.duration:>=863',
Expand Down Expand Up @@ -517,6 +524,7 @@ describe('Performance > Trends', function () {
await clickEl(option);

expect(browserHistory.push).toHaveBeenCalledWith({
pathname: '/trends/',
query: expect.objectContaining({
regressionCursor: undefined,
improvedCursor: undefined,
Expand Down Expand Up @@ -596,6 +604,7 @@ describe('Performance > Trends', function () {
await clickEl(option);

expect(browserHistory.push).toHaveBeenCalledWith({
pathname: '/trends/',
query: expect.objectContaining({
trendParameter: parameter.label,
}),
Expand Down

0 comments on commit 7a5535f

Please sign in to comment.