rsnext/test
Wyatt Johnson f0e4298f67
Ensure urlPathname is always a pathname (#63846)
### What?

This modifies the static generation store to instead store a `url`
object with the `pathname` and `search` properties. This corrects the
previous behaviour which used the variable `urlPathname` which had
ambiguous meanings as it technically contained the search string as
well, not just the pathname.

In cases during the app render, this still grabs the contents of
`url.pathname + url.search` (where `url.search` always has a leading `?`
if it has any query parameters, [see the
docs](https://developer.mozilla.org/en-US/docs/Web/API/URL/search)) so
that it emulates the current behaviour. This allows more specific access
though, where now additional parsing can be eliminated which had to
strip the query string off of the `urlPathname` in a few places, and
more worrisome, still accidentally contained the search string causing
errors.

### How?

This requires an upstream fix (#64088) which corrected a bug with the
store access which had caused some previous test failures (accessing
`store.url.pathname` was throwing as `store.url` was undefined on the
wrong return, check the upstream PR for more details on that).

This also changes out usage of `pagePath` with `route`, and lets it be
the fallback (for debugging and error messaging). During static
generation, we will provide a value for the page being rendered that's
correlated to the particular file on the filesystem that the route is
based on:

```
// rendering app/users/[userID]/page.tsx
page: /users/[userID]
pathname: /users/1, /users/2, etc
```

The `route` is used only for debugging, such as when
`generateStaticParams` incorrectly calls `headers()`.

This also moves the pathname from the `staticGenerationStore` into the
`requestStore`, as it's tied to a given request.

Closes NEXT-2965
2024-06-11 12:49:07 -07:00
..
.stats-app Update React from 1df34bdf62 to 6230622a1a (#66726) 2024-06-11 00:06:12 +00:00
development feat(turbopack-ecmascript): cache external modules with wrapper (#63337) 2024-06-10 15:39:40 +00:00
e2e fix: app-router prefetch crash when an invalid URL is passed to Link (#66755) 2024-06-11 21:36:27 +02:00
examples Replace createNextDescribe with nextTestSetup (#64817) 2024-04-25 12:06:12 -06:00
integration tweak flaky module-imports test (#66728) 2024-06-10 23:29:49 +00:00
lib Update React from f994737d14 to 1df34bdf62 (19.0.0-rc.0) (#66533) 2024-06-10 12:06:38 +00:00
production Use addDependency to track metadata route file changes (#66714) 2024-06-11 17:19:23 +02:00
unit Ensure urlPathname is always a pathname (#63846) 2024-06-11 12:49:07 -07:00
.gitignore ci(workflow): enable test trace upload (#51107) 2023-06-12 17:14:13 +00:00
build-turbopack-build-tests-manifest.js Ensure production integration test results are uploaded (#63706) 2024-03-26 10:41:16 +01:00
build-turbopack-dev-tests-manifest.js Rename turbopack-tests-manifest to turbopack-dev-tests-manifest (#63409) 2024-03-19 10:26:14 +01:00
build-turbopack-tests-manifest.d.ts Update Turbopack test manifest from GitHub Actions artifact (#58394) 2023-11-24 16:48:12 +01:00
get-test-filter.js run tests from test suite that are not listed in the manifest (#58401) 2024-01-11 07:38:35 +00:00
jest-setup-after-env.ts Decrease default test timeouts (#56116) 2023-09-27 23:55:20 +00:00
ppr-tests-manifest.json Add timeout/retry handling for fetch cache (#66652) 2024-06-10 11:34:36 -07:00
readme.md
related-tests-manifest.json Reapply "chore(test): run related E2E deploy tests on PRs" (#64682) (#64712) 2024-04-19 11:02:43 +02:00
test-file.txt
turbopack-build-tests-manifest.json Use addDependency to track metadata route file changes (#66714) 2024-06-11 17:19:23 +02:00
turbopack-dev-examples-manifest.json Fix last examples for Turbopack (#64020) 2024-04-03 16:02:52 +02:00
turbopack-dev-tests-manifest.json feat(turbopack-ecmascript): cache external modules with wrapper (#63337) 2024-06-10 15:39:40 +00:00

See Testing for more information on how you can run/write/debug tests for Next.js.