Skip to content

Add tests for Interactive Forms + minor validation tweaks - #6098

Merged
DanTup merged 1 commit into
interactive-formsfrom
interactive-forms-tests-and-validation-tweaks
Jun 29, 2026
Merged

DanTup merged 1 commit into
interactive-formsfrom
interactive-forms-tests-and-validation-tweaks

Conversation

@DanTup

@DanTup DanTup commented Jun 22, 2026

Copy link
Copy Markdown
Member

This adds some tests for form.ts, plus some minor changes to the validation for consistency, including:

  • consider empty strings as "no answer" (eg. fail validation if required)
  • treat empty inputs as "null" answer for optional fields
  • validate individual parts of a list input

gemini-code-assist[bot]

This comment was marked as resolved.

This comment was marked as resolved.

@DanTup
DanTup force-pushed the interactive-forms-tests-and-validation-tweaks branch from 89dcf96 to a84fb89 Compare June 22, 2026 14:26
This adds some tests for `form.ts`, plus some minor changes to the validation for consistency, including:

- consider empty strings as "no answer" (eg. fail validation if required)
- treat empty inputs as "null" answer for optional fields
- validate individual parts of a list input
- use `null` for skipped answers of optional fields

POTENTIALLY BREAKING: For consistency, we always use `null` for skipped optional answers now. Previously an optional `list` field would get an empty array if skipped.
@DanTup
DanTup force-pushed the interactive-forms-tests-and-validation-tweaks branch from a84fb89 to b3b7a47 Compare June 22, 2026 14:28
@DanTup DanTup self-assigned this Jun 22, 2026
@codecov

codecov Bot commented Jun 22, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.37500% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.10%. Comparing base (2ed820e) to head (b3b7a47).

Files with missing lines Patch % Lines
src/extension/analysis/form.ts 84.37% 4 Missing and 1 partial ⚠️
Additional details and impacted files
@@                  Coverage Diff                  @@
##           interactive-forms    #6098      +/-   ##
=====================================================
+ Coverage              70.01%   71.10%   +1.08%     
=====================================================
  Files                    173      173              
  Lines                  13273    13295      +22     
  Branches                2668     2677       +9     
=====================================================
+ Hits                    9293     9453     +160     
+ Misses                  3484     3322     -162     
- Partials                 496      520      +24     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@DanTup DanTup left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@h9jiang @bwilkerson this PR is mostly adding some tests (which I've tried to keep standalone in case we want to lift this with form.ts to a central repo in future), however while adding them I noticed some slight inconsistencies with validation (empty strings, and lists) so there are also some minor changes in form.ts.

Comment on lines -1004 to +1053
return [];
// Treat empty as no answer. We shouldn't get here if required because
// of validation.
return null;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@h9jiang I made this change to keep things consistent (submitting an empty input for an optional field always uses null for the answer), however if you've already shipped any server code with optional lists that expect non-null, this might be breaking. If so, we could revert this.

@DanTup

DanTup commented Jun 29, 2026

Copy link
Copy Markdown
Member Author

@h9jiang I'd also like your feedback on these changes to form.ts. There are also some tests, but those aren't likely to impact you in the same way as the form changes might.

@h9jiang h9jiang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the CL make perfect sense to me.

Right now, the vscode-go test against the gopls directly. However the approach you are taking (testing against the dummy language server) is better.

Thanks for coming up with the robust test!

@DanTup

DanTup commented Jun 29, 2026

Copy link
Copy Markdown
Member Author

Great, thanks for the review! 🙂

@DanTup
DanTup merged commit 0eb006c into interactive-forms Jun 29, 2026
24 checks passed
@DanTup
DanTup deleted the interactive-forms-tests-and-validation-tweaks branch June 29, 2026 17:39
@DanTup DanTup added this to the v3.140.0 milestone Jun 29, 2026
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.

3 participants