Commit 0f34ffb
authored
test(e2e): Add Next.js cache component nesting scenarios (#24704)
Add tests for 4 different nested cache component scenarios. Currently
all in a "failed" state as this is not yet implemented.
```
Legend
T1, T2, T3 traces, one per request, in order
ck:X cache.key digest of entry X
o--> put span link (sentry.link.type: 'cache_origin'), target = the cache.put span
```
## 1. Cached layout in the middle
```
app/(cached-nesting)/cached-mid-layout/
[id]/layout.tsx 'use cache' (hours), key <- awaited [id]
[id]/page.tsx dynamic (awaits headers)
Request 1 (fill) Request 2 (hit)
T1: GET /cached-mid-layout/[id] T2: GET /cached-mid-layout/[id]
|- cache.get hit=false ck:layout |- cache.get hit=true ck:layout
|- cache.put ck:layout <-----------------o cache_origin
|- dynamic page render |- dynamic page render (no cache spans)
```
## 2. Dynamic Layouts, Cached Leaf
```
app/(cached-nesting)/dynamic-layouts/
[id]/layout.tsx dynamic (awaits headers)
[id]/layout-cached-leaf/page.tsx page renders CachedLeaf ('use cache', hours)
Request 1 (fill) Request 2 (hit)
T1: GET /dynamic-layouts/[id]/... T2: GET /dynamic-layouts/[id]/...
|- cache.put ck:leaf <-------------------o cache.get hit=true ck:leaf
```
## 3. Mixed lifetimes: two cache links, but pointing to a different
origin
```
app/(cached-nesting)/mixed-lifetimes/
[id]/layout.tsx 'use cache', expire: 2s <- short-lived
[id]/page.tsx dynamic + LongLivedComponent ('use cache', hours)
T1 (fill both) --sleep 3s--> T2 (layout expired) T3 (both hit)
|- put ck:layout |- get hit=false ck:layout |- get hit=true ck:layout
|- put ck:cmp |- put ck:layout <------------o cache_origin
^ |- get hit=true ck:cmp |- get hit=true ck:cmp
| |
+---------------------------------------------------------------o cache_origin
```
## 4. Shared layout across sibling routes: Origin trace is different
than serving (`/a` and `/b`)
```
app/(cached-nesting)/shared-layout/
[id]/layout.tsx 'use cache' (hours) — ONE entry shared by a and b
[id]/a/page.tsx dynamic
[id]/b/page.tsx dynamic
Request 1: /shared-layout/<id>/a Request 2: /shared-layout/<id>/b
T1: GET /shared-layout/[id]/a T2: GET /shared-layout/[id]/b
|- cache.put ck:layout <-----------------o cache.get hit=true ck:layout
```
Closes #247011 parent b7b7e04 commit 0f34ffb
23 files changed
Lines changed: 753 additions & 0 deletions
File tree
- dev-packages/e2e-tests/test-applications
- nextjs-16-cacheComponents
- app/(cached-nesting)
- cached-mid-layout/[id]
- dynamic-layouts/[id]
- layout-cached-leaf
- mixed-lifetimes/[id]
- tests
- nextjs-16-streaming-cacheComponents
- app/(cached-nesting)
- cached-mid-layout/[id]
- dynamic-layouts/[id]
- layout-cached-leaf
- mixed-lifetimes/[id]
- tests
Lines changed: 25 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
Lines changed: 17 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
Lines changed: 7 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
dev-packages/e2e-tests/test-applications/nextjs-16-cacheComponents/app/(cached-nesting)/layout.tsx
Lines changed: 11 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
Lines changed: 24 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
Lines changed: 19 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
Lines changed: 24 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
0 commit comments