[docs-utils] 1️⃣ Add unit tests and improve stats#247700
Merged
clintandrewhall merged 8 commits intoelastic:mainfrom Jan 15, 2026
Merged
[docs-utils] 1️⃣ Add unit tests and improve stats#247700clintandrewhall merged 8 commits intoelastic:mainfrom
clintandrewhall merged 8 commits intoelastic:mainfrom
Conversation
Add comprehensive unit test coverage for kbn-docs-utils and enhance
API declarations with source location metadata.
API declaration improvements:
- Add lineNumber and columnNumber to ApiDeclaration type
- Add getSourceLocationForNode() utility for source positions
- Update buildBasicApiDeclaration to capture line/column info
Test infrastructure:
- Configure Jest coverage collection for src/**/*.{ts,tsx}
- Add stats snapshot generation alongside other test snapshots
- Add update_fixture_comments.js script for syncing expected
issues comments in fixture files
Fixture updates:
- Expand test fixtures with additional API patterns
- Add expected issues comments to fixture files
- Regenerate snapshot files with new metadata
Contributor
|
Pinging @elastic/kibana-operations (Team:Operations) |
Contributor
|
Pinging @elastic/appex-sharedux (Team:SharedUX) |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive unit test coverage for @kbn/docs-utils and enhances API declarations with source location metadata. The changes improve test coverage from 44% to 82% (10x increase in test count from 26 to 263 tests) and add lineNumber and columnNumber fields to ApiDeclaration for better navigation.
Key changes:
- Enhanced
ApiDeclarationtype with source position metadata - Added
getSourceLocationForNode()utility function - Comprehensive unit tests for core functionality
- Bug fixes in deprecation table generation (slice vs splice)
- Stats snapshot generation for validation
- Test fixture expansion with expected issues comments
- Jest coverage configuration improvements
Reviewed changes
Copilot reviewed 47 out of 47 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
packages/kbn-docs-utils/src/types.ts |
Added lineNumber and columnNumber optional fields to ApiDeclaration |
packages/kbn-docs-utils/src/build_api_declarations/utils.ts |
Added getSourceLocationForNode() utility to extract source positions |
packages/kbn-docs-utils/src/utils.test.ts |
Added 370+ lines of comprehensive unit tests |
packages/kbn-docs-utils/src/stats.test.ts |
Added 700 lines of stats collection tests |
packages/kbn-docs-utils/src/trim_deleted_docs_from_nav.test.ts |
Added nav trimming tests |
packages/kbn-docs-utils/src/mdx/*.test.ts |
Added extensive MDX generation tests |
packages/kbn-docs-utils/src/mdx/*_due_by_team.ts |
Fixed slice/splice bug in reference truncation |
packages/kbn-docs-utils/src/mdx/*_doc_by_plugin.ts |
Fixed slice/splice bug |
packages/kbn-docs-utils/src/mdx/build_plugin_deprecations_table.ts |
Fixed slice/splice bug and removed unused params |
packages/kbn-docs-utils/src/integration_tests/api_doc_suite.test.ts |
Added validation tests and stats snapshot generation |
packages/kbn-docs-utils/src/integration_tests/__fixtures__/**/*.ts |
Added expected issues comments to fixture files |
packages/kbn-docs-utils/src/integration_tests/snapshots/*.json |
Updated with lineNumber/columnNumber metadata |
packages/kbn-docs-utils/src/integration_tests/snapshots/*.mdx |
Updated date fields to 2025-12-31 |
packages/kbn-docs-utils/jest.integration.config.js |
Added coverage configuration |
| Various new test files | Added unit tests for find_plugins, get_paths_by_package, get_plugin_api_map, get_declaration_nodes_for_plugin |
tylersmalley
approved these changes
Jan 15, 2026
Contributor
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]
History
|
13 tasks
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
This PR adds comprehensive unit test coverage for kbn-docs-utils and enhance API declarations with source location metadata.
Note
This PR is a subset of #247688 for ease of review.
This PR was written with Cursor and
claude-4.5-opus-high.API declaration improvements
Test infrastructure
Fixture updates
Test Coverage Report
This PR adds comprehensive unit test coverage for
@kbn/docs-utilsand enhances API declarations with source location metadata.Coverage Comparison
Highlights
kbn-docs-utilssource filesFiles with 100% Line Coverage
src/stats.tssrc/trim_deleted_docs_from_nav.tssrc/get_paths_by_package.tssrc/get_plugin_api.tssrc/count_eslint_disable.tssrc/build_api_declarations/build_basic_api_declaration.tssrc/build_api_declarations/extract_import_refs.tssrc/build_api_declarations/js_doc_utils.tssrc/build_api_declarations/build_variable_dec.tssrc/build_api_declarations/build_call_signature_dec.tssrc/build_api_declarations/get_references.tssrc/mdx/build_plugin_deprecations_table.tssrc/mdx/get_all_doc_file_ids.tssrc/mdx/write_deprecations_doc_by_api.tssrc/mdx/write_deprecations_doc_by_plugin.tssrc/mdx/write_deprecations_due_by_team.tssrc/mdx/write_plugin_directory_doc.tsChanges Included
lineNumberandcolumnNumbertoApiDeclarationtypegetSourceLocationForNode()utilitysrc/**/*.{ts,tsx}src/__test_helpers__/