Add web search and page retrieval to Toolbox
This commit is contained in:
@@ -554,3 +554,20 @@ final class WorkspaceLibraryTests: XCTestCase {
|
||||
XCTAssertNoThrow(try WebClipCapture.url("https://example.com"))
|
||||
}
|
||||
}
|
||||
|
||||
final class WebToolsTests: XCTestCase {
|
||||
func testSearchAndRetrieveKeepSourceURLs() async throws {
|
||||
guard let endpoint = ProcessInfo.processInfo.environment["AISTUDIO_TEST_WEB_URL"] else {
|
||||
throw XCTSkip("Run Scripts/test.sh to configure the web fixture.")
|
||||
}
|
||||
let results = try await WebSearch.results(endpoint: endpoint, query: "tides & moon")
|
||||
XCTAssertEqual(results.count, 1)
|
||||
let result = try XCTUnwrap(results.first)
|
||||
XCTAssertEqual(result.title, "Moon and tides")
|
||||
XCTAssertEqual(result.snippet, "A fixture & summary")
|
||||
let page = try await WebClipCapture.page(from: result.url.absoluteString)
|
||||
XCTAssertEqual(page.url, result.url)
|
||||
XCTAssertEqual(page.text, "Moon and tides\nTest passage.")
|
||||
XCTAssertTrue(page.reference.contains(result.url.absoluteString))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user