mirror of
https://github.com/baserow/baserow.git
synced 2026-12-04 16:28:31 +00:00
64 lines
1.8 KiB
JavaScript
64 lines
1.8 KiB
JavaScript
import { describe, expect, test, vi } from 'vitest'
|
|
|
|
vi.mock('#imports', () => ({
|
|
defineNuxtPlugin: vi.fn((plugin) => plugin),
|
|
useRequestURL: vi.fn(),
|
|
useRouter: vi.fn(),
|
|
useRuntimeConfig: vi.fn(),
|
|
}))
|
|
|
|
const { shouldRemoveRoute } =
|
|
await import('@baserow/modules/builder/plugins/router')
|
|
|
|
const publishedHostname = {
|
|
isWebFrontendHostname: false,
|
|
isBuilderPreviewHostname: false,
|
|
isBuilderPreviewRequest: false,
|
|
}
|
|
|
|
const webFrontendPreviewRequest = {
|
|
isWebFrontendHostname: true,
|
|
isBuilderPreviewHostname: true,
|
|
isBuilderPreviewRequest: true,
|
|
}
|
|
|
|
const webFrontendRegularRequest = {
|
|
isWebFrontendHostname: true,
|
|
isBuilderPreviewHostname: true,
|
|
isBuilderPreviewRequest: false,
|
|
}
|
|
|
|
describe('builder router route filtering', () => {
|
|
test('keeps a route shared by published and preview builders on published hostnames', () => {
|
|
const route = {
|
|
meta: { publishedBuilderRoute: true, previewBuilderRoute: true },
|
|
}
|
|
|
|
expect(shouldRemoveRoute(route, publishedHostname)).toBe(false)
|
|
})
|
|
|
|
test('removes preview-only routes from published hostnames', () => {
|
|
const route = { meta: { previewBuilderRoute: true } }
|
|
|
|
expect(shouldRemoveRoute(route, publishedHostname)).toBe(true)
|
|
})
|
|
|
|
test('removes regular frontend routes from published hostnames', () => {
|
|
const route = { meta: {} }
|
|
|
|
expect(shouldRemoveRoute(route, publishedHostname)).toBe(true)
|
|
})
|
|
|
|
test('keeps the catch-all preview route for a prefixed preview request', () => {
|
|
const route = { meta: { previewBuilderRoute: true } }
|
|
|
|
expect(shouldRemoveRoute(route, webFrontendPreviewRequest)).toBe(false)
|
|
})
|
|
|
|
test('removes the catch-all preview route for regular frontend requests', () => {
|
|
const route = { meta: { previewBuilderRoute: true } }
|
|
|
|
expect(shouldRemoveRoute(route, webFrontendRegularRequest)).toBe(true)
|
|
})
|
|
})
|