From d065b7c9bf9dc84e91f41498cc3f301f9163ef2f Mon Sep 17 00:00:00 2001 From: kirillzyusko Date: Thu, 6 Jun 2024 16:45:00 +0200 Subject: [PATCH 1/2] e2e: fixed typing test --- .../ComposerWithSuggestions/index.e2e.tsx | 24 +++++++++++++++---- tests/e2e/config.ts | 17 +++++++------ 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/index.e2e.tsx b/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/index.e2e.tsx index 7f169ef15918..3c898fb4882b 100644 --- a/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/index.e2e.tsx +++ b/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/index.e2e.tsx @@ -2,6 +2,7 @@ import type {ForwardedRef} from 'react'; import React, {forwardRef, useEffect} from 'react'; import E2EClient from '@libs/E2E/client'; import type {ComposerRef} from '@pages/home/report/ReportActionCompose/ReportActionCompose'; +import {Keyboard} from 'react-native'; import type {ComposerWithSuggestionsProps} from './ComposerWithSuggestions'; import ComposerWithSuggestions from './ComposerWithSuggestions'; @@ -26,11 +27,26 @@ function ComposerWithSuggestionsE2e(props: ComposerWithSuggestionsProps, ref: Fo // We need to wait for the component to be mounted before focusing setTimeout(() => { - if (!(ref && 'current' in ref)) { - return; - } + const setFocus = () => { + if (!(ref && 'current' in ref)) { + return; + } - ref.current?.focus(true); + ref.current?.focus(true); + + setTimeout(() => { + // and actually let's verify that the keyboard is visible + if (Keyboard.isVisible()) { + return + } + + ref.current?.blur(); + setFocus(); + // 500ms is enough time for any keyboard to open + }, 500); + }; + + setFocus(); }, 1); }, [ref]); diff --git a/tests/e2e/config.ts b/tests/e2e/config.ts index 4120019de692..c7cb9d0ed3c7 100644 --- a/tests/e2e/config.ts +++ b/tests/e2e/config.ts @@ -74,15 +74,14 @@ export default { [TEST_NAMES.OpenChatFinderPage]: { name: TEST_NAMES.OpenChatFinderPage, }, - // TODO: Fix text and enable again - // [TEST_NAMES.ReportTyping]: { - // name: TEST_NAMES.ReportTyping, - // reportScreen: { - // autoFocus: true, - // }, - // // Crowded Policy (Do Not Delete) Report, has a input bar available: - // reportID: '8268282951170052', - // }, + [TEST_NAMES.ReportTyping]: { + name: TEST_NAMES.ReportTyping, + reportScreen: { + autoFocus: true, + }, + // Crowded Policy (Do Not Delete) Report, has a input bar available: + reportID: '8268282951170052', + }, [TEST_NAMES.ChatOpening]: { name: TEST_NAMES.ChatOpening, // #announce Chat with many messages From e4e3f6a92574dcf772202a125e1c0371b0853956 Mon Sep 17 00:00:00 2001 From: kirillzyusko Date: Mon, 17 Jun 2024 11:00:29 +0300 Subject: [PATCH 2/2] fix: eslint --- .../ReportActionCompose/ComposerWithSuggestions/index.e2e.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/index.e2e.tsx b/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/index.e2e.tsx index 3c898fb4882b..682d3e8605b9 100644 --- a/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/index.e2e.tsx +++ b/src/pages/home/report/ReportActionCompose/ComposerWithSuggestions/index.e2e.tsx @@ -1,8 +1,8 @@ import type {ForwardedRef} from 'react'; import React, {forwardRef, useEffect} from 'react'; +import {Keyboard} from 'react-native'; import E2EClient from '@libs/E2E/client'; import type {ComposerRef} from '@pages/home/report/ReportActionCompose/ReportActionCompose'; -import {Keyboard} from 'react-native'; import type {ComposerWithSuggestionsProps} from './ComposerWithSuggestions'; import ComposerWithSuggestions from './ComposerWithSuggestions'; @@ -37,7 +37,7 @@ function ComposerWithSuggestionsE2e(props: ComposerWithSuggestionsProps, ref: Fo setTimeout(() => { // and actually let's verify that the keyboard is visible if (Keyboard.isVisible()) { - return + return; } ref.current?.blur();