Skip to content

Commit 4c8ef87

Browse files
committed
fix: LoginPage checkbox methods fail with Radix UI checkboxes
The LoginPage used .check() and .uncheck() on the "Remember me" checkbox, but these Playwright methods only work on native <input type="checkbox"> elements. The app uses @radix-ui/react-checkbox which renders as <button role="checkbox">, causing tests to fail with: "Error: Not a checkbox or radio input" This prevented ALL e2e and visual tests from running, including the auth tests that execute in CI. Changed to use .setChecked() which works with both: - Native <input type="checkbox"> elements - ARIA checkboxes with role="checkbox" (Radix UI, MUI, etc.) Changes: - login(): Use setChecked(rememberMe) instead of conditional check() - clearForm(): Use setChecked(false) instead of conditional uncheck() The .isChecked() and .toBeChecked() assertions still work correctly because they check the aria-checked attribute that Radix UI sets.
1 parent 08a7b61 commit 4c8ef87

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

tests/pages/LoginPage.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,8 @@ export class LoginPage extends BasePage {
4343
await this.serverNameInput.fill(serverName);
4444
await this.bearerTokenInput.fill(token);
4545

46-
if (rememberMe) {
47-
await this.rememberMeCheckbox.check();
48-
}
46+
// Use setChecked() for Radix UI checkbox (renders as button role="checkbox")
47+
await this.rememberMeCheckbox.setChecked(rememberMe);
4948

5049
await this.loginButton.click();
5150
}
@@ -73,9 +72,8 @@ export class LoginPage extends BasePage {
7372
async clearForm() {
7473
await this.serverNameInput.clear();
7574
await this.bearerTokenInput.clear();
76-
if (await this.rememberMeCheckbox.isChecked()) {
77-
await this.rememberMeCheckbox.uncheck();
78-
}
75+
// Use setChecked() for Radix UI checkbox (renders as button role="checkbox")
76+
await this.rememberMeCheckbox.setChecked(false);
7977
}
8078

8179
/**

0 commit comments

Comments
 (0)