test: add PPF coverage to use-cache and RDC tests (#99417)
We weren't running the use-cache/resume-data-cache test suites in PPF.
some of the tests fail due to the bug that is fixed in #98005 (although
interestingly the fetch-cache tests only fail in deploy mode, because in
`next start` we heal a bad RDC using outputs from
`.next/cache/fetch-cache`). a bunch of refactoring was needed (some
tests were producing false negatives, flakily), so i split this into a
separate PR to confirm behavior before/after the fix.
### `use-cache.test.ts`
- I've refactored the tests to use timestamps and be a bit more
debuggable. previously, they'd fail with a hydration error, and it was
hard to pinpoint the cause. including a name lets us know which cache
was mismatched, and assert that the values of the cache are consistent
across the HTML shell / resume.
- the tests for exluded caches now include more complete assertions on
what content is and isn't included in the HTML shell
### `resume-data-cache.test.ts`
This one needed quite a bit of work:
- The `use cache` and `fetch cache` tests were not independent. they
both used the same page and revalidated the same tag, which means that a
revalidation from the first test affected the outcome of the second
test. i've split them into two separate pages with two separate tags to
make the behavior consistent.
- Multiple tests fetched the same URL (with `fetch(..., { cache:
'force-cache' }`), which made them interfere with each other's fetch
caches. the URLs are now different so the tests are actually independent
- Some cache values are now tagged with a name and timestamp. The name
is used for asserting consistency, the timestamp is for improved
debuggability (provides ordering)
- The action revalidation tests weren't checking what the value from the
build-time prerender was actually supposed to be, so they were passing
even if the build-time RDC was not used at all
- The tests that use `browser()` now assert that there should be no
hydration warning, which can happen due to the PPF bug (due to
inconsistent cache values across HTML shell/resume)
- **the revalidation assertions are very flaky in deploy**, and i've had
to disable them to avoid introducing a test that fails often. i'm not
sure how they were passing before.
Showing
This diff is collapsed.
This diff is collapsed.
Please
register
or
sign in
to comment