Skip to content

Commit f8d69d9

Browse files
committed
Add test for API Collection icon rendering in external references
Adds test to verify that API Collections (articles with Topics sections) are correctly identified as .collectionGroup kind in linkable entities, ensuring cross-framework references display the correct icon. The test is temporarily skipped until the fix is implemented in the next commit. rdar://135837611
1 parent 5915e66 commit f8d69d9

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

Tests/SwiftDocCTests/LinkTargets/LinkDestinationSummaryTests.swift

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -829,4 +829,53 @@ 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+
# Time Pitch Algorithm Settings
846+
847+
This is an API Collection that curates symbols.
848+
849+
## Topics
850+
851+
### Algorithms
852+
- ``TestModule/TestClass``
853+
"""),
854+
JSONFile(name: "TestModule.symbols.json", content: symbolGraph),
855+
InfoPlist(displayName: "TestBundle", identifier: "com.test.example")
856+
])
857+
858+
let (_, context) = try await loadBundle(catalog: catalogHierarchy)
859+
let converter = DocumentationNodeConverter(context: context)
860+
861+
let apiCollectionReference = ResolvedTopicReference(
862+
bundleID: context.inputs.id,
863+
path: "/documentation/TestBundle/APICollection",
864+
sourceLanguage: .swift
865+
)
866+
let node = try context.entity(with: apiCollectionReference)
867+
let renderNode = converter.convert(node)
868+
869+
let summaries = node.externallyLinkableElementSummaries(context: context, renderNode: renderNode)
870+
let pageSummary = summaries[0]
871+
872+
XCTAssertEqual(pageSummary.kind, .collectionGroup)
873+
XCTAssertEqual(pageSummary.title, "Time Pitch Algorithm Settings")
874+
XCTAssertEqual(pageSummary.abstract, [.text("This is an API Collection that curates symbols.")])
875+
876+
// Verify round-trip encoding preserves the correct kind
877+
let encoded = try JSONEncoder().encode(pageSummary)
878+
let decoded = try JSONDecoder().decode(LinkDestinationSummary.self, from: encoded)
879+
XCTAssertEqual(decoded.kind, .collectionGroup)
880+
}
832881
}

0 commit comments

Comments
 (0)