@@ -1320,6 +1320,32 @@ class PathHierarchyTests: XCTestCase {
13201320 XCTAssert ( overloadedProtocolMethod. symbol? . identifier. precise. hasSuffix ( SymbolGraph . Symbol. overloadGroupIdentifierSuffix) == true )
13211321 }
13221322
1323+ func testDoesNotSuggestBundleNameForSymbolLink( ) throws {
1324+ let exampleDocumentation = Folder ( name: " Something.docc " , content: [
1325+ JSONFile ( name: " ModuleName.symbols.json " , content: makeSymbolGraph ( moduleName: " ModuleName " ) ) ,
1326+
1327+ InfoPlist ( displayName: " ModuleNaem " ) , // The bundle name is intentionally misspelled.
1328+
1329+ // The symbol link in the header is intentionally misspelled.
1330+ TextFile ( name: " root.md " , utf8Content: """
1331+ # ``ModuleNaem``
1332+
1333+ A documentation extension file with a misspelled link that happens to match the, also misspelled, bundle name.
1334+ """ ) ,
1335+ ] )
1336+ let catalogURL = try exampleDocumentation. write ( inside: createTemporaryDirectory ( ) )
1337+ let ( _, _, context) = try loadBundle ( from: catalogURL)
1338+ let tree = context. linkResolver. localResolver. pathHierarchy
1339+
1340+ // This link is intentionally misspelled
1341+ try assertPathRaisesErrorMessage ( " ModuleNaem " , in: tree, context: context, expectedErrorMessage: " Can't resolve 'ModuleNaem' " ) { errorInfo in
1342+ XCTAssertEqual ( errorInfo. solutions. map ( \. summary) , [ " Replace 'ModuleNaem' with 'ModuleName' " ] )
1343+ }
1344+
1345+ let linkProblem = try XCTUnwrap ( context. problems. first ( where: { $0. diagnostic. summary == " No symbol matched 'ModuleNaem'. Can't resolve 'ModuleNaem'. " } ) )
1346+ XCTAssertEqual ( linkProblem. possibleSolutions. map ( \. summary) , [ " Replace 'ModuleNaem' with 'ModuleName' " ] )
1347+ }
1348+
13231349 func testSymbolsWithSameNameAsModule( ) throws {
13241350 let ( _, context) = try testBundleAndContext ( named: " SymbolsWithSameNameAsModule " )
13251351 let tree = context. linkResolver. localResolver. pathHierarchy
0 commit comments