import { LLMS_TXT_URL } from 'common/markdown-affordance' import { beforeEach, describe, expect, it, vi } from 'vitest' const reference = vi.hoisted(() => ({ sections: [] as Array<{ id: string; slug: string; title: string; type: string }>, })) vi.mock('~/features/docs/Reference.generated.singleton', () => ({ getFlattenedSections: async () => reference.sections, getFunctionsList: async () => [], getTypeSpec: async () => undefined, })) vi.mock('~/features/docs/Reference.mdx', () => ({ getRefMarkdown: async () => 'Reference content', })) vi.mock('next/navigation', () => ({ notFound: () => { throw new Error('notFound') }, })) import { GET } from './route' function section(slug: string, title: string, type = 'markdown') { return { id: slug, slug, title, type } } async function html(path: string) { const response = await GET(new Request(`https://supabase.com${path}`)) expect(response.status).toBe(200) return response.text() } beforeEach(() => { reference.sections = [] }) describe('crawler reference html', () => { it('points agents at llms.txt before the navigation', async () => { reference.sections = [section('introduction', 'Introduction')] const page = await html('/reference/javascript/introduction') expect(page).toContain(`href="${LLMS_TXT_URL}"`) expect(page.indexOf(LLMS_TXT_URL)).toBeLessThan(page.indexOf('