@@ -829,4 +829,98 @@ 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+ InfoPlist ( displayName: " TestBundle " , identifier: " com.test.example " )
855+ ] )
856+
857+ let ( _, context) = try await loadBundle ( catalog: catalogHierarchy)
858+ let converter = DocumentationNodeConverter ( context: context)
859+
860+ let apiCollectionReference = ResolvedTopicReference (
861+ bundleID: context. inputs. id,
862+ path: " /documentation/TestBundle/APICollection " ,
863+ sourceLanguage: . swift
864+ )
865+ let node = try context. entity ( with: apiCollectionReference)
866+ let renderNode = converter. convert ( node)
867+
868+ let summaries = node. externallyLinkableElementSummaries ( context: context, renderNode: renderNode)
869+ let pageSummary = try XCTUnwrap ( summaries. first)
870+
871+ XCTAssertEqual ( pageSummary. kind, . collectionGroup)
872+ XCTAssertEqual ( pageSummary. title, " API Collection " )
873+ XCTAssertEqual ( pageSummary. abstract, [ . text( " This is an API Collection that curates symbols. " ) ] )
874+
875+ // Verify round-trip encoding preserves the correct kind
876+ try assertRoundTripCoding ( pageSummary)
877+ }
878+
879+ /// Tests that explicit `@PageKind(article)` metadata overrides API Collection detection,
880+ /// ensuring that explicit page kind directives take precedence over automatic detection.
881+ func testExplicitPageKindOverridesAPICollectionDetection( ) async throws {
882+ let symbolGraph = makeSymbolGraph (
883+ moduleName: " TestModule " ,
884+ symbols: [ makeSymbol ( id: " test-class " , kind: . class, pathComponents: [ " TestClass " ] ) ]
885+ )
886+
887+ let catalogHierarchy = Folder ( name: " unit-test.docc " , content: [
888+ TextFile ( name: " ExplicitArticle.md " , utf8Content: """
889+ # Explicit Article
890+
891+ This looks like an API Collection but is explicitly marked as an article.
892+
893+ @Metadata {
894+ @PageKind(article)
895+ }
896+
897+ ## Topics
898+
899+ - ``TestModule/TestClass``
900+ """ ) ,
901+ JSONFile ( name: " TestModule.symbols.json " , content: symbolGraph) ,
902+ InfoPlist ( displayName: " TestBundle " , identifier: " com.test.example " )
903+ ] )
904+
905+ let ( _, context) = try await loadBundle ( catalog: catalogHierarchy)
906+ let converter = DocumentationNodeConverter ( context: context)
907+
908+ let explicitArticleReference = ResolvedTopicReference (
909+ bundleID: context. inputs. id,
910+ path: " /documentation/TestBundle/ExplicitArticle " ,
911+ sourceLanguage: . swift
912+ )
913+ let node = try context. entity ( with: explicitArticleReference)
914+ let renderNode = converter. convert ( node)
915+
916+ let summaries = node. externallyLinkableElementSummaries ( context: context, renderNode: renderNode)
917+ let pageSummary = try XCTUnwrap ( summaries. first)
918+
919+ // Should be .article because of explicit @PageKind(article), not .collectionGroup
920+ XCTAssertEqual ( pageSummary. kind, . article)
921+ XCTAssertEqual ( pageSummary. title, " Explicit Article " )
922+
923+ // Verify round-trip encoding preserves the correct kind
924+ try assertRoundTripCoding ( pageSummary)
925+ }
832926}
0 commit comments