doesitarm/test/prebuild/pagefind.test.js
ThatGuySam e1da6eb880 feat(search): add pagefind provider support
Add Pagefind indexing and browser search adapters behind a provider switch.

This lets prebuild generate either Stork or Pagefind search artifacts and lets the existing search UI run against Pagefind while preserving scoped filters, excerpts, and result metadata.
2026-03-15 13:42:07 -05:00

64 lines
2.1 KiB
JavaScript

import { describe, it, expect } from 'vitest'
import {
mapSitemapEntryToPagefindRecord,
shouldIndexSitemapEntry
} from '~/helpers/pagefind/index.js'
describe('Pagefind records', () => {
it('should skip sitemap entries without searchable payloads', () => {
expect( shouldIndexSitemapEntry({
route: '/games',
payload: {}
}) ).toBe( false )
})
it('should map benchmark entries to Pagefind records', () => {
const record = mapSitemapEntryToPagefindRecord({
route: '/app/example/benchmarks',
payload: {
app: {
name: 'Example App',
text: '✅ Native support',
content: 'Runs fast on Apple Silicon',
aliases: [ 'Example' ],
tags: [ 'Utilities' ],
status: 'no-in-progress',
slug: 'example',
category: {
slug: 'system-tools',
label: 'System Tools'
},
lastUpdated: {
timestamp: 1234567890
}
}
}
})
expect( record ).toMatchObject({
url: '/app/example/benchmarks',
language: 'en',
meta: {
title: 'Example App Benchmarks',
text: '✅ Native support',
slug: 'example',
categorySlug: 'system-tools',
routeType: 'benchmarks',
lastUpdatedTimestamp: '1234567890'
},
filters: {
status: [ 'no_in_progress' ],
category: [ 'system_tools' ],
type: [ 'benchmarks' ]
},
sort: {
updated: '1234567890'
}
})
expect( record.content ).toContain('Example App Benchmarks')
expect( record.content ).toContain('Runs fast on Apple Silicon')
expect( record.content ).toContain('Apple Silicon App Tested')
})
})