Fix profile-visibility radio selector in e2e (strict-mode collision)

`getByLabel('Public')` matched both radios because the Private radio's
help-text label contains the substring "public" ("…followers see your
public content."). Switch to targeting the input directly by name+value,
which is unambiguous regardless of help-text wording.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ullrich Schäfer 2026-04-25 23:51:19 +02:00
parent ff09775091
commit 1219b46ca3
2 changed files with 9 additions and 6 deletions

View file

@ -50,9 +50,13 @@ async function setRouteVisibility(
// New users default to profile_visibility='private' (locked-account // New users default to profile_visibility='private' (locked-account
// model). Tests that need an anon visitor to see the profile in full // model). Tests that need an anon visitor to see the profile in full
// have to flip the owner to public first. // have to flip the owner to public first.
//
// The radio is targeted by name+value rather than getByLabel because
// the Private radio's help-text label happens to contain the word
// "public", which trips Playwright's strict-mode match.
async function setProfileVisibilityPublic(page: Page) { async function setProfileVisibilityPublic(page: Page) {
await page.goto("/settings"); await page.goto("/settings");
await page.getByLabel("Public").check(); await page.locator('input[type=radio][name=profileVisibility][value=public]').check();
await page.getByRole("button", { name: /^Save$/ }).first().click(); await page.getByRole("button", { name: /^Save$/ }).first().click();
await page.waitForLoadState("networkidle"); await page.waitForLoadState("networkidle");
} }

View file

@ -28,11 +28,10 @@ async function registerUser(page: Page, email: string, username: string) {
async function setProfileVisibility(page: Page, value: "public" | "private") { async function setProfileVisibility(page: Page, value: "public" | "private") {
await page.goto("/settings"); await page.goto("/settings");
if (value === "public") { // Target the radio by name+value; getByLabel collides because the
await page.getByLabel("Public").check(); // help text of one radio mentions the other's word ("public" appears
} else { // in the Private radio's helper sentence).
await page.getByLabel(/Private/).check(); await page.locator(`input[type=radio][name=profileVisibility][value=${value}]`).check();
}
await page.getByRole("button", { name: /^Save$/ }).first().click(); await page.getByRole("button", { name: /^Save$/ }).first().click();
await page.waitForLoadState("networkidle"); await page.waitForLoadState("networkidle");
} }