Conversation
Co-authored-by: stephenhand <1694716+stephenhand@users.noreply.github.com>
stephenhand
left a comment
There was a problem hiding this comment.
The preengagement form on the new client has more mandatory fields than the legacy form, determine which fields need to be filled and update the test code to populate them
…t POM Co-authored-by: stephenhand <1694716+stephenhand@users.noreply.github.com>
Identified the mandatory fields from the AS helpline's pre-engagement form definition (
All fields are still filled conditionally (if visible) to keep the POM flexible across helplines. Committed in 86095f9. |
There was a problem hiding this comment.
Pull request overview
Adds a new Playwright E2E flow for the aselo-webchat-react-app client (React/Redux, data-test / data-testid selectors), mirroring the existing legacy webchat E2E test flow and ensuring the new client’s pre-engagement form is completed before chatting.
Changes:
- Added
ASELO_WEBCHAT_URL/aseloWebchatUrlconfig option with a sensible default based onHLandHL_ENV. - Introduced a new Page Object Model (
aseloWebchat.ts) targeting the new app’s test attributes and pre-engagement fields. - Added a new serial Playwright spec (
aseloWebchat.spec.ts) that runs the same end-to-end chat + contact save flow against the new client.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| e2e-tests/config.ts | Adds aseloWebchatUrl config option used by the new E2E flow. |
| e2e-tests/aseloWebchat.ts | New POM for the React webchat client (open widget, fill pre-engagement form, run scripted chat). |
| e2e-tests/tests/aseloWebchat.spec.ts | New Playwright test that executes the full chat + HRM contact save workflow using the new POM. |
You can also share your feedback on Copilot code review. Take the survey.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
stephenhand
left a comment
There was a problem hiding this comment.
The new E2E test is failing because it doesn't check the accept terms and conditions checkbox
There was a problem hiding this comment.
Pull request overview
Adds a Playwright E2E test path for the new aselo-webchat-react-app client, mirroring the existing legacy webchat E2E flow while targeting the React app’s data-test / data-testid selectors and completing the required pre-engagement form.
Changes:
- Added a new Page Object Model for the React-based Aselo webchat client (
e2e-tests/aseloWebchat.ts). - Added a new Playwright spec that runs the full chat + HRM contact save flow against the new client (
e2e-tests/tests/aseloWebchat.spec.ts). - Introduced a new E2E config option for the Aselo webchat URL (
aseloWebchatUrl, env varASELO_WEBCHAT_URL) ine2e-tests/config.ts.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| e2e-tests/tests/aseloWebchat.spec.ts | New serial E2E test that opens the new webchat, fills pre-engagement, runs the chat script, and saves the contact form. |
| e2e-tests/config.ts | Adds aseloWebchatUrl config option (env override + default URL) for navigating to the new client. |
| e2e-tests/aseloWebchat.ts | New POM for the React app using data-test/data-testid selectors and onBlur-based pre-engagement field updates. |
| // The url of the aselo webchat react app is used to navigate to the new aselo webchat client | ||
| aseloWebchatUrl: { | ||
| envKey: 'ASELO_WEBCHAT_URL', | ||
| default: `https://assets-${localOverrideEnv}.tl.techmatters.org/aselo-webchat-react-app/${helplineShortCode}/`, |
There was a problem hiding this comment.
webchatUrl explicitly uses the direct S3 URL to avoid CloudFront caching issues (see the comment above), but aseloWebchatUrl defaults to the assets-...tl.techmatters.org host. For consistency and to reduce the risk of E2E tests hitting stale cached assets, consider switching this default to the equivalent https://s3.amazonaws.com/assets-${localOverrideEnv}.tl.techmatters.org/aselo-webchat-react-app/${helplineShortCode}/ (still overridable via ASELO_WEBCHAT_URL).
| default: `https://assets-${localOverrideEnv}.tl.techmatters.org/aselo-webchat-react-app/${helplineShortCode}/`, | |
| default: `https://s3.amazonaws.com/assets-${localOverrideEnv}.tl.techmatters.org/aselo-webchat-react-app/${helplineShortCode}/`, |
There was a problem hiding this comment.
Using the cloudfront URL is a better test as it checks cloudfront and the cache evection on deployment is correctly configured
…kbox Co-authored-by: stephenhand <1694716+stephenhand@users.noreply.github.com> Agent-Logs-Url: https://github.com/techmatters/flex-plugins/sessions/e3456621-e7b9-4674-9f4f-25f1ddf08972
The checkbox wasn't being checked because Paste's Fixed in 7899e21:
|
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
stephenhand
left a comment
There was a problem hiding this comment.
The test is failing because the terms & conditions checkbox is out of the viewport when the test tries to select it. From the logs it looks like the method being used should automatically try to scroll it into view but you might want to try explicitly scrolling it into view or changing the timeout
| // The url of the aselo webchat react app is used to navigate to the new aselo webchat client | ||
| aseloWebchatUrl: { | ||
| envKey: 'ASELO_WEBCHAT_URL', | ||
| default: `https://assets-${localOverrideEnv}.tl.techmatters.org/aselo-webchat-react-app/${helplineShortCode}/`, |
There was a problem hiding this comment.
Using the cloudfront URL is a better test as it checks cloudfront and the cache evection on deployment is correctly configured
Co-authored-by: stephenhand <1694716+stephenhand@users.noreply.github.com> Agent-Logs-Url: https://github.com/techmatters/flex-plugins/sessions/41d2e2c4-dec3-4823-ad73-fcf0c023b662
Added an explicit |
stephenhand
left a comment
There was a problem hiding this comment.
Twilio paste checkboxes like the terms and condtions checkbox hide the real HTML input and show an SVG facsimile instead, so playwright is failing to check it, because the 'real' checkbox is not rendered
Work around this by clicking the label for the checkbox rather than checking the box directly. Prefer adding a data ID attribute or a HTML ID to the label to locate it rather than attempting to match using the label text
Agent-Logs-Url: https://github.com/techmatters/flex-plugins/sessions/e3fc146f-7b88-41d9-abcd-96e842ce9c4f Co-authored-by: stephenhand <1694716+stephenhand@users.noreply.github.com>
Fixed in 1375f0b:
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:
If you need me to access, download, or install something from one of these locations, you can either:
|
…st' into copilot/add-aselo-webchat-e2e-test
stephenhand
left a comment
There was a problem hiding this comment.
Enhance the pre-engagement form by setting the values of every form value in redux to the current value in the equivalent form element prior to running any validation sweep. This way redux will always be up to date for validation purpuses
Agent-Logs-Url: https://github.com/techmatters/flex-plugins/sessions/9e47c862-b815-4883-b8a2-0d6666f0abf2 Co-authored-by: stephenhand <1694716+stephenhand@users.noreply.github.com>
Done in 5a7a98e. In Updated tests to reflect the new behaviour:
|
|
|
||
| // Sync every form element's current DOM value to Redux before validation runs. | ||
| // This ensures fields that have been filled but not yet blurred are still captured. | ||
| preEngagementFormDefinition?.fields?.forEach(field => { |
There was a problem hiding this comment.
@copilot This should be implemented as a single action that can take multiple updated fields and update them all at once. updatePreEngagementDataFields action creator should be replaced with one that takes multiple fields and conforms to our naming convention for action creator functiuons
There was a problem hiding this comment.
Done in 9989965. Added updatePreEngagementDataFields (plural) thunk in genericActions.ts — it takes an array of {name, value} pairs, looks up each definition once from state, validates and builds all updated items, then dispatches a single ACTION_UPDATE_PRE_ENGAGEMENT_DATA action with the merged result.
handleSubmit in PreEngagementFormPhase.tsx now collects all DOM values into an array via reduce and calls dispatch(updatePreEngagementDataFields(domFieldValues)) once before submitAndInitChatThunk. Added unit tests for the new action in genericActions.test.ts.
…bmit Agent-Logs-Url: https://github.com/techmatters/flex-plugins/sessions/d9454e11-096c-4b60-9f69-e37585453088 Co-authored-by: stephenhand <1694716+stephenhand@users.noreply.github.com>
Description
Adds an E2E test for the new
aselo-webchat-react-appclient, parallel to the existing legacy webchat test. The new client uses React+Redux withdata-test/data-testidattributes rather than Twilio Flex CSS classes, and requires completing a pre-engagement form before chatting.e2e-tests/config.tsaseloWebchatUrlconfig option (ASELO_WEBCHAT_URLenv var), defaulting to the CloudFront URLhttps://assets-${env}.tl.techmatters.org/aselo-webchat-react-app/${helplineShortCode}/(intentionally uses CloudFront rather than S3 direct, to validate cache eviction on deployment)HL=e2e,HL_ENV=development) resolves tohttps://assets-development.tl.techmatters.org/aselo-webchat-react-app/e2e/e2e-tests/aseloWebchat.ts(new POM)webchat.tsbut targets the new app's test attributes instead of Twilio Flex CSS classesbutton.Twilio-EntryPoint[data-testid="entry-point-button"]div.Twilio-MainContainer[data-test="root-container"]div.Twilio-PreEngagementCanvas[data-test="pre-engagement-chat-form"].Twilio-MessageInputArea-TextArea textarea[data-test="message-input-textarea"]div.Twilio-MessageListItem div.Twilio-MessageBubble[data-testid="message-bubble"] pfillPreEngagementForm()populates all mandatory fields of the AS pre-engagement form:firstName→input#firstNamecontactIdentifier(email) →input#contactIdentifierage→select#agegender→select#gendertermsAndConditions— Twilio Paste renders the real checkbox input as a visually-hidden element and shows an SVG facsimile, so the visible label is clicked instead. Adata-testid={${name}-label}attribute is added to theLabelelement inaselo-webchat-react-app/src/components/forms/formInputs/Checkbox.tsxand the POM locates the label via[data-testid="termsAndConditions-label"], clicks it to toggle the checkbox, then blurs the hidden input to fire theonBlurRedux dispatchselectHelpline()uses native<select>via Playwright'sselectOption()rather than the MUI dropdown approach in the legacy POMaselo-webchat-react-app/src/components/forms/formInputs/Checkbox.tsxdata-testid={${name}-label}to theLabelelement to give each checkbox label a stable, id-based test attribute for E2E targetingaselo-webchat-react-app/src/store/actions/genericActions.tsupdatePreEngagementDataFieldsthunk action creator that takes an array of{ name, value }pairs, looks up each field definition once from state, validates and builds all updated items, then dispatches a singleACTION_UPDATE_PRE_ENGAGEMENT_DATAaction with the merged resultaselo-webchat-react-app/src/components/PreEngagementFormPhase.tsxhandleSubmitnow syncs all current DOM form element values to Redux in a single batch dispatch immediately beforesubmitAndInitChatThunk()runs validation. It collects all field values viareduceand callsdispatch(updatePreEngagementDataFields(domFieldValues))once (.checkedfor checkboxes,.valuefor all others). This ensures Redux is fully up to date for validation regardless of whether a field'sonBlurevent has fired — preventing fields filled without blurring (e.g. by an E2E test) from failing validatione2e-tests/tests/aseloWebchat.spec.ts(new test)webchat.spec.ts: open chat → fill pre-engagement form → run chat script → fill contact form → saveChecklist
Other Related Issues
None
Verification steps
Run against the development environment:
The test navigates to the deployed e2e page, clicks the chat entry point, completes all mandatory pre-engagement form fields (first name, email, age, gender, terms & conditions), exchanges chat messages via the bot/counselor flow, and saves the contact form.
AFTER YOU MERGE
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
Original prompt
💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.