summaryrefslogtreecommitdiff
path: root/SoraTests/ViewDerivedDataTests.swift
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-03-22 13:57:35 +0000
committerFuwn <[email protected]>2026-03-22 14:02:14 +0000
commitcf602317509505a8acad376ac73a650391a26f8e (patch)
treeaad34713efcadfa780c6ced8fb8845a15a2830a1 /SoraTests/ViewDerivedDataTests.swift
parentfix: restore danbooru tag suggestions (diff)
downloadsora-testing-cf602317509505a8acad376ac73a650391a26f8e.tar.xz
sora-testing-cf602317509505a8acad376ac73a650391a26f8e.zip
fix: restore gelbooru tag suggestions
Diffstat (limited to 'SoraTests/ViewDerivedDataTests.swift')
-rw-r--r--SoraTests/ViewDerivedDataTests.swift55
1 files changed, 55 insertions, 0 deletions
diff --git a/SoraTests/ViewDerivedDataTests.swift b/SoraTests/ViewDerivedDataTests.swift
index fd3f1da..7c6e379 100644
--- a/SoraTests/ViewDerivedDataTests.swift
+++ b/SoraTests/ViewDerivedDataTests.swift
@@ -1155,6 +1155,61 @@ final class ViewDerivedDataTests: XCTestCase { // swiftlint:disable:this type_b
)
}
+ func testBooruManagerGelbooruTagSuggestionsUseAutocompleteEndpoint() throws {
+ let source = try loadSource(at: "Sora/Data/Booru/BooruManager.swift")
+ let searchTagsSection = try extractFunction(
+ named: "func searchTags(name: String) async -> [BooruTag]",
+ from: source
+ )
+ let tagSearchSection = try extractFunction(
+ named: "private func url(forTagsSearch name: String) -> URL?",
+ from: source
+ )
+ let gelbooruAutocompletePageCount = tokenCount(
+ matching: #"URLQueryItem\(name:\s*"page",\s*value:\s*"autocomplete2"\)"#,
+ in: tagSearchSection
+ )
+ let gelbooruAutocompleteTypeCount = tokenCount(
+ matching: #"URLQueryItem\(name:\s*"type",\s*value:\s*"tag_query"\)"#,
+ in: tagSearchSection
+ )
+ let safebooruFallbackCount = tokenCount(
+ matching: #"if\s+provider\s*==\s*\.safebooru"#,
+ in: tagSearchSection
+ )
+ let gelbooruParserSelectionCount = tokenCount(
+ matching:
+ #"flavor\s*==\s*\.gelbooru,\s*provider\s*!=\s*\.safebooru\s*\{\s*"#
+ + #"GelbooruAutocompleteTagParser\(data:\s*data\)\.parse\(\)"#,
+ in: searchTagsSection
+ )
+
+ // swiftlint:disable:next prefer_nimble
+ XCTAssertGreaterThan(
+ gelbooruAutocompletePageCount,
+ 0,
+ "Gelbooru tag suggestions should use the public `autocomplete2` endpoint."
+ )
+ // swiftlint:disable:next prefer_nimble
+ XCTAssertGreaterThan(
+ gelbooruAutocompleteTypeCount,
+ 0,
+ "Gelbooru autocomplete requests should identify tag-query lookups explicitly."
+ )
+ // swiftlint:disable:next prefer_nimble
+ XCTAssertGreaterThan(
+ safebooruFallbackCount,
+ 0,
+ "Safebooru should stay on the XML tag API because its autocomplete endpoint redirects away."
+ )
+ // swiftlint:disable:next prefer_nimble
+ XCTAssertGreaterThan(
+ gelbooruParserSelectionCount,
+ 0,
+ "Gelbooru autocomplete responses should decode through GelbooruAutocompleteTagParser."
+ )
+ }
+
func testBooruRequestConfigurationSupportsOptionalAndCustomUserAgentHeaders() throws {
let source = try loadSource(at: "Sora/Data/Booru/BooruRequestConfiguration.swift")
let userAgentResolverSection = try extractFunction(