Skip to content

fix(test-playwright-forms): refactor form handling to support modal inputs and improve field validation#16218

Open
petesfrench wants to merge 1 commit intomainfrom
WD-35799
Open

fix(test-playwright-forms): refactor form handling to support modal inputs and improve field validation#16218
petesfrench wants to merge 1 commit intomainfrom
WD-35799

Conversation

@petesfrench
Copy link
Copy Markdown
Contributor

@petesfrench petesfrench commented Apr 8, 2026

Problem

Done

  • Scoped modal tests to #contact-modal locator and fixed aria-labelledby assignments
  • Added modalForm field lists in form-fields.ts with correct aria-label selectors for the generated form

QA

  • Checkout this branch locally
  • Make sure you have the marketo keys in your .env.local (they are in bitwarden) and you have playwright chromium installed (yarn playwright install --with-deps chromium)
  • Start the app in one terminal with dotrun
  • Run the CI check INCLUDE_FORMS=true TESTING=true yarn playwright test forms --reporter=list
  • Check the marketo tests pass with dotrun test-marketo

Issue / Card

Fixes https://warthogs.atlassian.net/browse/WD-35799

Copilot AI review requested due to automatic review settings April 8, 2026 15:27
@webteam-app
Copy link
Copy Markdown

Copy link
Copy Markdown
Contributor

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 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-modal and update selectors to match generated-form accessibility attributes (aria-label).
  • Update shared Playwright helpers to support filling fields within either a Page or a scoped Locator.
  • Adjust static /contact-us form ID validation to scope the formid lookup 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

  • fillExistingFields switched 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
Copy link
Copy Markdown

codecov bot commented Apr 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 48.52%. Comparing base (48d0d7d) to head (c31a0b4).

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:
  • ❄️ 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants