-
Notifications
You must be signed in to change notification settings - Fork 59
[BI]Add support to display test cases for workspace projects #957
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
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. ✨ Finishing touches🧪 Generate unit tests (beta)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for displaying and running test cases in workspace projects (workspaces containing multiple Ballerina projects). The implementation differentiates between single-project and multi-project workspace scenarios.
Key changes:
- Test discovery now handles workspace projects with multiple child projects
- Test hierarchy includes project-level grouping for workspace contexts
- Test execution commands are constructed differently for workspace vs single project scenarios
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 12 comments.
| File | Description |
|---|---|
| runner.ts | Adds logic to extract project paths from test items, determine workspace context, construct appropriate test commands for workspace/single projects, and locate test results in the correct directory |
| discover.ts | Implements workspace-aware test discovery, creates project-level test groups for workspaces, and handles file changes/deletions across multiple projects |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
workspaces/ballerina/ballerina-extension/src/features/test-explorer/discover.ts
Show resolved
Hide resolved
| if (isTestFunctionItem(test)) { | ||
| // Extract from test ID: test:${projectPath}:${fileName}:${functionName} | ||
| const parts = test.id.split(':'); | ||
| if (parts.length >= 2) { |
Copilot
AI
Nov 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test ID parsing assumes a specific format but doesn't validate that parts[0] is 'test'. If the ID format changes or is malformed, this could return incorrect data. Consider adding validation: if (parts[0] === 'test' && parts.length >= 2) to ensure the ID follows the expected format.
| if (parts.length >= 2) { | |
| if (parts.length >= 2 && parts[0] === 'test') { |
workspaces/ballerina/ballerina-extension/src/features/test-explorer/runner.ts
Show resolved
Hide resolved
workspaces/ballerina/ballerina-extension/src/features/test-explorer/discover.ts
Show resolved
Hide resolved
| const workingDirectory = projectName ? StateMachine.context().workspacePath || projectPath : projectPath; | ||
| runCommand(command, workingDirectory).then(() => { | ||
| const endTime = Date.now(); | ||
| const timeElapsed = testItems.length > 0 ? (endTime - startTime) / testItems.length : (endTime - startTime); |
Copilot
AI
Nov 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The time elapsed calculation logic is duplicated multiple times throughout the file. Extract this into a helper function like calculateTimeElapsed(startTime: number, endTime: number, testItems: TestItem[]): number to reduce duplication and improve maintainability.
| const EndTime = Date.now(); | ||
| const timeElapsed = (EndTime - startTime) / testItems.length; | ||
| const endTime = Date.now(); | ||
| const timeElapsed = (endTime - startTime) / testItems.length; |
Copilot
AI
Nov 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The time elapsed calculation logic is duplicated multiple times throughout the file. Extract this into a helper function like calculateTimeElapsed(startTime: number, endTime: number, testItems: TestItem[]): number to reduce duplication and improve maintainability.
| const workingDirectory = projectName ? StateMachine.context().workspacePath || projectPath : projectPath; | ||
| runCommand(command, workingDirectory).then(() => { | ||
| const endTime = Date.now(); | ||
| const timeElapsed = (endTime - startTime) / testItems.length; |
Copilot
AI
Nov 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The time elapsed calculation logic is duplicated multiple times throughout the file. Extract this into a helper function like calculateTimeElapsed(startTime: number, endTime: number, testItems: TestItem[]): number to reduce duplication and improve maintainability.
| const EndTime = Date.now(); | ||
| const timeElapsed = (EndTime - startTime) / testItems.length; | ||
| const endTime = Date.now(); | ||
| const timeElapsed = (endTime - startTime) / testItems.length; |
Copilot
AI
Nov 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The time elapsed calculation logic is duplicated multiple times throughout the file. Extract this into a helper function like calculateTimeElapsed(startTime: number, endTime: number, testItems: TestItem[]): number to reduce duplication and improve maintainability.
workspaces/ballerina/ballerina-extension/src/features/test-explorer/discover.ts
Show resolved
Hide resolved
workspaces/ballerina/ballerina-extension/src/features/test-explorer/runner.ts
Show resolved
Hide resolved
| function getProjectPathFromTestItem(test: TestItem): string | undefined { | ||
| if (isTestFunctionItem(test)) { | ||
| // Extract from test ID: test:${projectPath}:${fileName}:${functionName} | ||
| const parts = test.id.split(':'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if projectPath is absolute path, this logic will break on Windows.
on Windows project path contains : (colons) (e.g., C:\Users\...\project), which breaks the parsing logic in getProjectPathFromTestItem() and belongsToFile().
Change the separator to something that won't conflict with file paths, such as | (pipe): test|${projectPath}|${fileName}|${functionName}.
|
Merging this PR due to priority. @samithkavishke Let’s handle this issue as a separate issue. |
Purpose
Fixes: wso2/product-ballerina-integrator#1942
Goals
Approach
UI Component Development
npm run storybookfrom the root directory to view current components.Manage Icons
User stories
Release note
Documentation
Training
Certification
Marketing
Automation tests
Security checks
Samples
Related PRs
Migrations (if applicable)
Test environment
Learning