-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat testing #72
Feat testing #72
Conversation
…guration, core, QuickPick, and ripgrep functionalities - Add new dependencies: mock-fs, sinon, and their respective type definitions - Introduce unit tests for configuration, core functionalities, QuickPick UI, and ripgrep integration - Ensure all tests utilize sinon for sandboxing and assertions
…alities - Add comprehensive unit tests for command registration during extension activation. - Implement mocks for extension context, QuickPick, and command execution to validate behavior. - Verify the correct registration of commands and their addition to subscriptions. - Test search operation and horizontal split functionality with appropriate assertions. - Utilize sinon for stubbing and sandboxing to ensure isolated test cases. chore: cleanup tests
- Introduced mocks for vscode.QuickPick and context to isolate tests. - Added tests for formatting search results from ripgrep and verifying QuickPick item properties. - Implemented preview functionality tests to ensure correct document opening and cursor positioning. - Validated menu action handling with appropriate assertions and event emitter usage.
…Query - Enhanced the regex matching logic to handle optional spaces and improve parameter extraction. - Updated the test suite to include dedicated tests for various query scenarios, ensuring robust coverage for flag handling. - Skipped a test for glob pattern extraction due to pending fixes, while validating existing functionality for type flags and query parsing.
- Replaced skipped test for glob pattern handling with an active test case. - Updated regex and parameter extraction logic to correctly handle glob patterns. - Enhanced assertions to validate the extraction of ripgrep flags for glob patterns, ensuring robust test coverage.
- Refactored QuickPick test setup to use stubs for event handlers, improving isolation and control during tests. - Added a new test case to validate the integration of native search functionality within QuickPick. - Mocked VSCode commands and configuration to simulate user interactions and verify correct command execution. - Ensured that the QuickPick UI behaves as expected when handling search queries, including hiding the QuickPick after execution. - Enhanced logging for better traceability of command calls and search parameters during tests.
- Implemented a new test case to validate the handling of menu actions within the QuickPick UI. - Mocked configuration to include custom menu actions and verified the correct setup of QuickPick properties. - Added assertions to ensure multiple selections are allowed and that the correct menu items are created. - Tested the selection handling and confirmed that selected actions are stored appropriately after user interaction. - Ensured QuickPick resets correctly for query input after an action is accepted.
- Implemented a new test case to verify the behavior of QuickPick when no matches are found. - Mocked configuration to control the visibility of previous results based on user settings. - Added assertions to ensure previous results are retained or cleared correctly depending on the configuration. - Verified that the origin document is shown when no results are found and previous results are not displayed.
- Implemented a new test case to verify the behavior of QuickPick when a search result is selected. - Mocked necessary VSCode components, including documents and editors, to simulate user interactions. - Added assertions to ensure the correct document is opened and displayed, with the cursor positioned accurately. - Verified that the QuickPick is disposed of correctly after a selection is made, ensuring proper cleanup.
- Introduced a new test suite for the formatPathLabel function to validate its behavior with various path formats and configurations. - Implemented tests for handling workspace folder visibility, path abbreviation based on depth settings, and edge cases such as empty paths and special characters. - Mocked necessary VSCode components and configuration to simulate different workspace scenarios and ensure accurate assertions. - Enhanced coverage for both standard and edge case path formatting, ensuring robustness of the utility function.
- Changed the test for handling root paths from skipped to active, ensuring it is now executed. - Updated the expected output for the root path test to reflect the correct formatting as 'workspace/../..'. - This enhancement improves test coverage and validates the behavior of the formatPathLabel function for root paths.
- Introduced new test cases to cover various edge scenarios for the formatPathLabel function, including handling zero, negative, and excessive display depths. - Added tests for mixed and consecutive path separators, as well as complex path cases involving parent traversal and unicode characters. - Enhanced overall test coverage and robustness of the formatPathLabel utility by validating its behavior across a wider range of path formats.
- Introduced a new test case to validate the formatting of QuickPick items using the createResultItem utility. - Added assertions to check the correct handling of various scenarios, including basic item formatting, empty content, special characters, and long content. - Enhanced test coverage for QuickPick UI, ensuring robust validation of item properties such as type, label, file path, and button tooltips.
- Add test case for basic preview content generation - Mock document and workspace for preview testing - Verify document opening and content display - Handle URI path resolution for cross-platform compatibility
- Add test case for multi-line TypeScript content - Verify correct line number handling - Test context lines availability - Validate language identification for syntax highlighting
- Add test case for scrolling large content - Verify visible range updates - Test context lines visibility - Mock editor scrolling behavior
- Deleted the configuration test suite for validating default and custom settings. - This cleanup improves code maintainability by removing outdated tests that are no longer relevant.
… and assertions - Refactored mockQuickPick to include all required properties for better test accuracy. - Updated test cases to ensure proper handling of QuickPick item selections and navigation. - Added assertions to verify the correct behavior of QuickPick when no results are found and when handling previous results. - Improved overall test coverage for QuickPick UI functionality, ensuring robust validation of user interactions and expected outcomes.
- Set environment variables for testing in runTest.ts and index.ts to ensure consistent test conditions. - Modify log.ts to suppress console logging in test mode while still displaying error messages, improving test output clarity. - These changes enhance the testing framework's reliability and maintainability.
- Introduced a new testing workflow in `test.yml` to run tests across multiple OS environments (macOS, Ubuntu, Windows) with Node.js. - Configured the `semantic-release` job in `publish-vscode-extension.yml` to depend on the test job, ensuring that tests must pass before a release is made. - This enhancement improves the CI/CD pipeline by integrating automated testing into the release process, increasing code reliability.
- Refactored existing tests to enhance clarity and specificity in naming. - Added tests for handling single workspace folders, no workspace folders, and toggling workspace folder visibility in file paths. - Improved assertions for paths outside workspace folders and multiple workspace folders, ensuring accurate behavior of the formatPathLabel function. - These changes enhance the robustness and maintainability of the test suite for path formatting functionality.
…pendent utilities - Introduced helper functions to create platform-independent workspace paths and expected paths, improving test clarity and maintainability. - Updated existing tests to utilize these helpers, ensuring consistent path formatting across different operating systems. - Enhanced assertions for various scenarios, including single and multiple workspace folders, path abbreviation, and edge cases with special characters and unicode. - These changes improve the robustness of the test suite for the formatPathLabel function, ensuring accurate behavior across diverse environments.
✅ Tests passed on macos-latest |
✅ Tests passed on ubuntu-latest |
- Modified .prettierrc to enforce LF line endings and reduced print width to 100 for better readability. - Updated package.json to streamline pretest command and added lint:fix command for automatic code formatting. - Enhanced GitHub Actions workflow to format code before running tests, ensuring consistent code style. - Refactored various TypeScript files to improve code formatting and readability, including consistent line breaks and indentation. - Improved test cases for formatPathLabel and other functionalities to enhance clarity and maintainability. These changes collectively enhance code quality, maintainability, and consistency across the project.
✅ Tests passed on macos-latest |
✅ Tests passed on ubuntu-latest |
1 similar comment
✅ Tests passed on ubuntu-latest |
✅ Tests passed on macos-latest |
✅ Tests passed on ubuntu-latest |
✅ Tests passed on macos-latest |
- Added a helper function to normalize path separators for consistent comparison in tests. - Updated existing tests to utilize the normalization function, ensuring accurate assertions across different platforms. - Refactored tests to improve clarity and maintainability, particularly for edge cases involving path formatting. - These changes enhance the robustness of the test suite for the formatPathLabel function, ensuring reliable behavior across diverse environments.
✅ Tests passed on macos-latest |
✅ Tests passed on ubuntu-latest |
✅ Tests passed on windows-latest |
- Introduced a new utility function `resolveRipgrepPath` to centralize the logic for resolving the ripgrep binary path from user-specified paths, system PATH, and the bundled vscode ripgrep. - Removed redundant path resolution logic from `getConfig` and integrated it into the new utility. - Added comprehensive tests for the new path resolution logic, covering scenarios for valid user paths, invalid paths, and platform-specific handling (including Windows). - Created a new test suite for `ripgrepPath` to ensure robust testing of path resolution functionality. - Enhanced error handling and logging for cases where ripgrep is not found, improving user feedback. These changes improve code organization, maintainability, and the reliability of the ripgrep integration within the project.
- Updated package.json to reflect the correct usage of the @vscode/ripgrep package in the description for the rgPath configuration. - Refactored the checkAndExtractRgFlagsFromQuery function to streamline the extraction of additional ripgrep flags from the query, improving clarity and efficiency. - Enhanced the getConfig function to resolve the ripgrep path only once during initialization, reducing blocking operations. - Improved logging messages for better clarity when user-specified ripgrep paths are not found. These changes enhance the overall functionality and user experience of the ripgrep integration within the project.
✅ Tests passed on macos-latest |
✅ Tests passed on ubuntu-latest |
✅ Tests passed on windows-latest |
…ope tests - Deleted the obsolete `extension.test.ts` file as it was no longer needed. - Refactored the `periscope.test.ts` file to improve mock context setup, enhancing clarity and maintainability. - Updated assertions to use the new mock context, ensuring consistency in test behavior. - Marked incomplete tests in `quickPick.test.ts` and `ripgrep.test.ts` with TODO comments for future attention. These changes improve the organization and clarity of the test suite, ensuring a more efficient testing process.
…overage - Removed obsolete test cases and streamlined the ripgrep test suite for clarity and maintainability. - Added comprehensive tests for the `resolveRipgrepPath` function, covering scenarios for valid and invalid user paths, platform-specific handling, and error notifications. - Improved mock setups to ensure accurate testing of path resolution logic, including handling of empty and whitespace paths. - Enhanced error handling to provide clearer feedback when ripgrep is not found, improving user experience. These changes improve the organization and robustness of the ripgrep integration tests, ensuring reliable functionality across different scenarios.
…ndling - Updated the QuickPick test suite to properly format search results from ripgrep, ensuring accurate item creation in the QuickPick UI. - Introduced event emitters to simulate process output and exit events, improving the reliability of the tests. - Refactored assertions to validate the formatted QuickPick items, including checks for labels, descriptions, and additional properties. - Marked previously incomplete tests as complete, enhancing the overall test coverage for the QuickPick functionality. These changes improve the robustness and clarity of the QuickPick UI tests, ensuring reliable behavior when processing search results.
…andling - Refactored the QuickPick test suite to improve the structure and clarity of the tests. - Introduced a helper function to create mock processes, enhancing the simulation of stdout and stderr events. - Streamlined the setup of event emitters and context configuration for better readability. - Updated assertions to ensure accurate validation of formatted QuickPick items, including checks for labels, file paths, and additional properties. - Improved the overall reliability of the tests by ensuring proper handling of asynchronous operations. These changes enhance the maintainability and robustness of the QuickPick UI tests, ensuring reliable behavior when processing search results.
✅ Tests passed on ubuntu-latest |
✅ Tests passed on macos-latest |
✅ Tests passed on windows-latest |
🎉 This PR is included in version 1.9.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This pull request includes several changes to improve the testing workflow, update dependencies, and refactor code for better readability and performance. The most important changes include the addition of a new test workflow, updates to the ESLint configuration, and various code refactorings.
Testing Workflow Enhancements:
.github/workflows/publish-vscode-extension.yml
: Added a dependency on the new test job to ensure tests pass before release..github/workflows/test.yml
: Created a new test workflow to run tests on multiple operating systems and report the status on pull requests.ESLint Configuration Updates:
.eslintrc.json
: Updated the ESLint configuration to useecmaVersion
6 andsourceType
module, and added specific naming conventions and rules for TypeScript.Dependency Updates:
package.json
: Added new dependencies for@types/mock-fs
,@types/sinon
,mock-fs
, andsinon
. [1] [2]Code Refactoring:
src/lib/editorActions.ts
: RefactoredopenInHorizontalSplit
to use async/await for better readability and performance. [1] [2]src/lib/ripgrep.ts
: Simplified theripgrepPath
function and improved thecheckAndExtractRgFlagsFromQuery
function for better maintainability. [1] [2] [3] [4]Test Improvements:
src/test/runTest.ts
: Set environment variables for testing to ensure consistent test environments.src/test/suite/formatPathLabel.test.ts
: Added comprehensive tests for theformatPathLabel
function to cover various edge cases and configurations.src/test/suite/index.ts
: Set test environment variables to ensure consistent test environments.