summaryrefslogtreecommitdiff
path: root/SoraTests/ViewDerivedDataTests.swift
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-03-22 13:55:55 +0000
committerFuwn <[email protected]>2026-03-22 14:02:13 +0000
commit9a19ff4b3caa8d650a009636e4234f5c677b1438 (patch)
treeef6b2dcab091e2558d06e7c992755fdb53c110b3 /SoraTests/ViewDerivedDataTests.swift
parentfix: repair moebooru tag suggestions (diff)
downloadsora-testing-9a19ff4b3caa8d650a009636e4234f5c677b1438.tar.xz
sora-testing-9a19ff4b3caa8d650a009636e4234f5c677b1438.zip
fix: restore danbooru tag suggestions
Diffstat (limited to 'SoraTests/ViewDerivedDataTests.swift')
-rw-r--r--SoraTests/ViewDerivedDataTests.swift43
1 files changed, 43 insertions, 0 deletions
diff --git a/SoraTests/ViewDerivedDataTests.swift b/SoraTests/ViewDerivedDataTests.swift
index ba02145..fd3f1da 100644
--- a/SoraTests/ViewDerivedDataTests.swift
+++ b/SoraTests/ViewDerivedDataTests.swift
@@ -1112,6 +1112,49 @@ final class ViewDerivedDataTests: XCTestCase { // swiftlint:disable:this type_b
)
}
+ func testBooruManagerDanbooruTagSuggestionsUseJSONSearchEndpoint() 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 danbooruJSONPathCount = tokenCount(
+ matching: #"case\s+\.danbooru:\s*[\s\S]*?components\.path\s*=\s*"/tags\.json""#,
+ in: tagSearchSection
+ )
+ let danbooruWildcardQueryCount = tokenCount(
+ matching: #"URLQueryItem\(name:\s*"search\[name_matches\]""#,
+ in: tagSearchSection
+ )
+ let danbooruParserSelectionCount = tokenCount(
+ matching: #"flavor\s*==\s*\.danbooru\s*\?\s*DanbooruTagParser\(data:\s*data\)\.parse\(\)"#,
+ in: searchTagsSection
+ )
+
+ // swiftlint:disable:next prefer_nimble
+ XCTAssertGreaterThan(
+ danbooruJSONPathCount,
+ 0,
+ "Danbooru tag suggestions should use the JSON `/tags.json` endpoint."
+ )
+ // swiftlint:disable:next prefer_nimble
+ XCTAssertGreaterThan(
+ danbooruWildcardQueryCount,
+ 0,
+ "Danbooru tag suggestions should search with `search[name_matches]=<term>*`."
+ )
+ // swiftlint:disable:next prefer_nimble
+ XCTAssertGreaterThan(
+ danbooruParserSelectionCount,
+ 0,
+ "Danbooru tag suggestions should decode JSON through DanbooruTagParser."
+ )
+ }
+
func testBooruRequestConfigurationSupportsOptionalAndCustomUserAgentHeaders() throws {
let source = try loadSource(at: "Sora/Data/Booru/BooruRequestConfiguration.swift")
let userAgentResolverSection = try extractFunction(