/** * E2E tests verifying that the HTML→markdown pipeline preserves semantic content. * * These tests use well-known text from fixtures/sample.html to assert that the * core conversion is correct, not merely that the server returns 200. */ import { describe, it } from 'node:test'; import assert from 'node:assert'; import { crawl, getContent } from '../helpers/client'; describe('content fidelity: headings', () => { it('h1 becomes a level-1 ATX heading', async () => { const res = await crawl({ respondWith: 'markdown' }); assert.strictEqual(res.status, 200); assert.match(getContent(res), /^# Web Crawling Guide$/m); }); it('all seven h2 section headings survive extraction', async () => { const content = getContent(await crawl({ respondWith: 'markdown' })); for (const section of ['One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven']) { assert.ok(content.includes(`Section ${section}`), `Section ${section} missing from output`); } }); }); describe('content fidelity: inline elements', () => { it('bold text is wrapped with strong delimiters', async () => { const content = getContent(await crawl({ respondWith: 'markdown' })); // fixture: main content assert.match(content, /\*\*main content\*\*/); }); it('italic text is wrapped with em delimiters', async () => { const content = getContent(await crawl({ respondWith: 'markdown' })); // fixture: fetching pages assert.match(content, /_fetching pages_|\*fetching pages\*/); }); }); describe('content fidelity: blockquote', () => { it('blockquote is formatted with > prefix', async () => { const content = getContent(await crawl({ respondWith: 'markdown' })); // fixture:

The web is a graph, not a tree.

assert.match(content, /^> .*The web is a graph, not a tree\./m); }); }); describe('content fidelity: code block', () => { it('pre/code renders as a fenced code block', async () => { const content = getContent(await crawl({ respondWith: 'markdown' })); // fixture: const crawler = new Crawler(); assert.match(content, /```[\s\S]*?const crawler = new Crawler\(\)/); }); it('code block contains both lines from the fixture', async () => { const content = getContent(await crawl({ respondWith: 'markdown' })); assert.ok(content.includes("crawler.start('https://example.com')")); }); }); describe('content fidelity: unordered list', () => { it('all three list items appear in output', async () => { const content = getContent(await crawl({ respondWith: 'markdown' })); // fixture: