test: add TypeScript plugin and teacher contract test coverage#495
Draft
madara88645 wants to merge 1 commit into
Draft
test: add TypeScript plugin and teacher contract test coverage#495madara88645 wants to merge 1 commit into
madara88645 wants to merge 1 commit into
Conversation
…t normalization Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes two test gaps found in a prior audit — both files were pure logic with no dedicated test coverage:
analyst/languages/typescript.py(TypeScriptAnalyzer, tree-sitter-based TS/TSX parsing) had no test file, even though its siblingsanalyst/languages/javascript.pyandanalyst/languages/python.pyare both covered bytests/languages/test_javascript.pyandtests/languages/test_python.py.teacher/contract.py(~383 lines of prompt/response normalization helpers:clip_text,_normalize_contract_sections,normalize_chat_text,normalize_explain_payload,normalize_ghost_payload,normalize_learning_steps,extract_node_ids_from_summary,build_*_prompt) had notests/test_contract.py— it was only reachable indirectly through mocked tests ofteacher/openrouter_teacher.py.Changes
tests/languages/test_typescript.py(new, 10 tests inTestTypeScriptAnalyzer, mirrors thetest_python.pytempdir-fixture convention):test_function_and_class_declarations,test_arrow_function_export,test_interface_and_type_alias_do_not_create_nodes— basic TS parsingtest_tsx_jsx_syntax_parses— TSX/JSX supporttest_nestjs_route_decorators_mark_api_boundary,test_non_route_decorator_does_not_mark_api_boundary— decorator-basedapi_boundarydetectiontest_import_type_only_is_stripped— TS-specificimport typestrippingtest_empty_file_returns_valid_analysis,test_malformed_syntax_does_not_crash,test_unreadable_file_returns_none— edge casesBug found while writing tests (not fixed here, documented in the test with a detailed comment):
_TypeScriptWalker._collect_decoratorsintypescript.pyfinds a node's siblings viachild is node(identity comparison). tree-sitter's Python bindings return a newNodewrapper object on every.children/.parentaccess, so this identity check never matches in practice — decorators are never collected, andapi_boundaryis neverTruefor NestJS/Angular-decorated methods today, despite the module docstring's stated intent.test_nestjs_route_decorators_mark_api_boundaryasserts the actual (currently-false) behavior and explains the root cause inline; a follow-up fix would likely switch the comparison tochild.id == node.id.tests/test_contract.py(new, 54 tests, pytest-class style matchingtests/test_openrouter_teacher.py's conventions):TestClipText— truncation at/under/over the limit, empty/whitespace fallback, custom fallbackTestNormalizeContractSections— well-formed input, missingsectionskey, wrong-typedsections/unknowns, non-string values rendered as markdown, References fallbackTestRenderContractText,TestNormalizeChatText— JSON vs. text-extraction paths (including the same-line-header-content-is-dropped nuance)TestNormalizeExplainPayload,TestNormalizeGhostPayload— valid/missing/wrong-typed payload keys, importance allow-list normalizationTestNormalizeLearningSteps— valid payload, wrong types, missing/duplicate node ids, allowed-list filtering, step renumberingTestExtractNodeIdsFromSummary— ids present/absent/mixedTestTeacherReferencesRender,TestBudgetsAreDefinedForEverySection— supporting dataclass/constantsTesting
python -m pytest tests/ -v) — 420 passed (356 baseline + 64 new)python -m pytest tests/languages/test_typescript.py tests/test_contract.py -v— 64 passedChecklist
ruff check . --select E,F --ignore E501,E402)Only the two new test files are touched; no source, config, CI, or lockfile changes.
Generated by Claude Code