diff --git a/test/production/app-dir/action-only-fallback-resume-data-cache/action-only-fallback-resume-data-cache.test.ts b/test/production/app-dir/action-only-fallback-resume-data-cache/action-only-fallback-resume-data-cache.test.ts index 68a7f8f2c6..9c333a663c 100644 --- a/test/production/app-dir/action-only-fallback-resume-data-cache/action-only-fallback-resume-data-cache.test.ts +++ b/test/production/app-dir/action-only-fallback-resume-data-cache/action-only-fallback-resume-data-cache.test.ts @@ -9,6 +9,7 @@ describe('action-only fallback resume data cache', () => { : { NEXT_PRIVATE_TEST_HEADERS: '1', NEXT_PRIVATE_MINIMAL_MODE: '1', + TEST_CACHE_HANDLER: '1', }, }) @@ -70,6 +71,8 @@ describe('action-only fallback resume data cache', () => { } it('handles postponed state on an action-only fallback request', async () => { + const outputIndex = next.cliOutput.length + const response = await invokeAction('readCachedValue') expect(response.status).toBe(200) @@ -77,15 +80,25 @@ describe('action-only fallback resume data cache', () => { const responseBody = await response.text() expect(responseBody).toContain('cached value') expect(responseBody).not.toContain('destination page rendered') + + const output = next.cliOutput.slice(outputIndex) + expect(output).toContain('ActionOnlyFallbackCacheHandler::updateTags') + expect(output).toContain('_N_T_/events/foo/group') }) - it('does not render the fallback route when the action calls notFound', async () => { + it('applies pending revalidations without rendering the fallback route when the action calls notFound', async () => { + const outputIndex = next.cliOutput.length + const response = await invokeAction('notFoundAfterRevalidation') expect(response.status).toBe(404) expect(response.headers.get('content-type')).toContain('text/x-component') const responseBody = await response.text() expect(responseBody).not.toContain('destination page rendered') + + const output = next.cliOutput.slice(outputIndex) + expect(output).toContain('ActionOnlyFallbackCacheHandler::updateTags') + expect(output).toContain('_N_T_/events/foo/group') }) } }) diff --git a/test/production/app-dir/action-only-fallback-resume-data-cache/cache-handler.js b/test/production/app-dir/action-only-fallback-resume-data-cache/cache-handler.js new file mode 100644 index 0000000000..84768037bb --- /dev/null +++ b/test/production/app-dir/action-only-fallback-resume-data-cache/cache-handler.js @@ -0,0 +1,23 @@ +// @ts-check + +const defaultCacheHandler = + require('next/dist/server/lib/cache-handlers/default.external').default + +/** + * @type {import('next/dist/server/lib/cache-handlers/types').CacheHandler} + */ +const cacheHandler = { + get: defaultCacheHandler.get.bind(defaultCacheHandler), + set: defaultCacheHandler.set.bind(defaultCacheHandler), + refreshTags: defaultCacheHandler.refreshTags.bind(defaultCacheHandler), + getExpiration: defaultCacheHandler.getExpiration.bind(defaultCacheHandler), + async updateTags(tags) { + console.log( + 'ActionOnlyFallbackCacheHandler::updateTags', + JSON.stringify(tags) + ) + return defaultCacheHandler.updateTags(tags) + }, +} + +module.exports = cacheHandler diff --git a/test/production/app-dir/action-only-fallback-resume-data-cache/next.config.js b/test/production/app-dir/action-only-fallback-resume-data-cache/next.config.js index e64bae22d6..337d9c2e1e 100644 --- a/test/production/app-dir/action-only-fallback-resume-data-cache/next.config.js +++ b/test/production/app-dir/action-only-fallback-resume-data-cache/next.config.js @@ -3,6 +3,11 @@ */ const nextConfig = { cacheComponents: true, + cacheHandlers: process.env.TEST_CACHE_HANDLER + ? { + default: require.resolve('./cache-handler.js'), + } + : undefined, } module.exports = nextConfig