test_page_assist.js (1192B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 const { PageAssist } = ChromeUtils.importESModule( 5 "moz-src:///browser/components/genai/PageAssist.sys.mjs" 6 ); 7 8 /** 9 * Test PageAssist fetchAiResponse when no page data is provided 10 */ 11 add_task(async function test_fetchAiResponse_no_page_data() { 12 const response = await PageAssist.fetchAiResponse("test prompt", null); 13 Assert.equal( 14 response, 15 null, 16 "Should return null when no page data is provided" 17 ); 18 }); 19 20 /** 21 * Test PageAssist fetchAiResponse with valid page data 22 */ 23 add_task(async function test_fetchAiResponse_valid_page_data() { 24 // Create mock page data 25 const mockPageData = { 26 url: "https://example.com/test", 27 title: "Test Page Title", 28 content: "<h1>Test Content</h1>", 29 textContent: "Test Content", 30 excerpt: "This is a test excerpt", 31 isReaderable: true, 32 }; 33 34 const userPrompt = "What is this page about?"; 35 const response = await PageAssist.fetchAiResponse(userPrompt, mockPageData); 36 37 // Validate response format - TODO: when response shape is finalized update this 38 Assert.ok(response, "Should return a response"); 39 });