mirror of
https://github.com/getpaseo/paseo.git
synced 2026-07-29 12:01:31 +00:00
fix(app): add aria-checked to Switch for E2E toBeChecked() assertions
React Native Web does not map accessibilityState.checked to aria-checked
for role="switch", so Playwright's toBeChecked() always finds the element
unchecked. Adding aria-checked={value} directly to the Pressable sets the
attribute explicitly.
Update the switch.test.tsx mock to accept and pass through the explicit
aria-checked prop, keeping the mock faithful to the fixed component.
This commit is contained in:
@@ -32,6 +32,7 @@ vi.mock("react-native-reanimated", () => ({
|
||||
|
||||
vi.mock("react-native", () => ({
|
||||
Pressable: ({
|
||||
"aria-checked": ariaChecked,
|
||||
accessibilityLabel,
|
||||
accessibilityRole,
|
||||
accessibilityState,
|
||||
@@ -40,6 +41,7 @@ vi.mock("react-native", () => ({
|
||||
onPress,
|
||||
testID,
|
||||
}: {
|
||||
"aria-checked"?: boolean;
|
||||
accessibilityLabel?: string;
|
||||
accessibilityRole?: string;
|
||||
accessibilityState?: { checked?: boolean; disabled?: boolean };
|
||||
@@ -51,7 +53,7 @@ vi.mock("react-native", () => ({
|
||||
React.createElement(
|
||||
"button",
|
||||
{
|
||||
"aria-checked": accessibilityState?.checked,
|
||||
"aria-checked": ariaChecked ?? accessibilityState?.checked,
|
||||
"aria-disabled": accessibilityState?.disabled,
|
||||
"aria-label": accessibilityLabel,
|
||||
"data-disabled": disabled,
|
||||
|
||||
@@ -100,6 +100,7 @@ export function Switch({
|
||||
accessibilityRole="switch"
|
||||
accessibilityState={accessibilityState}
|
||||
accessibilityLabel={accessibilityLabel}
|
||||
aria-checked={value}
|
||||
testID={testID}
|
||||
style={pressableStyle}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user