2024-03-16 18:53:01 +00:00
|
|
|
import { vi } from 'vitest'
|
|
|
|
import { defineEventHandler } from 'h3'
|
|
|
|
|
|
|
|
import { registerEndpoint } from '@nuxt/test-utils/runtime'
|
|
|
|
|
|
|
|
vi.mock('#app/compat/idle-callback', () => ({
|
2024-04-05 18:08:32 +00:00
|
|
|
requestIdleCallback: (cb: Function) => cb(),
|
2024-07-03 16:46:42 +00:00
|
|
|
cancelIdleCallback: () => {},
|
2024-03-16 18:53:01 +00:00
|
|
|
}))
|
|
|
|
|
|
|
|
const timestamp = Date.now()
|
|
|
|
registerEndpoint('/_nuxt/builds/latest.json', defineEventHandler(() => ({
|
|
|
|
id: 'override',
|
2024-04-05 18:08:32 +00:00
|
|
|
timestamp,
|
2024-03-16 18:53:01 +00:00
|
|
|
})))
|
|
|
|
registerEndpoint('/_nuxt/builds/meta/override.json', defineEventHandler(() => ({
|
|
|
|
id: 'override',
|
|
|
|
timestamp,
|
|
|
|
matcher: {
|
|
|
|
static: {
|
|
|
|
'/': null,
|
|
|
|
'/pre': null,
|
2024-04-05 18:08:32 +00:00
|
|
|
'/pre/test': { redirect: true },
|
2024-03-16 18:53:01 +00:00
|
|
|
},
|
|
|
|
wildcard: { '/pre': { prerender: true } },
|
2024-04-05 18:08:32 +00:00
|
|
|
dynamic: {},
|
2024-03-16 18:53:01 +00:00
|
|
|
},
|
2024-04-05 18:08:32 +00:00
|
|
|
prerendered: ['/specific-prerendered'],
|
2024-03-16 18:53:01 +00:00
|
|
|
})))
|