File size: 2,778 Bytes
94786da | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | diff --git a/test/e2e/app-dir/use-cache-dev/use-cache-dev.test.ts b/test/e2e/app-dir/use-cache-dev/use-cache-dev.test.ts
index da4e0a22..ca835118 100644
--- a/test/e2e/app-dir/use-cache-dev/use-cache-dev.test.ts
+++ b/test/e2e/app-dir/use-cache-dev/use-cache-dev.test.ts
@@ -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)
}
)
|