[Segment Cache] Fix tests related to optimistic loading state reuse (#84498)
When navigating to a route that reads from search params, and there's no
matching route prefetch in the cache, we use a trick where we
optimistically assume that a route will not be rewritten or redirected
based on the search string. So, if we have a matching entry with the
same pathname but different search params, we can construct a route tree
based on that before making a new network request. Then, the router can
show the loading state.
We should be able to reuse any route entry that shares the same
pathname, but for now, we special case the empty search string. The plan
is to refactor the data structure that stores route entries to support
efficient lookups by pathname.
But for now, the workaround is: whenever prefetching a page with a
non-empty search string, also prefetch the route tree for the same
pathname and an empty search string. (Just the route tree, no data.)