fix(test-playwright-forms): refactor form handling to support modal inputs and improve field validation#16218
Open
petesfrench wants to merge 1 commit intomainfrom
Open
fix(test-playwright-forms): refactor form handling to support modal inputs and improve field validation#16218petesfrench wants to merge 1 commit intomainfrom
petesfrench wants to merge 1 commit intomainfrom
Conversation
…nputs and improve field validation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors Playwright form tests to better handle Marketo forms rendered inside a modal (form generator), improving selector scoping and field-filling behavior across static and modal form variants.
Changes:
- Scope modal form interactions to
#contact-modaland update selectors to match generated-form accessibility attributes (aria-label). - Update shared Playwright helpers to support filling fields within either a
Pageor a scopedLocator. - Adjust static
/contact-usform ID validation to scope theformidlookup to a specific Marketo form element.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| tests/playwright/tests/forms/static-forms.spec.ts | Scopes formid validation to a located Marketo form and adds a per-test timeout. |
| tests/playwright/tests/forms/form-generator.spec.ts | Refactors modal tests to scope locators to the modal and use generated-form selectors. |
| tests/playwright/helpers/form-fields.ts | Adds modal-specific checkbox/radio selector lists for generated forms. |
| tests/playwright/helpers/commands.ts | Extends helpers to accept Page or Locator to enable scoped form filling in modals. |
Comments suppressed due to low confidence (1)
tests/playwright/helpers/commands.ts:77
fillExistingFieldsswitched checkbox handling from.check()to.click()..click()toggles state and can uncheck boxes that are pre-selected, making tests less deterministic. Prefer using.check()for checkboxes (and.check()for radios as well) so the helper guarantees the element ends up selected.
for (const { field, value } of testTextFields) {
if (await isExistingField(page, field)) {
await page.locator(field).fill(value);
}
}
for (const { field } of testCheckboxFields) {
if (await isExistingField(page, field)) {
await page.locator(field).click({ force: true });
}
}
for (const { field } of testRadioFields) {
if (await isExistingField(page, field)) {
await page.locator(field).click({ force: true });
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #16218 +/- ##
=======================================
Coverage 48.52% 48.52%
=======================================
Files 37 37
Lines 5875 5875
=======================================
Hits 2851 2851
Misses 3024 3024 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Done
QA
.env.local(they are in bitwarden) and you have playwright chromium installed (yarn playwright install --with-deps chromium)dotrunINCLUDE_FORMS=true TESTING=true yarn playwright test forms --reporter=listdotrun test-marketoIssue / Card
Fixes https://warthogs.atlassian.net/browse/WD-35799