Skip to content

test: Improve unit test coverage for webchat pre-engagement form components [CHI-3696]#3976

Merged
gpaoloni merged 4 commits intogian_CHI-3696from
copilot/sub-pr-3897
Feb 27, 2026
Merged

test: Improve unit test coverage for webchat pre-engagement form components [CHI-3696]#3976
gpaoloni merged 4 commits intogian_CHI-3696from
copilot/sub-pr-3897

Conversation

Copy link
Contributor

Copilot AI commented Feb 27, 2026

Description

Adds validation logic and comprehensive test coverage for the pre-engagement form components introduced in the parent PR. Covers all FormInputType variants supported in webchat forms (Input, Email, Select, DependentSelect, Checkbox).

Changes

validation.ts

  • Fixed validateEmailPattern to skip validation for empty values — optional email fields no longer produce errors when blank

PreEngagementFormPhase.tsx

  • Added submit-time validation: all fields are validated via validateInput (using getDefaultValue for type-correct defaults per field type) before fetchAndStoreNewSession is called; aborts submission if any field has an error

PreEngagementFormPhase.test.tsx

  • Added form validation test block covering all five FormInputType types, asserting fetchAndStoreNewSession is not called when:
    • A required field is empty (Input, Email, Select, DependentSelect, Checkbox)
    • An Email field has a value that doesn't match EMAIL_PATTERN

New component test files (__tests__/Input.test.tsx, Checkbox.test.tsx, Select.test.tsx, DependentSelect.test.tsx)**

  • Each asserts: label renders, error message renders when error is non-null, onBlur calls handleChange with correct { name, value }
  • DependentSelect additionally asserts setItemValue is called to reset the dependent select when the dependee value changes

Checklist

  • Corresponding issue has been opened
  • New tests added
  • Feature flags added
  • Strings are localized
  • Tested for chat contacts
  • Tested for call contacts

Other Related Issues

Parent PR: #3865 (form definitions), #3897 (form rendering)

Verification steps

Run npm test in aselo-webchat-react-app — all 314 tests pass.

AFTER YOU MERGE

  1. Cut a release tag using the Github workflow. Wait for it to complete and notify in the #aselo-deploys Slack channel.
  2. Comment on the ticket with the release tag version AND any additional instructions required to configure an environment to test the changes.
  3. Only then move the ticket into the QA column in JIRA

You are responsible for ensuring the above steps are completed. If you move a ticket into QA without advising what version to test, the QA team will assume the latest tag has the changes. If it does not, the following confusion is on you! :-P


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…3696]

Co-authored-by: gpaoloni <15805319+gpaoloni@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 27, 2026

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • download.cypress.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node dist/index.js --exec install (dns block)
  • tsock.us1.twilio.com
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/flex-plugins/flex-plugins/aselo-webchat-react-app/node_modules/.bin/jest --watchAll=false (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/flex-plugins/flex-plugins/aselo-webchat-react-app/node_modules/.bin/jest --watchAll=false bash --no�� /package-lock.json (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] Implement rendering of webchat pre-engagement form test: Improve unit test coverage for webchat pre-engagement form components [CHI-3696] Feb 27, 2026
@gpaoloni gpaoloni marked this pull request as ready for review February 27, 2026 21:48
@gpaoloni gpaoloni merged commit 989af43 into gian_CHI-3696 Feb 27, 2026
26 checks passed
@gpaoloni gpaoloni deleted the copilot/sub-pr-3897 branch February 27, 2026 21:48
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.

2 participants