fix: improve testing and CLI command implementation
- Fix tests using ES Module best practices instead of complex mocking - Replace Commander.js mocking with direct action handler testing - Resolve ES Module import/mock issues and function redeclaration errors - Fix circular reference issues with console.log spies - Properly setup mock functions with jest.fn() for method access - Improve parse-prd command functionality - Add default PRD path support (scripts/prd.txt) so you can just run `task-master parse-prd` and it will use the default PRD if it exists. - Improve error handling and user feedback - Enhance help text with more detailed information - Fix detectCamelCaseFlags implementation in utils.js yet again with more tests this time - Improve regex pattern to correctly detect camelCase flags - Skip flags already in kebab-case format - Enhance tests with proper test-specific implementations - Document testing best practices - Add comprehensive "Common Testing Pitfalls and Solutions" section to tests.mdc - Provide clear examples of correct testing patterns for ES modules - Document techniques for test isolation and mock organization
This commit is contained in:
40
tasks/task_030.txt
Normal file
40
tasks/task_030.txt
Normal file
@@ -0,0 +1,40 @@
|
||||
# Task ID: 30
|
||||
# Title: Enhance parse-prd Command to Support Default PRD Path
|
||||
# Status: pending
|
||||
# Dependencies: None
|
||||
# Priority: medium
|
||||
# Description: Modify the parse-prd command to automatically use a default PRD path when no path is explicitly provided, improving user experience by reducing the need for manual path specification.
|
||||
# Details:
|
||||
Currently, the parse-prd command requires users to explicitly specify the path to the PRD document. This enhancement should:
|
||||
|
||||
1. Implement a default PRD path configuration that can be set in the application settings or configuration file.
|
||||
2. Update the parse-prd command to check for this default path when no path argument is provided.
|
||||
3. Add a configuration option that allows users to set/update the default PRD path through a command like `config set default-prd-path <path>`.
|
||||
4. Ensure backward compatibility by maintaining support for explicit path specification.
|
||||
5. Add appropriate error handling for cases where the default path is not set or the file doesn't exist.
|
||||
6. Update the command's help text to indicate that a default path will be used if none is specified.
|
||||
7. Consider implementing path validation to ensure the default path points to a valid PRD document.
|
||||
8. If multiple PRD formats are supported (Markdown, PDF, etc.), ensure the default path handling works with all supported formats.
|
||||
9. Add logging for default path usage to help with debugging and usage analytics.
|
||||
|
||||
# Test Strategy:
|
||||
1. Unit tests:
|
||||
- Test that the command correctly uses the default path when no path is provided
|
||||
- Test that explicit paths override the default path
|
||||
- Test error handling when default path is not set
|
||||
- Test error handling when default path is set but file doesn't exist
|
||||
|
||||
2. Integration tests:
|
||||
- Test the full workflow of setting a default path and then using the parse-prd command without arguments
|
||||
- Test with various file formats if multiple are supported
|
||||
|
||||
3. Manual testing:
|
||||
- Verify the command works in a real environment with actual PRD documents
|
||||
- Test the user experience of setting and using default paths
|
||||
- Verify help text correctly explains the default path behavior
|
||||
|
||||
4. Edge cases to test:
|
||||
- Relative vs. absolute paths for default path setting
|
||||
- Path with special characters or spaces
|
||||
- Very long paths approaching system limits
|
||||
- Permissions issues with the default path location
|
||||
@@ -1631,6 +1631,26 @@
|
||||
"priority": "medium",
|
||||
"details": "The task involves updating the Claude 3.7 Sonnet integration in the ai-services.js file to take advantage of the new 128k token output capability. Specifically:\n\n1. Locate the Claude 3.7 Sonnet API request configuration in ai-services.js\n2. Add the beta header 'output-128k-2025-02-19' to the request headers\n3. Update any related configuration parameters that might need adjustment for the increased token limit\n4. Ensure that token counting and management logic is updated to account for the new 128k token output limit\n5. Update any documentation comments in the code to reflect the new capability\n6. Consider implementing a configuration option to enable/disable this feature, as it may be a beta feature subject to change\n7. Verify that the token management logic correctly handles the increased limit without causing unexpected behavior\n8. Ensure backward compatibility with existing code that might assume lower token limits\n\nThe implementation should be clean and maintainable, with appropriate error handling for cases where the beta header might not be supported in the future.",
|
||||
"testStrategy": "Testing should verify that the beta header is correctly included and that the system properly handles the increased token limit:\n\n1. Unit test: Verify that the API request to Claude 3.7 Sonnet includes the 'output-128k-2025-02-19' header\n2. Integration test: Make an actual API call to Claude 3.7 Sonnet with the beta header and confirm a successful response\n3. Test with a prompt designed to generate a very large response (>20k tokens but <128k tokens) and verify it completes successfully\n4. Test the token counting logic with mock responses of various sizes to ensure it correctly handles responses approaching the 128k limit\n5. Verify error handling by simulating API errors related to the beta header\n6. Test any configuration options for enabling/disabling the feature\n7. Performance test: Measure any impact on response time or system resources when handling very large responses\n8. Regression test: Ensure existing functionality using Claude 3.7 Sonnet continues to work as expected\n\nDocument all test results, including any limitations or edge cases discovered during testing."
|
||||
},
|
||||
{
|
||||
"id": 30,
|
||||
"title": "Enhance parse-prd Command to Support Default PRD Path",
|
||||
"description": "Modify the parse-prd command to automatically use a default PRD path when no path is explicitly provided, improving user experience by reducing the need for manual path specification.",
|
||||
"status": "pending",
|
||||
"dependencies": [],
|
||||
"priority": "medium",
|
||||
"details": "Currently, the parse-prd command requires users to explicitly specify the path to the PRD document. This enhancement should:\n\n1. Implement a default PRD path configuration that can be set in the application settings or configuration file.\n2. Update the parse-prd command to check for this default path when no path argument is provided.\n3. Add a configuration option that allows users to set/update the default PRD path through a command like `config set default-prd-path <path>`.\n4. Ensure backward compatibility by maintaining support for explicit path specification.\n5. Add appropriate error handling for cases where the default path is not set or the file doesn't exist.\n6. Update the command's help text to indicate that a default path will be used if none is specified.\n7. Consider implementing path validation to ensure the default path points to a valid PRD document.\n8. If multiple PRD formats are supported (Markdown, PDF, etc.), ensure the default path handling works with all supported formats.\n9. Add logging for default path usage to help with debugging and usage analytics.",
|
||||
"testStrategy": "1. Unit tests:\n - Test that the command correctly uses the default path when no path is provided\n - Test that explicit paths override the default path\n - Test error handling when default path is not set\n - Test error handling when default path is set but file doesn't exist\n\n2. Integration tests:\n - Test the full workflow of setting a default path and then using the parse-prd command without arguments\n - Test with various file formats if multiple are supported\n\n3. Manual testing:\n - Verify the command works in a real environment with actual PRD documents\n - Test the user experience of setting and using default paths\n - Verify help text correctly explains the default path behavior\n\n4. Edge cases to test:\n - Relative vs. absolute paths for default path setting\n - Path with special characters or spaces\n - Very long paths approaching system limits\n - Permissions issues with the default path location"
|
||||
},
|
||||
{
|
||||
"id": 31,
|
||||
"title": "Add Config Flag Support to task-master init Command",
|
||||
"description": "Enhance the 'task-master init' command to accept configuration flags that allow users to bypass the interactive CLI questions and directly provide configuration values.",
|
||||
"status": "pending",
|
||||
"dependencies": [],
|
||||
"priority": "low",
|
||||
"details": "Currently, the 'task-master init' command prompts users with a series of questions to set up the configuration. This task involves modifying the init command to accept command-line flags that can pre-populate these configuration values, allowing for a non-interactive setup process.\n\nImplementation steps:\n1. Identify all configuration options that are currently collected through CLI prompts during initialization\n2. Create corresponding command-line flags for each configuration option (e.g., --project-name, --ai-provider, etc.)\n3. Modify the init command handler to check for these flags before starting the interactive prompts\n4. If a flag is provided, skip the corresponding prompt and use the provided value instead\n5. If all required configuration values are provided via flags, skip the interactive process entirely\n6. Update the command's help text to document all available flags and their usage\n7. Ensure backward compatibility so the command still works with the interactive approach when no flags are provided\n8. Consider adding a --non-interactive flag that will fail if any required configuration is missing rather than prompting for it (useful for scripts and CI/CD)\n\nThe implementation should follow the existing command structure and use the same configuration file format. Make sure to validate flag values with the same validation logic used for interactive inputs.",
|
||||
"testStrategy": "Testing should verify both the interactive and non-interactive paths work correctly:\n\n1. Unit tests:\n - Test each flag individually to ensure it correctly overrides the corresponding prompt\n - Test combinations of flags to ensure they work together properly\n - Test validation of flag values to ensure invalid values are rejected\n - Test the --non-interactive flag to ensure it fails when required values are missing\n\n2. Integration tests:\n - Test a complete initialization with all flags provided\n - Test partial initialization with some flags and some interactive prompts\n - Test initialization with no flags (fully interactive)\n\n3. Manual testing scenarios:\n - Run 'task-master init --project-name=\"Test Project\" --ai-provider=\"openai\"' and verify it skips those prompts\n - Run 'task-master init --help' and verify all flags are documented\n - Run 'task-master init --non-interactive' without required flags and verify it fails with a helpful error message\n - Run a complete non-interactive initialization and verify the resulting configuration file matches expectations\n\nEnsure the command's documentation is updated to reflect the new functionality, and verify that the help text accurately describes all available options."
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user