| |
| |
| |
| |
| @@ -108,15 +108,11 @@ describe('use-cache-dev', () => { |
| ) |
| }) |
| |
| - // These two currently fail in both Turbopack and Webpack. Dev "use cache" |
| - // invalidation relies on the __next_hmr_refresh_hash__ cookie that the |
| - // browser HMR client sets after an edit; a client that fetches directly |
| - // (curl, a plain fetch, a second device) never sends that cookie, so the |
| - // "use cache" key does not change across the edit and the stale entry is |
| - // reused. Change these to `it` once editing a file invalidates cached data |
| - // for requests that do not carry the cookie, covering both route handlers |
| - // and pages. |
| - it.failing( |
| + // Regression coverage for requesters that don't run the browser HMR client. |
| + // A direct requester never receives browser-authored refresh state, but it |
| + // must still observe a new cache generation after the server recompiles an |
| + // edited page or route handler. |
| + it( |
| 'should update cached data used by a route handler after editing a file', |
| async () => { |
| const initialData = await next |
| @@ -160,10 +156,20 @@ describe('use-cache-dev', () => { |
| // random value due to a cache miss. |
| expect(newData.text).toBe('bar') |
| expect(newData.mathRandom).not.toBe(initialData.mathRandom) |
| + |
| + // Once the edited module has compiled, ordinary warm requests should |
| + // keep reusing its new cache entry rather than advancing the cache key |
| + // for development bookkeeping. |
| + const warmData = await next |
| + .fetch('/api/cached') |
| + .then((res) => res.json()) |
| + |
| + expect(warmData.text).toBe('bar') |
| + expect(warmData.mathRandom).toBe(newData.mathRandom) |
| } |
| ) |
| |
| - it.failing( |
| + it( |
| 'should update cached data used by a page fetched without a cookie after editing a file', |
| async () => { |
| // `next.render$` fetches directly, without the browser HMR client, so |
| @@ -202,6 +208,13 @@ describe('use-cache-dev', () => { |
| // random value due to a cache miss. |
| expect($('#text').text()).toBe('bar') |
| expect($('#mathRandom').text()).not.toBe(initialMathRandom) |
| + |
| + // The post-edit value should remain cached on another direct request. |
| + const editedMathRandom = $('#mathRandom').text() |
| + $ = await next.render$('/cached-page') |
| + |
| + expect($('#text').text()).toBe('bar') |
| + expect($('#mathRandom').text()).toBe(editedMathRandom) |
| } |
| ) |
| |
|
|