Skip to content

test(e2e): drop the textarea fork and select the value editors by role - #8448

Draft
talissoncosta wants to merge 2 commits into
refactor/value-editor-typescriptfrom
test/value-editor-a11y-selectors
Draft

test(e2e): drop the textarea fork and select the value editors by role#8448
talissoncosta wants to merge 2 commits into
refactor/value-editor-typescriptfrom
test/value-editor-a11y-selectors

Conversation

@talissoncosta

@talissoncosta talissoncosta commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Warning

Not for this round. #8446 is the PR that closes #8441 and #8442; this is
follow-up work and should not merge before it. Kept as a draft against a
non-main base for that reason.

Thanks for submitting a PR! Please check the boxes below:

  • I have read the Contributing Guide.
  • I have added information to docs/ if required so people know about the feature.
  • I have filled in the "Changes" section below.
  • I have filled in the "How did you test this code" section below.

Changes

Stacked on #8447 — review that first, this targets its branch.

Split out of #8447 deliberately: it is the only part of that work CI can validate and the only part I cannot check locally, so it is worth being able to revert on its own.

The fork. E2E ? <textarea> : <Highlight> was added in 2022 (#1642) as a TestCafe workaround. Playwright landed in March (#6562) and drives a contenteditable with fill(); TestCafe is gone from package.json entirely. Until now every E2E assertion about this editor ran against a <textarea> that only exists during tests — the real editor was never exercised.

placeholder and readOnly only ever worked on that textarea, so they go with it, along with the three call sites passing them.

The selectors. ValueEditor no longer takes a data-test. Three accessors replace it, and setText/waitForElementVisible accept a Locator:

featureValueField()           // role=textbox, /^(Value|Control Value)/
variationValueField(i)        // role=textbox, "Variation Value", .nth(i)
segmentOverrideValueField(i)  // scoped to the override, then role+name

This is only possible because #8447 gave the editor role="textbox" and an accessible name.

The alternation in featureValueField is not defensive: the label becomes Control Value <weight>% once a feature has variations, and editRemoteConfig hits that path.

It also retires a selector that encoded its own value:

data-test={`featureVariationValue${Utils.featureStateToValue(value) || index}`}

The id was featureVariationValue1 only while the field was empty, and became featureVariationValueadded once you typed. The tests passed because they addressed it before typing.

toHaveValue becomes toHaveText in change-request-test: the editor is a contenteditable, so there is no value to assert on.

How did you test this code?

CI is the test here, and that is the point of the split. I cannot run the suite locally — no API on :8000 and no containers — so this PR is unverified until the E2E job runs.

What I could check: reproduced what fill() does to the live component in Storybook (focus, select all, insertText) and confirmed the edit reaches onChange and survives a blur. No new type errors in e2e/ (3 before, 3 after, all pre-existing).

Reviewing this

If the E2E job is red, the two commits are independently revertible: the fork removal and the selector swap fail differently — a selector problem fails as "element not found", a contenteditable problem as "value not set".

Follow-up

The helper layer is the next thing this unlocks. setText wraps fill() with a redundant waitFor and clear() (both already done by fill()), plus .first(), which disables Playwright's strict mode. Across the file: 1246 lines, 75 helpers, 51 .first() calls, 47 redundant waits. As tests move to getByRole, they can call Playwright directly and the layer shrinks — no big-bang rewrite needed.

@vercel

vercel Bot commented Sep 2, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
flagsmith-frontend-preview Ready Ready Preview Sep 4, 2026 11:59am UTC
flagsmith-frontend-staging Ready Ready Preview Sep 4, 2026 11:59am UTC
1 Skipped Deployment
Project Deployment Actions Updated
docs Ignored Ignored Preview Sep 4, 2026 11:59am UTC

Request Review

@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the front-end Issue related to the React Front End Dashboard label Sep 2, 2026
@talissoncosta talissoncosta changed the title Drop the E2E textarea fork and select the value editors by role test(e2e): drop the textarea fork and select the value editors by role Sep 4, 2026
talissoncosta and others added 2 commits September 4, 2026 08:51
The E2E ? textarea : Highlight fork was added in 2022 as a TestCafe
workaround. Playwright landed in March and drives a contenteditable with
fill(), so every E2E assertion about this editor has been running against
a textarea that only exists during tests.

placeholder and readOnly only ever worked on that textarea, so they go
with it, along with the three call sites passing them.

Highlight takes role and aria-readonly from the caller rather than
deriving them from onChange, so ValueEditor can name its read-only
editors while the code blocks that also use Highlight stay unlabelled.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
ValueEditor no longer takes a data-test. Three accessors replace it, and
setText/waitForElementVisible accept a Locator so callers can pass one.

  featureValueField()            role=textbox, /^(Value|Control Value)/
  variationValueField(i)         role=textbox, "Variation Value", nth(i)
  segmentOverrideValueField(i)   scoped to the override, then role+name

The feature value alternation is not cosmetic: the label becomes
"Control Value <weight>%" once a feature has variations.

This also retires a selector that encoded its own value:

  data-test={`featureVariationValue${featureStateToValue(value) || index}`}

The id was featureVariationValue1 only while the field was empty, and
became featureVariationValueadded once you typed. The tests passed because
they addressed it before typing.

toHaveValue becomes toHaveText in change-request-test: the editor is a
contenteditable, not a textarea, so there is no value to assert on.

No new type errors in e2e (3 before, 3 after, all pre-existing).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

front-end Issue related to the React Front End Dashboard testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant