-
Notifications
You must be signed in to change notification settings - Fork 0
Add shopping_app with integration tests for cart functionality #3
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
Draft
jpelletier1
wants to merge
4
commits into
main
Choose a base branch
from
add-shopping-cart-integration-tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d854ad1
Add shopping_app with integration tests for cart functionality
openhands-agent 267e400
Add test browser viewer with microagent
openhands-agent c1f2443
Add comprehensive documentation for shopping cart integration tests
openhands-agent fb59289
Add pricing page with three tiers, FAQ section, and navigation
openhands-agent File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,209 @@ | ||
| --- | ||
| name: test_runner | ||
| type: knowledge | ||
| version: 1.0.0 | ||
| agent: CodeActAgent | ||
| triggers: | ||
| - run tests | ||
| - run the tests | ||
| - show test results | ||
| - test results in browser | ||
| - display test results | ||
| --- | ||
|
|
||
| # Test Runner Microagent | ||
|
|
||
| This microagent helps run integration tests for the shopping_app and display the results in a browser-friendly HTML format. | ||
|
|
||
| ## Capabilities | ||
|
|
||
| When triggered, this microagent will: | ||
|
|
||
| 1. Run the Jest integration tests for shopping_app | ||
| 2. Generate an HTML report of the test results | ||
| 3. Serve the report on an available port for viewing in the OpenHands browser | ||
| 4. Provide the URL to view the results | ||
|
|
||
| ## Implementation Steps | ||
|
|
||
| ### 1. Run Tests and Capture Output | ||
|
|
||
| Navigate to the shopping_app directory and run tests with verbose output: | ||
|
|
||
| ```bash | ||
| cd /workspace/project/openhands-demos/shopping_app | ||
| npm test -- --verbose --json --outputFile=test-results.json 2>&1 | tee test-output.txt | ||
| ``` | ||
|
|
||
| ### 2. Generate HTML Report | ||
|
|
||
| Create an HTML file that displays the test results in a user-friendly format: | ||
|
|
||
| ```html | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8"> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
| <title>Shopping Cart Test Results</title> | ||
| <style> | ||
| body { | ||
| font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif; | ||
| max-width: 1200px; | ||
| margin: 0 auto; | ||
| padding: 20px; | ||
| background-color: #f5f5f5; | ||
| } | ||
| .header { | ||
| background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); | ||
| color: white; | ||
| padding: 30px; | ||
| border-radius: 10px; | ||
| margin-bottom: 20px; | ||
| box-shadow: 0 4px 6px rgba(0,0,0,0.1); | ||
| } | ||
| .summary { | ||
| display: grid; | ||
| grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); | ||
| gap: 15px; | ||
| margin-bottom: 30px; | ||
| } | ||
| .summary-card { | ||
| background: white; | ||
| padding: 20px; | ||
| border-radius: 8px; | ||
| box-shadow: 0 2px 4px rgba(0,0,0,0.1); | ||
| } | ||
| .summary-card h3 { | ||
| margin: 0 0 10px 0; | ||
| font-size: 14px; | ||
| color: #666; | ||
| text-transform: uppercase; | ||
| } | ||
| .summary-card .value { | ||
| font-size: 32px; | ||
| font-weight: bold; | ||
| color: #333; | ||
| } | ||
| .test-results { | ||
| background: white; | ||
| border-radius: 8px; | ||
| box-shadow: 0 2px 4px rgba(0,0,0,0.1); | ||
| overflow: hidden; | ||
| } | ||
| .test-item { | ||
| padding: 20px; | ||
| border-bottom: 1px solid #eee; | ||
| } | ||
| .test-item:last-child { | ||
| border-bottom: none; | ||
| } | ||
| .test-item.passed { | ||
| border-left: 4px solid #22c55e; | ||
| } | ||
| .test-item.failed { | ||
| border-left: 4px solid #ef4444; | ||
| } | ||
| .test-name { | ||
| font-weight: 600; | ||
| font-size: 16px; | ||
| margin-bottom: 5px; | ||
| } | ||
| .test-status { | ||
| display: inline-block; | ||
| padding: 4px 12px; | ||
| border-radius: 20px; | ||
| font-size: 12px; | ||
| font-weight: 600; | ||
| margin-left: 10px; | ||
| } | ||
| .status-passed { | ||
| background-color: #dcfce7; | ||
| color: #166534; | ||
| } | ||
| .status-failed { | ||
| background-color: #fee2e2; | ||
| color: #991b1b; | ||
| } | ||
| .test-duration { | ||
| color: #666; | ||
| font-size: 14px; | ||
| } | ||
| .pass-rate { | ||
| color: #22c55e; | ||
| } | ||
| .fail-rate { | ||
| color: #ef4444; | ||
| } | ||
| </style> | ||
| </head> | ||
| <body> | ||
| <div class="header"> | ||
| <h1>Shopping Cart Integration Test Results</h1> | ||
| <p>Comprehensive test suite for cart functionality</p> | ||
| </div> | ||
|
|
||
| <div class="summary"> | ||
| <!-- Summary cards will be populated here --> | ||
| </div> | ||
|
|
||
| <div class="test-results"> | ||
| <!-- Test results will be populated here --> | ||
| </div> | ||
|
|
||
| <script> | ||
| // Parse and display test results from JSON or text output | ||
| </script> | ||
| </body> | ||
| </html> | ||
| ``` | ||
|
|
||
| ### 3. Parse Test Results | ||
|
|
||
| Parse the test output to extract: | ||
| - Total tests run | ||
| - Tests passed | ||
| - Tests failed | ||
| - Individual test names and statuses | ||
| - Test durations | ||
| - Overall test suite duration | ||
|
|
||
| ### 4. Serve the Report | ||
|
|
||
| Use a simple HTTP server to serve the HTML report: | ||
|
|
||
| ```bash | ||
| cd /workspace/project/openhands-demos/shopping_app | ||
| python3 -m http.server 12001 --directory . | ||
| ``` | ||
|
|
||
| ### 5. Provide the URL | ||
|
|
||
| Give the user the URL to view the test results: | ||
| - https://work-2-angmgpptuwafuigr.prod-runtime.all-hands.dev | ||
|
|
||
| ## Notes | ||
|
|
||
| - The server must be running on port 12000 for the tests to execute properly | ||
| - Tests should be run from the shopping_app directory | ||
| - If tests fail, the report should clearly indicate which tests failed and why | ||
| - The HTML report should be generated even if tests fail | ||
|
|
||
| ## Error Handling | ||
|
|
||
| If tests fail to run: | ||
| 1. Check if dependencies are installed (npm install) | ||
| 2. Verify the server is running on port 12000 | ||
| 3. Check for any missing test files or configuration issues | ||
|
|
||
| ## Example Usage | ||
|
|
||
| User: "Run the tests and show me the results in the browser" | ||
|
|
||
| Agent response: | ||
| 1. Navigate to shopping_app directory | ||
| 2. Run npm test with appropriate flags | ||
| 3. Parse the output | ||
| 4. Generate HTML report | ||
| 5. Start HTTP server | ||
| 6. Provide URL to user | ||
Oops, something went wrong.
Oops, something went wrong.
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.
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.
🔴 Critical: This hardcoded environment-specific URL was flagged in previous reviews but is still unresolved. This URL (
https://work-2-angmgpptuwafuigr.prod-runtime.all-hands.dev) will not work for other users or environments.Consider making this configurable or documenting that users need to replace this with their own runtime URL.