@@ -28,14 +28,32 @@ describe("link ingestion", () => {
2828 scrapeMock . mockReset ( ) ;
2929 } ) ;
3030
31- it ( "gets reader markdown and a full-page screenshot in one Firecrawl run " , async ( ) => {
31+ it ( "cleans Firecrawl HTML with Defuddle and keeps the full-page screenshot" , async ( ) => {
3232 scrapeMock . mockResolvedValue ( {
33- markdown :
34- "## Introduction\n\nToday we're announcing Project Glasswing.\n\n**Mythos Preview** found critical vulnerabilities." ,
33+ html : `<!doctype html>
34+ <html>
35+ <head>
36+ <title>Project Glasswing</title>
37+ <meta name="description" content="Securing critical software for the AI era">
38+ <link rel="icon" href="/favicon.ico">
39+ </head>
40+ <body>
41+ <nav>Products Pricing Company</nav>
42+ <main>
43+ <article>
44+ <h1>Project Glasswing</h1>
45+ <h2>Introduction</h2>
46+ <p>Today we're announcing Project Glasswing.</p>
47+ <p><strong>Mythos Preview</strong> found critical vulnerabilities.</p>
48+ </article>
49+ </main>
50+ <footer>Privacy Terms</footer>
51+ </body>
52+ </html>` ,
3553 metadata : {
36- description : "Securing critical software for the AI era " ,
37- favicon : "https://anthropic.com/favicon .ico" ,
38- title : "Project Glasswing " ,
54+ description : "Fallback description " ,
55+ favicon : "https://anthropic.com/fallback .ico" ,
56+ title : "Fallback title " ,
3957 } ,
4058 screenshot : "https://firecrawl.example/screenshots/glasswing.png" ,
4159 summary : "A new initiative for securing critical software." ,
@@ -46,21 +64,23 @@ describe("link ingestion", () => {
4664 expect ( preview . mode ) . toBe ( "firecrawl" ) ;
4765 expect ( preview . provider ) . toBe ( "firecrawl" ) ;
4866 expect ( preview . kind ) . toBe ( "article" ) ;
67+ expect ( preview . title ) . toBe ( "Project Glasswing" ) ;
4968 expect ( preview . imageUrl ) . toBe (
5069 "https://firecrawl.example/screenshots/glasswing.png"
5170 ) ;
52- expect ( preview . readerMarkdown ) . toContain ( "Introduction" ) ;
71+ expect ( preview . readerMarkdown ) . toContain ( "## Introduction" ) ;
5372 expect ( preview . readerMarkdown ) . toContain ( "**Mythos Preview**" ) ;
73+ expect ( preview . readerMarkdown ) . not . toContain ( "Products Pricing Company" ) ;
5474 expect ( scrapeMock ) . toHaveBeenCalledTimes ( 1 ) ;
5575 expect ( scrapeMock ) . toHaveBeenCalledWith (
5676 "https://anthropic.com/glasswing" ,
5777 expect . objectContaining ( {
5878 formats : expect . arrayContaining ( [
59- "markdown " ,
79+ "html " ,
6080 "summary" ,
6181 expect . objectContaining ( { fullPage : true , type : "screenshot" } ) ,
6282 ] ) ,
63- onlyMainContent : true ,
83+ onlyMainContent : false ,
6484 } )
6585 ) ;
6686 } ) ;
0 commit comments