Skip to content

Commit fb1ed57

Browse files
authored
Merge pull request #87184 from Expensify/fix/86534-regression-test-auto-focus
[No QA] Add regression test for: web auto-focus blocked by phantom screen reader
2 parents 8dc318b + fd793b2 commit fb1ed57

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* Regression test for https://github.com/Expensify/App/issues/86534
3+
*
4+
* react-native-web's AccessibilityInfo.isScreenReaderEnabled() is hardcoded to
5+
* always resolve `true` (no browser API exists to detect screen readers). This
6+
* caused useScreenReaderStatus() to return `true` on web, which in turn blocked
7+
* auto-focus in useAutoFocusInput and similar hooks.
8+
*
9+
* The fix: a web-specific isScreenReaderEnabled module that always returns false,
10+
* so auto-focus is never skipped on web due to a phantom screen-reader detection.
11+
*/
12+
describe('isScreenReaderEnabled (web)', () => {
13+
it('returns false even when AccessibilityInfo.isScreenReaderEnabled resolves to true', async () => {
14+
// Directly import the web module (index.ts, not index.native.ts).
15+
// jest-expo defaults to ios platform which would resolve index.native.ts,
16+
// but the fix lives in the web-specific index.ts.
17+
// eslint-disable-next-line @typescript-eslint/no-var-requires
18+
const {default: isScreenReaderEnabled} = require('../../../../src/libs/Accessibility/isScreenReaderEnabled/index') as {default: () => Promise<boolean>};
19+
20+
const result = await isScreenReaderEnabled();
21+
22+
expect(result).toBe(false);
23+
});
24+
});

0 commit comments

Comments
 (0)