Skip to content

Commit 5957d9a

Browse files
authored
Merge pull request #43178 from margelo/e2e/fixed-typing-test
[NoQA] e2e: fixed typing test
2 parents f415fa9 + e4e3f6a commit 5957d9a

File tree

2 files changed

+28
-13
lines changed

2 files changed

+28
-13
lines changed

src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/index.e2e.tsx

+20-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type {ForwardedRef} from 'react';
22
import React, {forwardRef, useEffect} from 'react';
3+
import {Keyboard} from 'react-native';
34
import E2EClient from '@libs/E2E/client';
45
import type {ComposerRef} from '@pages/home/report/ReportActionCompose/ReportActionCompose';
56
import type {ComposerWithSuggestionsProps} from './ComposerWithSuggestions';
@@ -26,11 +27,26 @@ function ComposerWithSuggestionsE2e(props: ComposerWithSuggestionsProps, ref: Fo
2627

2728
// We need to wait for the component to be mounted before focusing
2829
setTimeout(() => {
29-
if (!(ref && 'current' in ref)) {
30-
return;
31-
}
30+
const setFocus = () => {
31+
if (!(ref && 'current' in ref)) {
32+
return;
33+
}
3234

33-
ref.current?.focus(true);
35+
ref.current?.focus(true);
36+
37+
setTimeout(() => {
38+
// and actually let's verify that the keyboard is visible
39+
if (Keyboard.isVisible()) {
40+
return;
41+
}
42+
43+
ref.current?.blur();
44+
setFocus();
45+
// 500ms is enough time for any keyboard to open
46+
}, 500);
47+
};
48+
49+
setFocus();
3450
}, 1);
3551
}, [ref]);
3652

tests/e2e/config.ts

+8-9
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,14 @@ export default {
7474
[TEST_NAMES.OpenChatFinderPage]: {
7575
name: TEST_NAMES.OpenChatFinderPage,
7676
},
77-
// TODO: Fix text and enable again
78-
// [TEST_NAMES.ReportTyping]: {
79-
// name: TEST_NAMES.ReportTyping,
80-
// reportScreen: {
81-
// autoFocus: true,
82-
// },
83-
// // Crowded Policy (Do Not Delete) Report, has a input bar available:
84-
// reportID: '8268282951170052',
85-
// },
77+
[TEST_NAMES.ReportTyping]: {
78+
name: TEST_NAMES.ReportTyping,
79+
reportScreen: {
80+
autoFocus: true,
81+
},
82+
// Crowded Policy (Do Not Delete) Report, has a input bar available:
83+
reportID: '8268282951170052',
84+
},
8685
[TEST_NAMES.ChatOpening]: {
8786
name: TEST_NAMES.ChatOpening,
8887
// #announce Chat with many messages

0 commit comments

Comments
 (0)