Skip to content

@observe command can now make test cases #2282

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dividedmind
Copy link
Collaborator

This pull request introduces enhancements to the observe-command and explain-command functionality, focusing on improved test case suggestions, handling of unclosed XML tags, and better flexibility in user options. It also includes utility additions and test coverage for new functionality.

Enhancements to observe-command:

  • Added logic to suggest a test case when no relevant test is found, with detailed descriptions and placeholders for test case generation. ([[1]](https://github.com/getappmap/appmap-js/pull/2282/files#diff-453f47dc0b3f8349e806c45215de8b8589cdab994445a033872a11f6dae2d98cR160-R162), [[2]](https://github.com/getappmap/appmap-js/pull/2282/files#diff-453f47dc0b3f8349e806c45215de8b8589cdab994445a033872a11f6dae2d98cR193-R270), [[3]](https://github.com/getappmap/appmap-js/pull/2282/files#diff-453f47dc0b3f8349e806c45215de8b8589cdab994445a033872a11f6dae2d98cL189-R296), [[4]](https://github.com/getappmap/appmap-js/pull/2282/files#diff-453f47dc0b3f8349e806c45215de8b8589cdab994445a033872a11f6dae2d98cL225-R332))
  • Introduced a new private method suggestTestCase to handle the generation of test case suggestions using ExplainCommand. ([packages/navie/src/commands/observe-command.tsR193-R270](https://github.com/getappmap/appmap-js/pull/2282/files#diff-453f47dc0b3f8349e806c45215de8b8589cdab994445a033872a11f6dae2d98cR193-R270))
  • Updated the RelevantTest schema to support nullable and transformed fields, and added a suggestedTest field for test case suggestions. ([[1]](https://github.com/getappmap/appmap-js/pull/2282/files#diff-453f47dc0b3f8349e806c45215de8b8589cdab994445a033872a11f6dae2d98cR3-R60), [[2]](https://github.com/getappmap/appmap-js/pull/2282/files#diff-453f47dc0b3f8349e806c45215de8b8589cdab994445a033872a11f6dae2d98cR72-R80))

Enhancements to explain-command:

  • Made classifierService optional and restricted agentSelectionService to specific properties, improving flexibility and type safety. ([[1]](https://github.com/getappmap/appmap-js/pull/2282/files#diff-8fc64b3b138b643930110c42f044e061bdc178fb607f1fbcf34bd30b7b13e95cL37-R41), [[2]](https://github.com/getappmap/appmap-js/pull/2282/files#diff-8fc64b3b138b643930110c42f044e061bdc178fb607f1fbcf34bd30b7b13e95cL55-R58))

Utility additions:

  • Added a closingTags function to detect and append missing XML closing tags, ensuring well-formed output. ([packages/navie/src/lib/closing-tags.tsR1-R33](https://github.com/getappmap/appmap-js/pull/2282/files#diff-192232aef104a6ceddd59ee60925fa896ff165740e45f82e81195e1232e91412R1-R33))
  • Introduced a replaceStream utility to replace specific patterns in a stream with asynchronous replacements. ([packages/navie/src/lib/replace-stream.tsR1-R35](https://github.com/getappmap/appmap-js/pull/2282/files#diff-103e6121f36f41a08a0e12704ff43d2930a244b4b4e63d77f5a84bb23dbf5e01R1-R35))

Improvements to InteractionHistory:

  • Added a clone method to create shallow copies of interaction history for isolated modifications. ([packages/navie/src/interaction-history.tsR319-R333](https://github.com/getappmap/appmap-js/pull/2282/files#diff-ed85c6d6714ad90002f856d93a39906e6cbd3135d24e1b4bb445c8360a9df27cR319-R333))

Test coverage:

  • Added unit tests for the closingTags utility to validate its behavior with various tag scenarios. ([packages/navie/test/lib/closing-tags.spec.tsR1-R35](https://github.com/getappmap/appmap-js/pull/2282/files#diff-6e1aad13709c90f0f865d6437be1b34d8931838f059ea792158b095afc9e2c26R1-R35))

Gemini has some issues with consistently generating the required
schema, so accept a simpler schema too.
@dividedmind dividedmind self-assigned this Apr 25, 2025
Copy link
Contributor

@Copilot Copilot AI left a 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 enhances command functionalities by adding intelligent test case suggestions, improving XML tag handling in streams, and expanding user option parsing.

  • Added automated test case suggestions in observe-command with a new private method.
  • Introduced utilities for replacing stream content and ensuring well-formed XML via closing tags.
  • Updated schemas and improved type safety in the explain-command and user options modules.

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/lib/closing-tags.spec.ts Added comprehensive test cases for the XML closing tags utility.
src/lib/replace-stream.ts Implemented asynchronous stream replacement for dynamic content replacement.
src/lib/parse-options.ts Enhanced option parsing to accept both Maps and Records with consistent key formatting.
src/lib/closing-tags.ts Introduced utility to detect unclosed XML tags and generate appropriate closing tags.
src/interaction-history.ts Added a clone method for creating shallow copies of interaction history.
src/commands/observe-command.ts Improved observe-command functionality with test suggestion logic and adjusted messaging.
src/commands/explain-command.ts Adjusted service dependency types to enhance flexibility and type safety.

Other improvements:
- enhance UserOptions constructor to accept both Map and object formats;
- add clone method to InteractionHistory;
- implement closingTags function for unclosed XML tags;
- introduce replaceStream for async string replacement in streams;
- update ExplainCommand to handle optional classifierService.
@dividedmind dividedmind force-pushed the feat/observe-make-tests branch from dafa9e0 to cae623f Compare April 29, 2025 13:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant