-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test to check for Nuxt 3 compatibility (old folder structure)
- Loading branch information
Showing
8 changed files
with
99 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<template> | ||
<div class="app"> | ||
<NuxtPage /> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { defineMultiCacheOptions } from './../../src/runtime/serverOptions/defineMultiCacheOptions' | ||
|
||
export default defineMultiCacheOptions({ | ||
cacheKeyPrefix: (): Promise<string> => { | ||
return Promise.resolve('MY_CACHE_PREFIX_') | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { defineNuxtConfig } from 'nuxt/config' | ||
import NuxtMultiCache from './../src/module' | ||
|
||
export default defineNuxtConfig({ | ||
modules: [NuxtMultiCache], | ||
|
||
imports: { | ||
autoImport: true, | ||
}, | ||
|
||
multiCache: { | ||
debug: true, | ||
component: { | ||
enabled: true, | ||
}, | ||
route: { | ||
enabled: true, | ||
}, | ||
|
||
data: { | ||
enabled: true, | ||
}, | ||
|
||
cdn: { | ||
enabled: true, | ||
}, | ||
api: { | ||
enabled: true, | ||
cacheTagInvalidationDelay: 5000, | ||
authorization: false, | ||
}, | ||
}, | ||
|
||
compatibilityDate: '2024-10-19', | ||
|
||
future: { | ||
compatibilityVersion: 3, | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<template> | ||
<div>This is a cached page.</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { useRouteCache } from '#imports' | ||
useRouteCache((helper) => { | ||
helper.setCacheable() | ||
}) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "./.nuxt/tsconfig.json" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import path from 'path' | ||
import { setup, $fetch } from '@nuxt/test-utils/e2e' | ||
import { describe, expect, test } from 'vitest' | ||
import purgeAll from './__helpers__/purgeAll' | ||
|
||
describe('With Nuxt 3 "classic" folder structure', async () => { | ||
await setup({ | ||
rootDir: path.resolve(__dirname, './../playground-nuxt3'), | ||
}) | ||
test('the serverOptions file is included correctly', async () => { | ||
await purgeAll() | ||
|
||
// First call puts it into cache. | ||
await $fetch('/', { | ||
method: 'get', | ||
}) | ||
|
||
const stats: any = await $fetch('/__nuxt_multi_cache/stats/route') | ||
|
||
// If the serverOptions was included correctly, it will set a cache prefix. | ||
expect(stats.rows[0].key).toContain('MY_CACHE_PREFIX_') | ||
}) | ||
}) |