@@ -568,31 +568,34 @@ describe("createPdfTool", () => {
568568 } ) ;
569569 } ) ;
570570
571- it ( "rejects fractional page selections before fallback extraction" , async ( ) => {
572- await withTempPdfAgentDir ( async ( agentDir ) => {
573- await stubPdfToolInfra ( agentDir , {
574- provider : "openai" ,
575- api : "openai-responses" ,
576- input : [ "text" ] ,
577- } ) ;
578- const extractSpy = vi . spyOn ( pdfExtractModule , "extractPdfContent" ) . mockResolvedValue ( {
579- text : "Extracted content" ,
580- images : [ ] ,
571+ it . each ( [ "1.5" , "1,2.5" ] ) (
572+ "rejects fractional page selection %s before fallback extraction" ,
573+ async ( pages ) => {
574+ await withTempPdfAgentDir ( async ( agentDir ) => {
575+ await stubPdfToolInfra ( agentDir , {
576+ provider : "openai" ,
577+ api : "openai-responses" ,
578+ input : [ "text" ] ,
579+ } ) ;
580+ const extractSpy = vi . spyOn ( pdfExtractModule , "extractPdfContent" ) . mockResolvedValue ( {
581+ text : "Extracted content" ,
582+ images : [ ] ,
583+ } ) ;
584+ const cfg = withPdfModel ( OPENAI_PDF_MODEL ) ;
585+ const tool = requirePdfTool ( ( await loadCreatePdfTool ( ) ) ( { config : cfg , agentDir } ) ) ;
586+
587+ await expect (
588+ tool . execute ( "t1" , {
589+ prompt : "summarize" ,
590+ pdf : "/tmp/doc.pdf" ,
591+ pages,
592+ } ) ,
593+ ) . rejects . toThrow ( `Invalid page number: "${ pages . includes ( "," ) ? "2.5" : pages } "` ) ;
594+ expect ( extractSpy ) . not . toHaveBeenCalled ( ) ;
595+ expect ( completeMock ) . not . toHaveBeenCalled ( ) ;
581596 } ) ;
582- const cfg = withPdfModel ( OPENAI_PDF_MODEL ) ;
583- const tool = requirePdfTool ( ( await loadCreatePdfTool ( ) ) ( { config : cfg , agentDir } ) ) ;
584-
585- await expect (
586- tool . execute ( "t1" , {
587- prompt : "summarize" ,
588- pdf : "/tmp/doc.pdf" ,
589- pages : "1.5" ,
590- } ) ,
591- ) . rejects . toThrow ( 'Invalid page number: "1.5"' ) ;
592- expect ( extractSpy ) . not . toHaveBeenCalled ( ) ;
593- expect ( completeMock ) . not . toHaveBeenCalled ( ) ;
594- } ) ;
595- } ) ;
597+ } ,
598+ ) ;
596599
597600 it ( "rejects password parameter for native PDF providers" , async ( ) => {
598601 await withTempPdfAgentDir ( async ( agentDir ) => {
0 commit comments