fix client-cache deploy tests (#66770)
- Telemetry debugging isn't available when deployed - The loading test had a race bug Verified all of these passed when deployed locally. <!-- Thanks for opening a PR! Your contribution is much appreciated. 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(s) that you're making: ## For Contributors ### Improving Documentation - Run `pnpm prettier-fix` to fix formatting issues before opening the PR. - Read the Docs Contribution Guide to ensure your contribution follows the docs guidelines: https://nextjs.org/docs/community/contribution-guide ### Adding or Updating Examples - The "examples guidelines" are followed from our contributing doc https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md - Make sure the linting passes by running `pnpm build && pnpm lint`. See https://github.com/vercel/next.js/blob/canary/contributing/repository/linting.md ### Fixing a bug - Related issues linked using `fixes #number` - Tests added. See: https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ### Adding a feature - Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. (A discussion must be opened, see https://github.com/vercel/next.js/discussions/new?category=ideas) - Related issues/discussions are linked using `fixes #number` - e2e tests added (https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) - Documentation added - Telemetry added. In case of a feature if it's used or not. - Errors have a helpful link attached, see https://github.com/vercel/next.js/blob/canary/contributing.md ## For Maintainers - Minimal description (aim for explaining to someone not on the team to understand the PR) - When linking to a Slack thread, you might want to share details of the conclusion - Link both the Linear (Fixes NEXT-xxx) and the GitHub issues - Add review comments if necessary to explain to the reviewer the logic behind a change ### What? ### Why? ### How? Closes NEXT- Fixes # -->
This commit is contained in:
parent
a00555ae3a
commit
0c49daad3c
4 changed files with 56 additions and 50 deletions
|
@ -7,7 +7,6 @@
|
|||
"test/production/**/*.test.{t,j}s{,x}"
|
||||
],
|
||||
"exclude": [
|
||||
"test/e2e/app-dir/app-client-cache/client-cache.original.test.ts",
|
||||
"test/e2e/app-dir/app-routes/app-custom-routes.test.ts",
|
||||
"test/e2e/app-dir/next-after-app/index.test.ts",
|
||||
"test/e2e/app-dir/scss/nm-module-nested/nm-module-nested.test.ts",
|
||||
|
@ -32,7 +31,6 @@
|
|||
"test/e2e/third-parties/index.test.ts",
|
||||
"test/e2e/useselectedlayoutsegment-s-in-pages-router/useselectedlayoutsegment-s-in-pages-router.test.ts",
|
||||
"test/e2e/app-dir/app-prefetch-false-loading/app-prefetch-false-loading.test.ts",
|
||||
"test/e2e/app-dir/app-client-cache/client-cache.experimental.test.ts",
|
||||
"test/e2e/app-dir/app-routes-client-component/app-routes-client-component.test.ts",
|
||||
"test/e2e/app-dir/app-routes/app-custom-route-base-path.test.ts",
|
||||
"test/e2e/app-dir/mdx/mdx.test.ts",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { nextTestSetup } from 'e2e-utils'
|
||||
import { check } from 'next-test-utils'
|
||||
import { check, retry } from 'next-test-utils'
|
||||
import { BrowserInterface } from 'next-webdriver'
|
||||
import {
|
||||
browserConfigWithFixedTime,
|
||||
|
@ -316,18 +316,20 @@ describe('app dir client cache semantics (default semantics)', () => {
|
|||
await browser.elementByCss('[href="/null-loading"]').click()
|
||||
|
||||
// the page content should disappear immediately
|
||||
expect(
|
||||
await browser.hasElementByCssSelector('[href="/null-loading"]')
|
||||
).toBeFalse()
|
||||
await retry(async () => {
|
||||
expect(
|
||||
await browser.hasElementByCssSelector('[href="/null-loading"]')
|
||||
).toBe(false)
|
||||
})
|
||||
|
||||
// the root layout should still be visible
|
||||
expect(await browser.hasElementByCssSelector('#root-layout')).toBeTrue()
|
||||
expect(await browser.hasElementByCssSelector('#root-layout')).toBe(true)
|
||||
|
||||
// the dynamic content should eventually appear
|
||||
await browser.waitForElementByCss('#random-number')
|
||||
expect(
|
||||
await browser.hasElementByCssSelector('#random-number')
|
||||
).toBeTrue()
|
||||
expect(await browser.hasElementByCssSelector('#random-number')).toBe(
|
||||
true
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import path from 'path'
|
|||
|
||||
describe('app dir client cache semantics (experimental staleTimes)', () => {
|
||||
describe('dynamic: 0', () => {
|
||||
const { next, isNextDev } = nextTestSetup({
|
||||
const { next, isNextDev, isNextDeploy } = nextTestSetup({
|
||||
files: path.join(__dirname, 'fixtures', 'regular'),
|
||||
nextConfig: {
|
||||
experimental: { staleTimes: { dynamic: 0 } },
|
||||
|
@ -222,27 +222,29 @@ describe('app dir client cache semantics (experimental staleTimes)', () => {
|
|||
})
|
||||
})
|
||||
|
||||
describe('telemetry', () => {
|
||||
it('should send staleTimes feature usage event', async () => {
|
||||
const events = findAllTelemetryEvents(
|
||||
next.cliOutput,
|
||||
'NEXT_CLI_SESSION_STARTED'
|
||||
)
|
||||
if (!isNextDeploy) {
|
||||
describe('telemetry', () => {
|
||||
it('should send staleTimes feature usage event', async () => {
|
||||
const events = findAllTelemetryEvents(
|
||||
next.cliOutput,
|
||||
'NEXT_CLI_SESSION_STARTED'
|
||||
)
|
||||
|
||||
expect(events).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
staticStaleTime: null,
|
||||
dynamicStaleTime: 0,
|
||||
}),
|
||||
])
|
||||
)
|
||||
expect(events).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
staticStaleTime: null,
|
||||
dynamicStaleTime: 0,
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
describe('static: 180', () => {
|
||||
const { next, isNextDev } = nextTestSetup({
|
||||
const { next, isNextDev, isNextDeploy } = nextTestSetup({
|
||||
files: path.join(__dirname, 'fixtures', 'regular'),
|
||||
nextConfig: {
|
||||
experimental: { staleTimes: { static: 180 } },
|
||||
|
@ -341,22 +343,24 @@ describe('app dir client cache semantics (experimental staleTimes)', () => {
|
|||
})
|
||||
})
|
||||
|
||||
describe('telemetry', () => {
|
||||
it('should send staleTimes feature usage event', async () => {
|
||||
const events = findAllTelemetryEvents(
|
||||
next.cliOutput,
|
||||
'NEXT_CLI_SESSION_STARTED'
|
||||
)
|
||||
expect(events).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
staticStaleTime: 180,
|
||||
dynamicStaleTime: null,
|
||||
}),
|
||||
])
|
||||
)
|
||||
if (!isNextDeploy) {
|
||||
describe('telemetry', () => {
|
||||
it('should send staleTimes feature usage event', async () => {
|
||||
const events = findAllTelemetryEvents(
|
||||
next.cliOutput,
|
||||
'NEXT_CLI_SESSION_STARTED'
|
||||
)
|
||||
expect(events).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
staticStaleTime: 180,
|
||||
dynamicStaleTime: null,
|
||||
}),
|
||||
])
|
||||
)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
describe('dynamic: 0, static: 0', () => {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { nextTestSetup } from 'e2e-utils'
|
||||
import { check } from 'next-test-utils'
|
||||
import { check, retry } from 'next-test-utils'
|
||||
import { BrowserInterface } from 'next-webdriver'
|
||||
import {
|
||||
browserConfigWithFixedTime,
|
||||
|
@ -421,18 +421,20 @@ describe('app dir client cache semantics (30s/5min)', () => {
|
|||
await browser.elementByCss('[href="/null-loading"]').click()
|
||||
|
||||
// the page content should disappear immediately
|
||||
expect(
|
||||
await browser.hasElementByCssSelector('[href="/null-loading"]')
|
||||
).toBeFalse()
|
||||
await retry(async () => {
|
||||
expect(
|
||||
await browser.hasElementByCssSelector('[href="/null-loading"]')
|
||||
).toBe(false)
|
||||
})
|
||||
|
||||
// the root layout should still be visible
|
||||
expect(await browser.hasElementByCssSelector('#root-layout')).toBeTrue()
|
||||
expect(await browser.hasElementByCssSelector('#root-layout')).toBe(true)
|
||||
|
||||
// the dynamic content should eventually appear
|
||||
await browser.waitForElementByCss('#random-number')
|
||||
expect(
|
||||
await browser.hasElementByCssSelector('#random-number')
|
||||
).toBeTrue()
|
||||
expect(await browser.hasElementByCssSelector('#random-number')).toBe(
|
||||
true
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in a new issue