Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
39 lines
1.3 KiB
TypeScript
39 lines
1.3 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import { resolveEventDetailHref, resolveLegacyEventDestination } from '@/lib/seo/legacyEventRedirect'
|
|
|
|
const event = {
|
|
id: '462f10ff-7466-4a58-9631-d09f02b76eaf',
|
|
slug: 'tehran-book-club',
|
|
status: 'published',
|
|
settings: { isDiscoverable: true },
|
|
}
|
|
|
|
describe('legacy event redirect policy', () => {
|
|
it.each(['published', 'full', 'completed'])('redirects a discoverable %s event', (status) => {
|
|
expect(resolveLegacyEventDestination({ ...event, status })).toBe('/e/tehran-book-club')
|
|
})
|
|
|
|
it('keeps drafts and hidden events on their private UUID detail', () => {
|
|
expect(resolveLegacyEventDestination({ ...event, status: 'draft' })).toBeNull()
|
|
expect(resolveLegacyEventDestination({ ...event, settings: { isDiscoverable: false } })).toBeNull()
|
|
})
|
|
})
|
|
|
|
describe('resolveEventDetailHref', () => {
|
|
const event = {
|
|
id: '462f10ff-7466-4a58-9631-d09f02b76eaf',
|
|
slug: 'tehran-book-club',
|
|
status: 'published',
|
|
settings: { isDiscoverable: true },
|
|
}
|
|
|
|
it('uses the canonical slug for public events', () => {
|
|
expect(resolveEventDetailHref(event)).toBe('/e/tehran-book-club')
|
|
})
|
|
|
|
it('falls back to the UUID route for private drafts', () => {
|
|
expect(resolveEventDetailHref({ ...event, status: 'draft' })).toBe('/e/462f10ff-7466-4a58-9631-d09f02b76eaf')
|
|
})
|
|
})
|