@@ -829,4 +829,96 @@ class LinkDestinationSummaryTests: XCTestCase {
829829 " doc://com.example.mymodule/documentation/MyModule/MyClass/myFunc()-9a7po " ,
830830 ] )
831831 }
832+
833+ /// Tests that API Collections (articles with Topics sections) are correctly identified as `.collectionGroup`
834+ /// kind in linkable entities, ensuring cross-framework references display the correct icon.
835+ func testAPICollectionKindForLinkDestinationSummary( ) async throws {
836+ throw XCTSkip ( " Test will be enabled after implementing the fix " )
837+
838+ let symbolGraph = makeSymbolGraph (
839+ moduleName: " TestModule " ,
840+ symbols: [ makeSymbol ( id: " test-class " , kind: . class, pathComponents: [ " TestClass " ] ) ]
841+ )
842+
843+ let catalogHierarchy = Folder ( name: " unit-test.docc " , content: [
844+ TextFile ( name: " APICollection.md " , utf8Content: """
845+ # API Collection
846+
847+ This is an API Collection that curates symbols.
848+
849+ ## Topics
850+
851+ - ``TestModule/TestClass``
852+ """ ) ,
853+ JSONFile ( name: " TestModule.symbols.json " , content: symbolGraph)
854+ ] )
855+
856+ let ( _, context) = try await loadBundle ( catalog: catalogHierarchy)
857+ let converter = DocumentationNodeConverter ( context: context)
858+
859+ let apiCollectionReference = ResolvedTopicReference (
860+ bundleID: context. inputs. id,
861+ path: " /documentation/unit-test/APICollection " ,
862+ sourceLanguage: . swift
863+ )
864+ let node = try context. entity ( with: apiCollectionReference)
865+ let renderNode = converter. convert ( node)
866+
867+ let summaries = node. externallyLinkableElementSummaries ( context: context, renderNode: renderNode)
868+ let pageSummary = try XCTUnwrap ( summaries. first)
869+
870+ XCTAssertEqual ( pageSummary. kind, . collectionGroup)
871+ XCTAssertEqual ( pageSummary. title, " API Collection " )
872+ XCTAssertEqual ( pageSummary. abstract, [ . text( " This is an API Collection that curates symbols. " ) ] )
873+
874+ // Verify round-trip encoding preserves the correct kind
875+ try assertRoundTripCoding ( pageSummary)
876+ }
877+
878+ /// Tests that explicit `@PageKind(article)` metadata overrides API Collection detection,
879+ /// ensuring that explicit page kind directives take precedence over automatic detection.
880+ func testExplicitPageKindOverridesAPICollectionDetection( ) async throws {
881+ let symbolGraph = makeSymbolGraph (
882+ moduleName: " TestModule " ,
883+ symbols: [ makeSymbol ( id: " test-class " , kind: . class, pathComponents: [ " TestClass " ] ) ]
884+ )
885+
886+ let catalogHierarchy = Folder ( name: " unit-test.docc " , content: [
887+ TextFile ( name: " ExplicitArticle.md " , utf8Content: """
888+ # Explicit Article
889+
890+ This looks like an API Collection but is explicitly marked as an article.
891+
892+ @Metadata {
893+ @PageKind(article)
894+ }
895+
896+ ## Topics
897+
898+ - ``TestModule/TestClass``
899+ """ ) ,
900+ JSONFile ( name: " TestModule.symbols.json " , content: symbolGraph)
901+ ] )
902+
903+ let ( _, context) = try await loadBundle ( catalog: catalogHierarchy)
904+ let converter = DocumentationNodeConverter ( context: context)
905+
906+ let explicitArticleReference = ResolvedTopicReference (
907+ bundleID: context. inputs. id,
908+ path: " /documentation/unit-test/ExplicitArticle " ,
909+ sourceLanguage: . swift
910+ )
911+ let node = try context. entity ( with: explicitArticleReference)
912+ let renderNode = converter. convert ( node)
913+
914+ let summaries = node. externallyLinkableElementSummaries ( context: context, renderNode: renderNode)
915+ let pageSummary = try XCTUnwrap ( summaries. first)
916+
917+ // Should be .article because of explicit @PageKind(article), not .collectionGroup
918+ XCTAssertEqual ( pageSummary. kind, . article)
919+ XCTAssertEqual ( pageSummary. title, " Explicit Article " )
920+
921+ // Verify round-trip encoding preserves the correct kind
922+ try assertRoundTripCoding ( pageSummary)
923+ }
832924}
0 commit comments