Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NoQA] e2e: fixed typing test #43178

Merged
merged 2 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is a fix for an existing bug, does it mean that we need to increase the timeout that wraps it (currently 1ms)?
Could there be a cycling issue here?
I understand that this is for testing and wouldn't affect users, so this is just out of curiosity

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is a fix for an existing bug, does it mean that we need to increase the timeout that wraps it (currently 1ms)?

No, we don't need. Sometimes it may work within 1ms, sometimes not - and in this case we give 500ms to be sure keyboard is opened (otherwise we blur input, set focus again and repeat the action).

Could there be a cycling issue here?

I did many tests and haven't discovered ant cycling here 👀

}, 1);
}, [ref]);

Expand Down
17 changes: 8 additions & 9 deletions tests/e2e/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading