From 8e5eac4566c5677f57d017e232a69a0e14308540 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Sun, 22 Mar 2026 13:51:50 +0000 Subject: fix: repair moebooru tag suggestions --- SoraTests/ViewDerivedDataTests.swift | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'SoraTests/ViewDerivedDataTests.swift') diff --git a/SoraTests/ViewDerivedDataTests.swift b/SoraTests/ViewDerivedDataTests.swift index f737e1a..ba02145 100644 --- a/SoraTests/ViewDerivedDataTests.swift +++ b/SoraTests/ViewDerivedDataTests.swift @@ -1083,6 +1083,35 @@ final class ViewDerivedDataTests: XCTestCase { // swiftlint:disable:this type_b ) } + func testBooruManagerMoebooruTagSuggestionsUseNameQuery() throws { + let source = try loadSource(at: "Sora/Data/Booru/BooruManager.swift") + let tagSearchSection = try extractFunction( + named: "private func url(forTagsSearch name: String) -> URL?", + from: source + ) + let moebooruNameQueryCount = tokenCount( + matching: #"case\s+\.moebooru:\s*[\s\S]*?URLQueryItem\(name:\s*"name",\s*value:\s*name\)"#, + in: tagSearchSection + ) + let functionNamePatternQueryCount = tokenCount( + matching: #"URLQueryItem\(name:\s*"name_pattern""#, + in: tagSearchSection + ) + + // swiftlint:disable:next prefer_nimble + XCTAssertGreaterThan( + moebooruNameQueryCount, + 0, + "Moebooru tag suggestions should query with `name` so supported providers return filtered matches." + ) + // swiftlint:disable:next prefer_nimble + XCTAssertEqual( + functionNamePatternQueryCount, + 1, + "Only the Gelbooru tag-suggestion branch should still use `name_pattern`." + ) + } + func testBooruRequestConfigurationSupportsOptionalAndCustomUserAgentHeaders() throws { let source = try loadSource(at: "Sora/Data/Booru/BooruRequestConfiguration.swift") let userAgentResolverSection = try extractFunction( -- cgit v1.2.3