Commit graph

181 commits

Author SHA1 Message Date
Wyatt Johnson
c6ef857d57
Subresource Integrity for App Directory (#39729)
<!--
Thanks for opening a PR! Your contribution is much appreciated.
In order to make sure your PR is handled as smoothly as possible we
request that you follow the checklist sections below.
Choose the right checklist for the change that you're making:
-->

This serves to add support for [Subresource
Integrity](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity)
hashes for scripts added from the new app directory. This also has
support for utilizing nonce values passed from request headers (expected
to be generated per request in middleware) in the bootstrapping scripts
via the `Content-Security-Policy` header as such:

```
Content-Security-Policy: script-src 'nonce-2726c7f26c'
```

Which results in the inline scripts having a new `nonce` attribute hash
added. These features combined support for setting an aggressive Content
Security Policy on scripts loaded.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the
feature request has been accepted for implementation before opening a
PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [x] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [x] Make sure the linting passes by running `pnpm lint`
- [x] The examples guidelines are followed from [our contributing
doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)

Co-authored-by: Steven <steven@ceriously.com>
2022-09-08 15:17:15 -07:00
JJ Kasper
e8ff2738b3
Fix test hydration check in Safari 10.1 (#40285)
This removes the optional chaining inside of the `executeAsync` as that
is treated literally when passed to the browser and Safari 10.1 doesn't
support optional chaining.

fixes:
https://github.com/vercel/next.js/runs/8213273664?check_suite_focus=true
fixes:
https://github.com/vercel/next.js/runs/8213237056?check_suite_focus=true
2022-09-06 12:17:54 -07:00
Tim Neutkens
71ad0dd0b0
Add prefetch to new router (#39866)
Follow-up to #37551
Implements prefetching for the new router.

There are multiple behaviors related to prefetching so I've split them out for each case. The list below each case is what's prefetched:

Reference:
- Checkmark checked → it's implemented.
- RSC Payload → Rendered server components.
- Router state → Patch for the router history state.
- Preloads for client component entry → This will be handled in a follow-up PR.
- No `loading.js` static case → Will be handled in a follow-up PR.

---

- `prefetch={true}` (default, same as current router, links in viewport are prefetched)
    - [x]  Static all the way down the component tree
        - [x] RSC payload
        - [x] Router state
        - [ ] preloads for the client component entry
    - [x]  Not static all the way down the component tree
        - [x]  With `loading.js`
            - [x] RSC payload up until the loading below the common layout
            - [x] router state
            - [ ] preloads for the client component entry
        - [x]  No `loading.js` (This case can be static files to make sure it’s fast)
            - [x] router state
            - [ ] preloads for the client component entry
- `prefetch={false}`
    - [x]  always do an optimistic navigation. We already have this implemented where it tries to figure out the router state based on the provided url. That result might be wrong but the router will automatically figure out that

---

In the first implementation there is a distinction between `hard` and `soft` navigation. With the addition of prefetching you no longer have to add a `soft` prop to `next/link` in order to leverage the `soft` case. 

A heuristic has been added that automatically prefers `soft` navigation except when navigating between mismatching dynamic parameters.

An example:
- `app/[userOrTeam]/dashboard/page.js` and `app/[userOrTeam]/dashboard/settings/page.js`
  - `/tim/dashboard` → `/tim/dashboard/settings` = Soft navigation 
  - `/tim/dashboard` → `/vercel/dashboard` = Hard navigation
  - `/vercel/dashboard` → `/vercel/dashboard/settings` = Soft navigation
  - `/vercel/dashboard/settings` -> `/tim/dashboard` = Hard navigation

---

While adding these new heuristics some of the tests started failing and I found some state bugs in `router.reload()` which have been fixed. An example being when you push to `/dashboard` while on `/` in the same transition it would navigate to `/`, it also wouldn't push a new history entry. Both of these cases are now fixed:

```
React.startTransition(() => {
  router.push('/dashboard')
  router.reload()
})
```

---

While debugging the various changes I ended up debugging and manually diffing the cache and router state quite often and was looking at a way to automate this. `useReducer` is quite similar to Redux so I was wondering if Redux Devtools could be used in order to debug the various actions as it has diffing built-in. It took a bit of time to figure out the connection mechanism but in the end I figured out how to connect `useReducer`, a new hook `useReducerWithReduxDevtools` has been added, we'll probably want to put this behind a compile-time flag when the new router is marked stable but until then it's useful to have it enabled by default (only when you have Redux Devtools installed ofcourse).

> ⚠️ Redux Devtools is only connected to take incoming actions / state. Time travel and other features are not supported because the state sent to the devtools is normalized to allow diffing the maps, you can't move backward based on that state so applying the state is not connected.

Example of the integration:

<img width="1912" alt="Screen Shot 2022-09-02 at 10 00 40" src="https://user-images.githubusercontent.com/6324199/188637303-ad8d6a81-15e5-4b65-875b-1c4f93df4e44.png">
2022-09-06 17:29:09 +00:00
Will Binns-Smith
643447ed03
Allow port 0 in next dev and next start (#40118)
This addresses a bug where invoking `next dev` or `next start` with `--port 0` would fall back to the default port of 3000 instead of binding to port 0 (which typically results in the operating system assigning a free port).

I couldn't find a straightforward way of adding a test for next-start. It looks like we could add a similar test as for dev, but would need to generate a built project to serve. 

Manual test plan for `next start`:
```
$ ./packages/next/dist/bin/next start --port 0
ready - started server on 0.0.0.0:53508, url: http://localhost:53508
```

## Bug

- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [x] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)

Co-authored-by: Steven <steven@ceriously.com>
Co-authored-by: JJ Kasper <jj@jjsweb.site>
Co-authored-by: Wyatt Johnson <accounts+github@wyattjoh.ca>
2022-08-31 17:13:39 -05:00
JJ Kasper
5e5d56c1f7
Fix passing VERCEL_CLI_VERSION env for deploy tests (#39946)
The quotes around the env were being passed literally breaking usage of the env variable so this removes them. 

x-ref: [slack thread](https://vercel.slack.com/archives/C02K2HCH5V4/p1661417510950809?thread_ts=1659529028.137779&cid=C02K2HCH5V4)
2022-08-25 14:03:00 -05:00
JJ Kasper
b431bd4ba0
Leverage VERCEL_CLI_VERSION env for deploy tests (#39823)
This updates our next-e2e test deploy mode to auto pass along the VERCEL_CLI_VERSION env variable to allow testing builder changes easier. cc @nkzawa who encountered this.
2022-08-22 09:54:25 -05:00
Steven
53f0e2b31c
Update image tests files from *.js to *.ts (#39663)
Let's utilize typescript for our tests
2022-08-16 23:29:55 +00:00
Balázs Orbán
7de3cf5f89
fix(next-server): Fix priority for edge routes (#39462)
Fixes #39411
Bug

 Related issues linked using fixes #number
 Integration tests added
 Errors have helpful link attached, see contributing.md

Feature

 Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
 Related issues linked using fixes #number
 Integration tests added
 Documentation added
 Telemetry added. In case of a feature if it's used or not.
 Errors have helpful link attached, see contributing.md

Documentation / Examples

 Make sure the linting passes by running pnpm lint
 The examples guidelines are followed from our contributing doc

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-08-16 19:05:03 +01:00
JJ Kasper
1669c60684
Fix next.config.js overwriting on deploy e2e test (#39476) 2022-08-10 16:44:21 -05:00
Steven
d56aadae5b
Update tests to use random directory (#39230)
This PR fixes an issue where tests fail because the generated tmp directory already exists. This is likely caused from two tmp dirs being generated in the same millisecond.

```
Failed to create next instance [Error: EEXIST: file already exists, mkdir '/tmp/next-repo-1659368089063/packages'] {
  errno: -17,
  code: 'EEXIST',
  syscall: 'mkdir',
  path: '/tmp/next-repo-1659368089063/packages'
}
```

https://github.com/vercel/next.js/runs/7615808051?check_suite_focus=true
2022-08-01 19:05:48 +00:00
JJ Kasper
135a4cfc66
Add handling for prefetching onTouchStart and initial mobile testing (#38805)
This adds handling for prefetching `onTouchStart` as this gives a little more time to start parsing required scripts for a page transition if not already done that can help make the transition faster. This is based on research showing the touch start event firing on average `90ms` before click (x-ref: [source](https://instant.page/#:~:text=in%20the%20world.-,On%20mobile,-A%20user%20starts))

This also adds testing safari with playwright so we can run these in PRs instead of only after merge and adds initial mobile testing as well. 

x-ref: [slack thread](https://vercel.slack.com/archives/C7PDM7X2M/p1658250170774989?thread_ts=1658249275.178349&cid=C7PDM7X2M)

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-07-25 19:04:03 +00:00
JJ Kasper
366a04b7ac
Ensure mixed query/hash values are handled correctly (#38852)
This ensures we correctly detect query and hash values when there are `?` characters in the hash. A regression test to ensure this working properly has been added. 

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

Fixes: https://github.com/vercel/next.js/issues/38783
2022-07-21 19:16:38 +00:00
Jiachi Liu
a16d8dd4cd
Filter proper chunks from chunk group for client components (#38379)
Client components might result in a page chunk or a standalone splitted chunk marked in flight manifest, this PR filters out the page chunk for standalone chunk so that while loading a client chunk (like for `next/link`) it won't load the page chunk to break the hydration. `chunk.ids` is not enough for getting required chunks, so we get the chunks from chunk group then filter the required ones.

tests: Re-enable few previous rsc tests
chore: refactor few webpack api usage

## Bug

- [ ] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2022-07-06 17:35:20 +00:00
Jiachi Liu
bfaffbdd3f
Alias react and react-dom by default (#38245)
Previously we use custom webpack alias for specific react versions for non server side node runtime aliases. This PR alias the entire folders of `react/` and `react-dom/` so that no more alias in next.config is required but only the nodejs require hook.

* Alias `react` and `react-dom` by default
* Use `react@experimental` to run server components integration test
* Drop with-react-17 test util, add `__NEXT_REACT_CHANNEL` as an env var for testing and development to specify the react channel is 17 or new experimental version
2022-07-01 23:57:45 +00:00
JJ Kasper
8a5c59b7f1
Ensure @swc/helpers do not rely on hoisting (#38174)
This ensures we properly alias and internalize `@swc/helpers` so that we don't rely on package managers hoisting this dependency for the build to work properly. This also disables the external helpers with `jest` as this can also require hoisting to work and doesn't provide as much of an optimization. 

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

Fixes: [slack thread](https://vercel.slack.com/archives/C0289CGVAR2/p1656437059151439)
2022-06-29 22:47:44 +00:00
JJ Kasper
edd798e526
Fix hard navigation guard on popstate and handle fetching fresh data (#37970)
* Fix hard navigation guard on popstate and handle fetching fresh data

* undo link changes and handle middleware cases

* update tests
2022-06-24 10:50:41 -05:00
Hannes Bornö
2ff660c25a
Remove full reload overlay and warn in CLI instead (#37874)
- Always perform a full reload when needed without blocking with the overlay.
- Old client warnings re-added.
- Post client warning to dev server and print it in the CLI. 


## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)
2022-06-22 15:41:23 +00:00
Hannes Bornö
2313ee093a
Display full refresh warning even when error has occurred (#37425)
If you end up in a state where an error happened and you also should be warned about a full refresh  - you get stuck. The full refresh is blocked by the warning but the error is shown instead.

Tests didn't catch this because the refresh warning never showed in `__NEXT_TEST_MODE`.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2022-06-19 00:00:14 +00:00
Balázs Orbán
b8e533b589
chore: use pnpm install in tests (#37712)
## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `pnpm lint`
- [ ] The examples guidelines are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing.md#adding-examples)


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-06-16 18:08:07 +00:00
JJ Kasper
3b9f180d25
Allow passing FileRef directly to createNext (#37664)
* Allow passing FileRef directly to createNext

* update type
2022-06-13 15:28:34 -05:00
JJ Kasper
607ff2b322
Update to process redirects/rewrites for _next/data with middleware (#37574)
* Update to process redirects/rewrites for _next/data

* correct matched-path resolving with middleware

* Add next-data header

* migrate middleware tests

* lint-fix

* update error case

* update test case

* Handle additional resolving cases and add more tests

* update test from merge

* fix test

* rm .only

* apply changes from review

* ensure _next/data resolving does not apply without middleware
2022-06-10 12:35:12 -05:00
JJ Kasper
f7b81316ae
Update to leverage pnpm for monorepo (#37259)
* Update to leverage pnpm for monorepo

* update compiled

* update stats action

* update ci install step

* update ci

* add test dep

* update invoking scripts

* update caching

* skip cache for now

* update dep

* update packages and fix babel

* update compiled

* update lint

* update test

* update ci

* update pnpm store caching

* update path for windows

* update restore-key config

* update caching

* remove extra build azure stage

* re-add checkout

* update setting pnpm store

* bump

* remove azure caching as pnpm is faster to download

* update contributing

* apply suggestions

* remove install-peers

* prepublish -> prepublishOnly

* prepublish -> prepublishOnly more

* more yarn -> pnpm references

* more yarn -> pnpm references take 2

* use workspace protocol for root package.json

Co-authored-by: Steven <steven@ceriously.com>
2022-05-28 23:35:16 -05:00
JJ Kasper
81850eb295
Update deploy E2E test setup (#37126)
* Update deploy E2E test setup
2022-05-23 17:37:21 -05:00
await-ovo
ff37cc9e13
fix: should listen for config file changes when specifying the app directory (#36570)
Fixes: #36569 



## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [x] Make sure the linting passes by running `yarn lint`


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-05-22 19:42:53 +00:00
Гончаров
e2e7f04c98
Fixed anotation param name (#37075)
## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
2022-05-20 19:41:11 +00:00
Damien Simonin Feugas
4a86a8ffb1
fix(middleware): false positive dynamic code detection at build time (#36955)
## What's in there?

Partially fixes https://github.com/vercel/edge-functions/issues/82
Relates to #36715 

Our webpack plugin for middleware leverages static analysis to detect Dyanamic code evaluation in user `_middleware.js` file (and depedencies). Since edge function runtime do not allow them, the build is aborted.

The use of `Function.bind` is considered invalid, while it is legit. A customer using `@aws-sdk/client-s3` reported it.
This PR fixes it.

Please note that this check is too strict: some dynamic code may be in the bundle (despite treeshaking), but may never be used (because of code branches). Since this point is under discussion, this PR adds tests covering some false positives (`@apollo/react-hook`, `qs` and `has`), but does not change the behavior (consider them as errors).

## Notes to reviewer

I looked for test facilities allowing to download the required 3rd party modules. `createNext()` in production context made my day, but showed two issues:
- `cliOutput` is not cleaned in between tests. While clearance during `stop()` would be annoying, I hope that clearance during `start()` is better.
- if `start()` fails while building, the created instance can never be stopped. This is because we don't clear `childProcess` after `build`. 

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [x] Make sure the linting passes by running `yarn lint`
2022-05-17 19:35:48 +00:00
JJ Kasper
3692a5ecdb
Add falling back to wasm swc build on native load failure (#36612)
Follow-up to https://github.com/vercel/next.js/pull/36527 this adds falling back to the wasm swc build when loading the native bindings fails so that we don't block the build on the native dependency being available.  

This continues off of https://github.com/vercel/next.js/pull/33496 but does not add a postinstall script yet and only downloads the fallback when the native dependency fails to load.
2022-05-02 21:11:45 +00:00
Tim Neutkens
5aa54b3385
Add pagesDir to Jest transformer (#36599)
Fixes #35469

Adds `pagesDir` which is required for the Relay transform.

Added a test case based on https://github.com/hanford/relay-swc-jest.



## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`


Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-05-01 16:39:30 +00:00
JJ Kasper
917a736a55
Add event for swc load failure and attempt patching lockfile (#36527) 2022-04-28 11:31:15 +02:00
Shu Ding
be9491e243
Ensure there is only 1 render pass in concurrent rendering with getInitialProps in _document (#36352)
This PR makes sure `renderPage` calls `renderShell` in concurrent features, and `renderToString` if not.

Closes #36268, #36229.

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
2022-04-21 16:01:47 +00:00
await-ovo
864d401ee1
fix(next): use moduleGraph.getIssuer to avoid deprecation warning (#36329) (#36330)
fix: #36329 



## Bug

- [x] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
2022-04-21 14:14:03 +00:00
JJ Kasper
073a05a1be
Add handling for testing against deployments (#36285)
This adds a new test mode `next-deploy` which allows testing against deployments using the Vercel CLI. After running these tests they uncovered some bugs we need to correct before fully enabling. Patching the uncovered issues will be done in follow-up PRs and then after resolved this will be enabled to run after new publishes. 

Tests that uncovered bugs to patch in follow-ups:

- [ ] test/e2e/getserversideprops/test/index.test.ts (req.url normalizing)
- [ ] test/e2e/i18n-api-support/index.test.ts (locale prefixed API routes matching)
- [ ] test/e2e/prerender.test.ts (/_next/data/build-id/ does not 404)
2022-04-20 12:23:09 +00:00
Jiachi Liu
2e00eb6746
Validate streaming writer chunk type in testing (#36200)
* Validate streaming writer chunk type in testing

* call

* update text
2022-04-18 16:24:06 +02:00
Naoyuki Kanezawa
93678b569b
Do not add locale to link for api route and middleware preflight (#35994)
Fixes https://github.com/vercel/next.js/issues/33578

This PR fixes `Link` component as well to not add locale for api routes since both preflight redirect and link should work the same.

Additionally, it fixes the webdriver method `browser.waitForCondition()` for playwright to not wrap with function string.

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`
2022-04-11 15:59:07 +00:00
Jiachi Liu
de0bc57b6e
test: organize react 18 tests (#36003)
* Organize react 18 test cases, group invalid cases to speed up the regular test cases
* Add `runDevSuite` and `runProdSuite` for group next dev/prod test cases

```js
runDevSuite(name, appDir, {
  runTests: (context, env) => { ... },
  beforeAll,
  afterAll,
})

runProdvSuite(name, appDir, {
  runTests: (context, env) => { ... },
  beforeAll,
  afterAll,
})
```
2022-04-08 15:29:35 +00:00
Naoyuki Kanezawa
633050402f
fix: add locale prefix to middleware preflight url (#35911)
Fixes part of https://github.com/vercel/next.js/issues/34274

Navigating to `/` causes to redirect preflight request to a url of browser language like `/en`. 
This PR fixes to add the locale prefix always so that the redirect does not happen anymore and middleware can get a correct locale.

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
2022-04-07 11:39:49 +00:00
JJ Kasper
4a7ab34baf
Update repo to use react 18 by default (#35888)
This updates our `yarn next` command to leverage react v18 by default and removes the need for the test require hook/config modifying when testing react 18. There are some fixtures we need to investigate react 18 support in follow-ups:

- `test/integration/client-navigation-a11y`
- `test/integration/critical-css`
- `test/integration/custom-error-page-exception`
- `test/integration/font-optimization`
- AMP specific tests
2022-04-05 21:51:47 +00:00
JJ Kasper
e148d2bdbd
Continue testing react v17 with e2e tests (#35787)
* Continue testing react v17 with e2e tests

* update react 17 expected error

* Update env variable name and add log

* fix starter cache version

* remove extra setup condition

* Revert "remove extra setup condition"

This reverts commit 5760a9f8867213f95a9fac073fe27a9ec01b780f.

* update basepath test

* remove log

* stabilize test
2022-03-31 17:35:00 -05:00
Tim Neutkens
446432719f
Run e2e suite against React 18 (#35774)
* Run e2e suite against React 18

* update test

Co-authored-by: JJ Kasper <jj@jjsweb.site>
2022-03-31 10:57:21 -05:00
Tim Neutkens
62bb3482fe
Fix Fast Refresh for React 18 (#35718)
- Updates the React 18 test suite to the latest React version.
- Upgrade `react-refresh` module

Fixes #35518
Fixes #35703

## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`


Co-authored-by: Jiachi Liu <4800338+huozhi@users.noreply.github.com>
2022-03-30 12:16:17 +00:00
JJ Kasper
6a4c70e051
Update default test timeouts for yarn install times (#35669)
This updates our default test times as discussed to account for longer `yarn install` times for the isolated tests as GitHub actions network can be slow. 

x-ref: https://github.com/vercel/next.js/pull/35507#issuecomment-1074606737
x-ref: [slack thread](https://vercel.slack.com/archives/CGU8HUTUH/p1647919982840099)
2022-03-28 20:46:01 +00:00
JJ Kasper
12e1bb7d32
Ensure eslint plugins dont conflict (#35667) 2022-03-28 12:31:30 -05:00
CommanderRoot
db2567b01b
chore: replace deprecated String.prototype.substr() (#35421)
.substr() is deprecated so we replace it with .slice() which works similarily but isn't deprecated
Signed-off-by: Tobias Speicher <rootcommander@gmail.com>

Co-authored-by: Steven <steven@ceriously.com>
2022-03-24 17:49:38 -04:00
Jiachi Liu
00ca8df26c
test: add inline flight response reuse test (#34364)
To collect the requests starting from page load, we need to register event listeners before page loading (`page.goto` API invocation). By default webdriver will wait for hydration, so we need to register events inside `browser.loadPage` to ensure we can collect the requests before hydration is done.

### Changes
* Add `beforePageLoad` for next webdriver
* registry page `'request'` event before loading page
* update related tests for agruments change

### Usage

```js
browser = await webdriver(appPort, '/path', {
   waitHydration, // default true
   retryWaitHydration, // default false
   disableCache, // default false
   beforePageLoad, // default undefined
})

```
2022-02-15 18:53:45 +00:00
JJ Kasper
abf781f637
Allow listening for page requests in tests (#34204) 2022-02-10 18:02:38 -06:00
Klaas Landsman
b39e49eca9
Fix detection of anchor click events inside svg (#23272)
## Bug

The `nodeName` of an anchor inside an SVG equals the lowercase `a` instead of the html anchor's uppercase `A`.
This behavior can be seen in this plain js demo: https://jsfiddle.net/L2p8f4ve/28/

fixes #23252




## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.

## Documentation / Examples

- [ ] Make sure the linting passes

Co-authored-by: JJ Kasper <22380829+ijjk@users.noreply.github.com>
2022-02-06 20:53:03 +00:00
Tim Neutkens
3bac02e032
Enable jest hoist transform when using next/jest (#33731)
Fixes #32539

Implements what was shared at https://github.com/vercel/next.js/issues/32539#issuecomment-1023139083.



## Bug

- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Errors have helpful link attached, see `contributing.md`

## Feature

- [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [ ] Related issues linked using `fixes #number`
- [ ] Integration tests added
- [ ] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [ ] Errors have helpful link attached, see `contributing.md`

## Documentation / Examples

- [ ] Make sure the linting passes by running `yarn lint`
2022-01-31 16:15:15 +00:00
Steven
b9c012f49d
Fix duplicate image src causing canceled request (#33776)
In PR #26968, we added Set of loaded images that was removed in #33474 erroneously.

We still need to track loaded images since we can't rely on `img.complete`, especially if the parent uses `react-virtualized`.

Tested on https://nextjs.org/showcase
2022-01-28 23:50:36 +00:00
JJ Kasper
389432048c
Update check for fallback pages during export (#33323)
This fixes our check for fallback pages during `next export` as we are currently erroring even when the erroneous pages are not included in the `exportPathMap`. This also adds additional tests to certify the expected behavior for the error. 

## Bug

- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] Errors have helpful link attached, see `contributing.md`

Fixes: https://github.com/vercel/next.js/issues/29135
2022-01-17 14:44:45 +00:00
JJ Kasper
613e4c91e3
Update yarn PnP tests and disable swc file reading for PnP (#33236)
* Update yarn PnP tests and disable swc file reading for PnP

* update job

* Update test

* add env variable

* update destory

* test one

* bump timeout

* update pnp install command

* only run pnp test

* add more logs

* handle exit signal

* dont inherit stdio for install

* update server start

* re-add test type

* add build log

* additional logging

* update build command

* remove separate timeout

* update install command

* install separate for better time info

* add cache pre-warming

* update yarn config

* enable other pnp tests

* Separate out tests

* fix-lint

* update path

* update test concurrency for isolated tests

* update retries

* Revert "update test concurrency for isolated tests"

This reverts commit 3a6e924df8ec61d55d3ee8a58d24cd50f0141195.

* re-enable production tests

* apply suggestions
2022-01-14 09:43:30 -06:00