From a8958019a5d8a9699121a4c57c5da7e1a50ccc06 Mon Sep 17 00:00:00 2001 From: Calinteodor Date: Sat, 10 Aug 2024 18:02:48 +0300 Subject: [PATCH] feat(chat/polls/native): added ids for tests (#14994) * feat(chat/polls/navigation): added ids for tests and removed some unused helpers --- react/features/base/react/types.ts | 1 + .../base/ui/components/native/Button.tsx | 21 ++++++++------- .../base/ui/components/native/IconButton.tsx | 2 ++ .../base/ui/components/native/Switch.tsx | 12 +++++++-- .../chat/components/native/ChatInputBar.tsx | 3 +++ .../chat/components/native/ChatMessage.tsx | 4 ++- .../chat/components/native/GifMessage.tsx | 1 + .../components/native/MessageContainer.tsx | 4 ++- .../components/native/MessageRecipient.tsx | 9 +++++-- .../components/HeaderNavigationButton.tsx | 9 ++++++- .../components/welcome/functions.tsx | 21 --------------- .../features/mobile/navigation/functions.tsx | 26 ++++--------------- .../polls/components/native/PollAnswer.tsx | 9 ++++++- .../polls/components/native/PollCreate.tsx | 6 +++++ .../polls/components/native/PollItem.tsx | 1 + .../polls/components/native/PollResults.tsx | 18 +++++++++++-- .../polls/components/native/PollsList.tsx | 4 ++- .../polls/components/native/PollsPane.tsx | 1 + 18 files changed, 90 insertions(+), 62 deletions(-) delete mode 100644 react/features/mobile/navigation/components/welcome/functions.tsx diff --git a/react/features/base/react/types.ts b/react/features/base/react/types.ts index d8870b89ee..1525926ea1 100644 --- a/react/features/base/react/types.ts +++ b/react/features/base/react/types.ts @@ -5,6 +5,7 @@ export interface IIconButtonProps { accessibilityLabel?: string; color?: string; disabled?: boolean; + id?: string; onPress?: (e?: GestureResponderEvent) => void; size?: number | string; src: Function; diff --git a/react/features/base/ui/components/native/Button.tsx b/react/features/base/ui/components/native/Button.tsx index 1291b21d39..f9e056c20d 100644 --- a/react/features/base/ui/components/native/Button.tsx +++ b/react/features/base/ui/components/native/Button.tsx @@ -1,7 +1,8 @@ import React from 'react'; import { useTranslation } from 'react-i18next'; -import { TouchableHighlight } from 'react-native'; +import { StyleProp, TouchableHighlight } from 'react-native'; import { Button as NativePaperButton, Text } from 'react-native-paper'; +import { IconSource } from 'react-native-paper/lib/typescript/components/Icon'; import { BUTTON_MODES, BUTTON_TYPES } from '../../constants.native'; import BaseTheme from '../BaseTheme.native'; @@ -13,6 +14,7 @@ import styles from './buttonStyles'; export interface IProps extends IButtonProps { color?: string | undefined; contentStyle?: Object | undefined; + id?: string; labelStyle?: Object | undefined; mode?: any; style?: Object | undefined; @@ -24,6 +26,7 @@ const Button: React.FC = ({ contentStyle, disabled, icon, + id, labelKey, labelStyle, mode = BUTTON_MODES.CONTAINED, @@ -74,16 +77,17 @@ const Button: React.FC = ({ + ] as StyleProp }> { t(labelKey ?? '') } + ] as StyleProp }>{ t(labelKey ?? '') } ); } @@ -96,21 +100,20 @@ const Button: React.FC = ({ contentStyle = { [ styles.buttonContent, contentStyle - ] } + ] as StyleProp } disabled = { disabled } - - // @ts-ignore - icon = { icon } + icon = { icon as IconSource | undefined } + id = { id } labelStyle = { [ buttonLabelStyles, labelStyle - ] } + ] as StyleProp } mode = { mode } onPress = { onPress } style = { [ buttonStyles, style - ] } /> + ] as StyleProp } /> ); }; diff --git a/react/features/base/ui/components/native/IconButton.tsx b/react/features/base/ui/components/native/IconButton.tsx index c374a26895..2e61680324 100644 --- a/react/features/base/ui/components/native/IconButton.tsx +++ b/react/features/base/ui/components/native/IconButton.tsx @@ -12,6 +12,7 @@ const IconButton: React.FC = ({ accessibilityLabel, color: iconColor, disabled, + id, onPress, size, src, @@ -52,6 +53,7 @@ const IconButton: React.FC = ({ ( } thumbColor = { thumbColor } trackColor = { trackColor } value = { checked } /> diff --git a/react/features/chat/components/native/ChatInputBar.tsx b/react/features/chat/components/native/ChatInputBar.tsx index b0fcf1f422..df726fcf0a 100644 --- a/react/features/chat/components/native/ChatInputBar.tsx +++ b/react/features/chat/components/native/ChatInputBar.tsx @@ -84,6 +84,7 @@ class ChatInputBar extends Component { return ( { { value = { this.state.message } /> diff --git a/react/features/chat/components/native/ChatMessage.tsx b/react/features/chat/components/native/ChatMessage.tsx index 696b78b62d..f1be1c8a84 100644 --- a/react/features/chat/components/native/ChatMessage.tsx +++ b/react/features/chat/components/native/ChatMessage.tsx @@ -76,7 +76,9 @@ class ChatMessage extends Component { const messageText = getMessageText(this.props.message); return ( - + { this._renderAvatar() } diff --git a/react/features/chat/components/native/GifMessage.tsx b/react/features/chat/components/native/GifMessage.tsx index fc14948f9b..7d77ee3da9 100644 --- a/react/features/chat/components/native/GifMessage.tsx +++ b/react/features/chat/components/native/GifMessage.tsx @@ -17,6 +17,7 @@ const GifMessage = ({ message }: IProps) => { const url = message.substring(GIF_PREFIX.length, message.length - 1); return ( { const { t } = this.props; return ( - + { t('chat.noMessagesMessage') } diff --git a/react/features/chat/components/native/MessageRecipient.tsx b/react/features/chat/components/native/MessageRecipient.tsx index 63457682f4..fc48025ae2 100644 --- a/react/features/chat/components/native/MessageRecipient.tsx +++ b/react/features/chat/components/native/MessageRecipient.tsx @@ -102,7 +102,9 @@ class MessageRecipient extends AbstractMessageRecipient { if (isLobbyChatActive) { return ( - + { t('chat.lobbyChatMessageTo', { recipient: lobbyMessageRecipient?.name @@ -123,13 +125,16 @@ class MessageRecipient extends AbstractMessageRecipient { } return ( - + { t('chat.messageTo', { recipient: privateMessageRecipient.name }) } { +const HeaderNavigationButton = ({ color, id, disabled, label, onPress, src, style, twoActions }: IProps) => { let btnStyle; let labelStyle; @@ -70,6 +75,7 @@ const HeaderNavigationButton = ({ color, disabled, label, onPress, src, style, t src ? ( void) { - return ( - - ); -} diff --git a/react/features/mobile/navigation/functions.tsx b/react/features/mobile/navigation/functions.tsx index d080e763bc..48bafc4a33 100644 --- a/react/features/mobile/navigation/functions.tsx +++ b/react/features/mobile/navigation/functions.tsx @@ -11,7 +11,7 @@ import { getFeatureFlag } from '../../base/flags/functions'; import { IconCloseLarge } from '../../base/icons/svg'; import { toState } from '../../base/redux/functions'; import { cancelKnocking } from '../../lobby/actions.native'; -import { isPrejoinEnabledInConfig } from '../../prejoin/functions'; +import { isPrejoinEnabledInConfig } from '../../prejoin/functions.native'; import HeaderNavigationButton from './components/HeaderNavigationButton'; @@ -28,6 +28,7 @@ export function screenHeaderCloseButton(goBack: (e?: GestureResponderEvent | Rea if (Platform.OS === 'ios') { return ( ); @@ -35,6 +36,7 @@ export function screenHeaderCloseButton(goBack: (e?: GestureResponderEvent | Rea return ( ); @@ -71,6 +73,7 @@ export function lobbyScreenHeaderCloseButton() { if (Platform.OS === 'ios') { return ( ); @@ -78,27 +81,8 @@ export function lobbyScreenHeaderCloseButton() { return ( ); } - -/** - * Returns true if we should auto-knock in case prejoin is enabled for the room. - * - * @param {Function|Object} stateful - The redux state or {@link getState} - * function. - * @returns {boolean} - */ -export function shouldEnableAutoKnock(stateful: IStateful) { - const state = toState(stateful); - const { displayName } = state['features/base/settings']; - - if (isPrejoinPageEnabled(state)) { - if (displayName) { - return true; - } - } else { - return false; - } -} diff --git a/react/features/polls/components/native/PollAnswer.tsx b/react/features/polls/components/native/PollAnswer.tsx index 53e0709a08..5411fdaa29 100644 --- a/react/features/polls/components/native/PollAnswer.tsx +++ b/react/features/polls/components/native/PollAnswer.tsx @@ -50,7 +50,9 @@ const PollAnswer = (props: AbstractProps) => { src = { IconCloseLarge } /> } - + { poll.answers.map((answer, index: number) => ( { setCheckbox(index, state) } /> { answer.name } @@ -72,6 +75,7 @@ const PollAnswer = (props: AbstractProps) => { ?