Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions test/unit/checks/content-negotiation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,8 @@ describe('content-negotiation', () => {
});

it('normalizes .md URLs to canonical form before testing (#33)', async () => {
// The handler is on the canonical (non-.md) URL because the check
// should strip the extension before fetching.
// Curated pages bypass discovery, so .md URLs reach the check directly.
// The check should strip the extension before fetching.
server.use(
http.get(
'http://test.local/docs/page1',
Expand All @@ -366,8 +366,12 @@ describe('content-negotiation', () => {
),
);

const content = `# Docs\n> Summary\n## Links\n- [Page 1](http://test.local/docs/page1.md): First\n`;
const result = await check.run(makeCtx(content));
const ctx = createContext('http://test.local', {
requestDelay: 0,
samplingStrategy: 'curated',
curatedPages: ['http://test.local/docs/page1.md'],
});
const result = await check.run(ctx);

expect(result.status).toBe('fail');
expect(result.details?.normalizedMdUrls).toBe(1);
Expand All @@ -377,6 +381,7 @@ describe('content-negotiation', () => {
});

it('reports testedUrl when .md URL is normalized (#33)', async () => {
// Curated pages bypass discovery, so .md URLs reach the check directly.
server.use(
http.get(
'http://test.local/docs/page1',
Expand All @@ -388,8 +393,12 @@ describe('content-negotiation', () => {
),
);

const content = `# Docs\n> Summary\n## Links\n- [Page 1](http://test.local/docs/page1.md): First\n`;
const result = await check.run(makeCtx(content));
const ctx = createContext('http://test.local', {
requestDelay: 0,
samplingStrategy: 'curated',
curatedPages: ['http://test.local/docs/page1.md'],
});
const result = await check.run(ctx);

const pageResults = result.details?.pageResults as Array<{
url: string;
Expand Down
9 changes: 8 additions & 1 deletion test/unit/checks/llms-txt-directive.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,8 @@ describe('llms-txt-directive', () => {
});

it('falls back to .md URL when HTML version has no directive', async () => {
// Curated pages bypass discovery, so .md URLs reach the check directly.
// The check should try the HTML version first, then fall back to the .md URL.
server.use(
http.get(
'http://test.local/docs/page1/',
Expand All @@ -284,7 +286,12 @@ describe('llms-txt-directive', () => {
),
);

const result = await check.run(makeCtx(llms('/docs/page1/index.md')));
const ctx = createContext('http://test.local', {
requestDelay: 0,
samplingStrategy: 'curated',
curatedPages: ['http://test.local/docs/page1/index.md'],
});
const result = await check.run(ctx);
expect(result.status).toBe('pass');
expect(result.details?.foundCount).toBe(1);
const pages = result.details?.pageResults as Array<{ source?: string }>;
Expand Down