@@ -489,47 +489,52 @@ describe("firecrawl tools", () => {
|
489 | 489 | }); |
490 | 490 | }); |
491 | 491 | |
492 | | -it("drops malformed numeric Firecrawl tool options", async () => { |
| 492 | +it("rejects malformed numeric Firecrawl search options before dispatch", async () => { |
493 | 493 | const searchTool = createFirecrawlSearchTool({ |
494 | 494 | config: { env: "test" }, |
495 | 495 | } as never); |
496 | | -await searchTool.execute("call-search", { |
497 | | -query: "web search", |
498 | | -count: 6.5, |
499 | | -timeoutSeconds: Number.POSITIVE_INFINITY, |
500 | | -}); |
501 | 496 | |
502 | | -expect(runFirecrawlSearch).toHaveBeenLastCalledWith({ |
503 | | -cfg: { env: "test" }, |
504 | | -query: "web search", |
505 | | -count: undefined, |
506 | | -timeoutSeconds: undefined, |
507 | | -sources: undefined, |
508 | | -categories: undefined, |
509 | | -scrapeResults: false, |
510 | | -}); |
| 497 | +await expect( |
| 498 | +searchTool.execute("call-search", { |
| 499 | +query: "web search", |
| 500 | +count: 6.5, |
| 501 | +}), |
| 502 | +).rejects.toThrow("count must be an integer from 1 to 10"); |
| 503 | +await expect( |
| 504 | +searchTool.execute("call-search-timeout", { |
| 505 | +query: "web search", |
| 506 | +timeoutSeconds: Number.POSITIVE_INFINITY, |
| 507 | +}), |
| 508 | +).rejects.toThrow("timeoutSeconds must be a positive integer"); |
| 509 | + |
| 510 | +expect(runFirecrawlSearch).not.toHaveBeenCalled(); |
| 511 | +}); |
511 | 512 | |
| 513 | +it("rejects malformed numeric Firecrawl scrape options before dispatch", async () => { |
512 | 514 | const scrapeTool = createFirecrawlScrapeTool({ |
513 | 515 | config: { env: "test" }, |
514 | 516 | } as never); |
515 | | -await scrapeTool.execute("call-scrape", { |
516 | | -url: "https://docs.openclaw.ai", |
517 | | -maxChars: 1500.5, |
518 | | -maxAgeMs: -1, |
519 | | -timeoutSeconds: 22.5, |
520 | | -}); |
521 | 517 | |
522 | | -expect(runFirecrawlScrape).toHaveBeenLastCalledWith({ |
523 | | -cfg: { env: "test" }, |
524 | | -url: "https://docs.openclaw.ai", |
525 | | -extractMode: "markdown", |
526 | | -maxChars: undefined, |
527 | | -onlyMainContent: undefined, |
528 | | -maxAgeMs: undefined, |
529 | | -proxy: undefined, |
530 | | -storeInCache: undefined, |
531 | | -timeoutSeconds: undefined, |
532 | | -}); |
| 518 | +await expect( |
| 519 | +scrapeTool.execute("call-scrape-max-chars", { |
| 520 | +url: "https://docs.openclaw.ai", |
| 521 | +maxChars: 1500.5, |
| 522 | +}), |
| 523 | +).rejects.toThrow("maxChars must be a positive integer"); |
| 524 | +await expect( |
| 525 | +scrapeTool.execute("call-scrape-max-age", { |
| 526 | +url: "https://docs.openclaw.ai", |
| 527 | +maxAgeMs: -1, |
| 528 | +}), |
| 529 | +).rejects.toThrow("maxAgeMs must be a non-negative integer"); |
| 530 | +await expect( |
| 531 | +scrapeTool.execute("call-scrape-timeout", { |
| 532 | +url: "https://docs.openclaw.ai", |
| 533 | +timeoutSeconds: 22.5, |
| 534 | +}), |
| 535 | +).rejects.toThrow("timeoutSeconds must be a positive integer"); |
| 536 | + |
| 537 | +expect(runFirecrawlScrape).not.toHaveBeenCalled(); |
533 | 538 | }); |
534 | 539 | |
535 | 540 | it("passes text mode through and ignores invalid proxy values", async () => { |
|