Files
adnify/tests/shared/languageSupportContract.test.ts
adnaan 4b45612831 feat: implement LSP text edits and agent symbol handling
- Add `textEdits.ts` for applying LSP text edits and collecting workspace edits.
- Introduce `AgentSymbol` interface in `types/index.ts` for agent-facing symbol descriptors.
- Create tests for `buildSubAgentExecutionSteps` to validate execution states and tool handling.
- Add tests for `parseSymbolToolResult` to ensure correct extraction of symbol paths and locations.
- Enhance document read tools tests to cover new LSP functionalities and symbol searching.
- Implement loop detection tests for semantic navigation and document reading.
- Establish integration tests for LSP bundled servers to verify symbol retrieval.
- Create tests for document ownership management in the main process.
- Add LSP protocol helper tests to validate JSON-RPC interactions.
- Implement server routing tests for LSP project configurations.
- Add tests for agent symbols to ensure correct symbol pathing and extraction.
- Validate language support contract for LSP routing and extensions.
- Create tests for LSP text edits to ensure correct application and error handling.
2026-08-24 18:06:20 +08:00

47 lines
1.7 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import {
EXTENSION_TO_LANGUAGE,
LSP_SERVER_DEFINITIONS,
LSP_SUPPORTED_LANGUAGES,
getLanguageFromPath,
getServerIdForLanguage,
isLspSupported,
} from '@shared/languages'
describe('LSP language support contract', () => {
it('routes every declared language to exactly one server', () => {
const declaredLanguages = LSP_SERVER_DEFINITIONS.flatMap(server => server.languages)
const serverIds = LSP_SERVER_DEFINITIONS.map(server => server.id)
expect(new Set(serverIds).size).toBe(serverIds.length)
expect(new Set(declaredLanguages).size).toBe(declaredLanguages.length)
expect(LSP_SUPPORTED_LANGUAGES).toEqual(declaredLanguages)
for (const languageId of declaredLanguages) {
expect(isLspSupported(languageId)).toBe(true)
expect(getServerIdForLanguage(languageId)).not.toBeNull()
}
})
it('has at least one file extension for every statically routed language', () => {
const extensionLanguages = new Set(Object.values(EXTENSION_TO_LANGUAGE))
for (const languageId of LSP_SUPPORTED_LANGUAGES) {
expect(extensionLanguages.has(languageId), `${languageId} has no file extension`).toBe(true)
}
})
it('keeps recognized-but-unsupported languages out of the LSP route', () => {
expect(getLanguageFromPath('build.gradle.kts')).toBe('kotlin')
expect(isLspSupported('kotlin')).toBe(false)
expect(getServerIdForLanguage('kotlin')).toBeNull()
})
it('keeps Deno project-scoped instead of claiming JavaScript extensions globally', () => {
const deno = LSP_SERVER_DEFINITIONS.find(server => server.id === 'deno')
expect(deno?.languages).toEqual([])
expect(getServerIdForLanguage('typescript')).toBe('typescript')
})
})