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
3 changes: 3 additions & 0 deletions src/libs/Navigation/linkingConfig/OldRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ const oldRoutes: Record<string, string> = {
'/*/*/merchant/*/*': '/r/$4/expense-merchant?action=$1&iouType=$2&transactionID=$3&reportID=$4',
'/*/*/description/*/*/*': '/r/$4/expense-description?action=$1&iouType=$2&transactionID=$3&reportID=$4&reportActionID=$5',
'/*/*/description/*/*': '/r/$4/expense-description?action=$1&iouType=$2&transactionID=$3&reportID=$4',
// Keeps the split edit route opened from the Search split overview's Date tab as-is
// (/search/split-expense-overview-search/date/split-expense/edit/...), otherwise the legacy date patterns below rewrite it into a broken route.
'/*/*/date/split-expense/edit/*': '/$1/$2/date/split-expense/edit/$3',
'/*/*/date/*/*/*': '/r/$4/expense-date?action=$1&iouType=$2&transactionID=$3&reportID=$4&reportActionID=$5',
'/*/*/date/*/*': '/r/$4/expense-date?action=$1&iouType=$2&transactionID=$3&reportID=$4',
'/*/*/participants/participants-details/*': '/$1/$2/participants/participants-details/$3',
Expand Down
10 changes: 10 additions & 0 deletions tests/navigation/getMatchingNewRouteTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,16 @@ describe('getBestMatchingPath', () => {
expect(getMatchingNewRoute('/edit/split-expense/overview/123/456/789?backTo=/r/123')).toBe('/create/split-expense/overview/123/456/0/split-expense/edit/123/789?backTo=/r/123');
});

it('does not rewrite the split expense edit route opened from the Date tab of the Search split overview', () => {
// Given a split edit URL built on top of the Search split overview while the Date tab is active
const splitEditPath = '/search/split-expense-overview-search/date/split-expense/edit/123/456';

// When it is matched against the legacy routes
// Then it comes back unchanged, so the legacy `/*/*/date/*/*/*` pattern can't turn it into a broken expense-date route
expect(getMatchingNewRoute(splitEditPath)).toBe(splitEditPath);
expect(getMatchingNewRoute(`${splitEditPath}?backTo=/search`)).toBe(`${splitEditPath}?backTo=/search`);
});

it('redirects old card reconciliation account path with two wildcards', () => {
expect(getMatchingNewRoute('/workspaces/abc/accounting/xero/card-reconciliation/account')).toBe(
'/workspaces/abc/accounting/xero/card-reconciliation/account-reconciliation-settings',
Expand Down
Loading