Skip to content

Commit

Permalink
feat(chat/polls): added ids for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Calinteodor committed Aug 9, 2024
1 parent fa6dc29 commit 3fb954e
Show file tree
Hide file tree
Showing 15 changed files with 76 additions and 19 deletions.
1 change: 1 addition & 0 deletions react/features/base/react/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export interface IIconButtonProps {
accessibilityLabel?: string;
color?: string;
disabled?: boolean;
id?: string;
onPress?: (e?: GestureResponderEvent) => void;
size?: number | string;
src: Function;
Expand Down
18 changes: 10 additions & 8 deletions react/features/base/ui/components/native/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
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 { BUTTON_MODES, BUTTON_TYPES } from '../../constants.native';
Expand All @@ -13,6 +13,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;
Expand All @@ -24,6 +25,7 @@ const Button: React.FC<IProps> = ({
contentStyle,
disabled,
icon,
id,
labelKey,
labelStyle,
mode = BUTTON_MODES.CONTAINED,
Expand Down Expand Up @@ -74,16 +76,17 @@ const Button: React.FC<IProps> = ({
<TouchableHighlight
accessibilityLabel = { accessibilityLabel }
disabled = { disabled }
id = { id }
onPress = { onPress }
style = { [
buttonStyles,
style
] }>
] as StyleProp<object> }>
<Text
style = { [
buttonLabelStyles,
labelStyle
] }>{ t(labelKey ?? '') }</Text>
] as StyleProp<object> }>{ t(labelKey ?? '') }</Text>
</TouchableHighlight>
);
}
Expand All @@ -96,21 +99,20 @@ const Button: React.FC<IProps> = ({
contentStyle = { [
styles.buttonContent,
contentStyle
] }
] as StyleProp<object> }
disabled = { disabled }

// @ts-ignore
icon = { icon }

Check failure on line 104 in react/features/base/ui/components/native/Button.tsx

View workflow job for this annotation

GitHub Actions / Lint

Type 'Function | undefined' is not assignable to type 'IconSource | undefined'.
id = { id }
labelStyle = { [
buttonLabelStyles,
labelStyle
] }
] as StyleProp<object> }
mode = { mode }
onPress = { onPress }
style = { [
buttonStyles,
style
] } />
] as StyleProp<object> } />
);
};

Expand Down
2 changes: 2 additions & 0 deletions react/features/base/ui/components/native/IconButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const IconButton: React.FC<IIconButtonProps> = ({
accessibilityLabel,
color: iconColor,
disabled,
id,
onPress,
size,
src,
Expand Down Expand Up @@ -52,6 +53,7 @@ const IconButton: React.FC<IIconButtonProps> = ({
<TouchableHighlight
accessibilityLabel = { accessibilityLabel }
disabled = { disabled }
id = { id }
onPress = { onPress }
style = { [
iconButtonContainerStyles,
Expand Down
14 changes: 11 additions & 3 deletions react/features/base/ui/components/native/Switch.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { ColorValue } from 'react-native';
import { ColorValue, StyleProp } from 'react-native';
import { Switch as NativeSwitch } from 'react-native-paper';

import { ISwitchProps } from '../types';
Expand All @@ -12,6 +12,12 @@ import {

interface IProps extends ISwitchProps {

/**
* Id for the switch.
*/

id?: string;

/**
* Custom styles for the switch.
*/
Expand All @@ -31,6 +37,7 @@ interface IProps extends ISwitchProps {
const Switch = ({
checked,
disabled,
id,
onChange,
thumbColor = THUMB_COLOR,
trackColor = {
Expand All @@ -41,11 +48,12 @@ const Switch = ({
}: IProps) => (
<NativeSwitch
disabled = { disabled }
id = { id }
ios_backgroundColor = { DISABLED_TRACK_COLOR }
onValueChange = { onChange }
style = { style }
style = { style as StyleProp<object> }
thumbColor = { thumbColor }
trackColor = { trackColor }
trackColor = { trackColor as ColorValue }

Check failure on line 56 in react/features/base/ui/components/native/Switch.tsx

View workflow job for this annotation

GitHub Actions / Lint

Type 'ColorValue' is not assignable to type '{ false?: ColorValue | null | undefined; true?: ColorValue | null | undefined; } | undefined'.
value = { checked } />
);

Expand Down
3 changes: 3 additions & 0 deletions react/features/chat/components/native/ChatInputBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,15 @@ class ChatInputBar extends Component<IProps, IState> {

return (
<View
id = 'chat-input'
style = { [
inputBarStyles,
this.state.addPadding ? styles.extraBarPadding : null
] as ViewStyle[] }>
<Input
blurOnSubmit = { false }
customStyles = {{ container: styles.customInputContainer }}
id = 'chat-input-messagebox'
multiline = { false }
onBlur = { this._onFocused(false) }
onChange = { this._onChangeText }
Expand All @@ -101,6 +103,7 @@ class ChatInputBar extends Component<IProps, IState> {
value = { this.state.message } />
<IconButton
disabled = { !this.state.message }
id = { this.props.t('chat.sendButton') }
onPress = { this._onSubmit }
src = { IconSend }
type = { BUTTON_TYPES.PRIMARY } />
Expand Down
4 changes: 3 additions & 1 deletion react/features/chat/components/native/ChatMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ class ChatMessage extends Component<IChatMessageProps> {
const messageText = getMessageText(this.props.message);

return (
<View style = { styles.messageWrapper as ViewStyle } >
<View
id = { message.messageId }
style = { styles.messageWrapper as ViewStyle } >
{ this._renderAvatar() }
<View style = { detailsWrapperStyle }>
<View style = { messageBubbleStyle }>
Expand Down
1 change: 1 addition & 0 deletions react/features/chat/components/native/GifMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const GifMessage = ({ message }: IProps) => {
const url = message.substring(GIF_PREFIX.length, message.length - 1);

return (<View
id = 'gif-message'
style = { styles.gifContainer }>
<Image
source = {{ uri: url }}
Expand Down
4 changes: 3 additions & 1 deletion react/features/chat/components/native/MessageContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ class MessageContainer extends AbstractMessageContainer<IProps, any> {
const { t } = this.props;

return (
<View style = { styles.emptyComponentWrapper as ViewStyle }>
<View
id = 'no-messages-message'
style = { styles.emptyComponentWrapper as ViewStyle }>
<Text style = { styles.emptyComponentText as TextStyle }>
{ t('chat.noMessagesMessage') }
</Text>
Expand Down
9 changes: 7 additions & 2 deletions react/features/chat/components/native/MessageRecipient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ class MessageRecipient extends AbstractMessageRecipient<IProps> {

if (isLobbyChatActive) {
return (
<View style = { styles.lobbyMessageRecipientContainer as ViewStyle }>
<View
id = 'chat-recipient'
style = { styles.lobbyMessageRecipientContainer as ViewStyle }>
<Text style = { styles.messageRecipientText }>
{ t('chat.lobbyChatMessageTo', {
recipient: lobbyMessageRecipient?.name
Expand All @@ -123,13 +125,16 @@ class MessageRecipient extends AbstractMessageRecipient<IProps> {
}

return (
<View style = { styles.messageRecipientContainer as ViewStyle }>
<View
id = 'message-recipient'
style = { styles.messageRecipientContainer as ViewStyle }>
<Text style = { styles.messageRecipientText }>
{ t('chat.messageTo', {
recipient: privateMessageRecipient.name
}) }
</Text>
<TouchableHighlight
id = 'message-recipient-cancel-button'
onPress = { this._onResetPrivateMessageRecipient }
underlayColor = { 'transparent' }>
<Icon
Expand Down
9 changes: 8 additions & 1 deletion react/features/polls/components/native/PollAnswer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ const PollAnswer = (props: AbstractProps) => {
src = { IconCloseLarge } />
}
</View>
<View style = { pollsStyles.answerContent as ViewStyle }>
<View
id = 'answer-content'
style = { pollsStyles.answerContent as ViewStyle }>
{
poll.answers.map((answer, index: number) => (
<View
Expand All @@ -59,6 +61,7 @@ const PollAnswer = (props: AbstractProps) => {
<Switch
checked = { checkBoxStates[index] }
disabled = { poll.saved }
id = 'answer-switch'
onChange = { state => setCheckbox(index, state) } />
<Text style = { pollsStyles.switchLabel as TextStyle }>
{ answer.name }
Expand All @@ -72,6 +75,7 @@ const PollAnswer = (props: AbstractProps) => {
? <View style = { pollsStyles.buttonRow as ViewStyle }>
<Button
accessibilityLabel = 'polls.answer.edit'
id = { t('polls.answer.edit') }
labelKey = 'polls.answer.edit'
onClick = { () => {
setCreateMode(true);
Expand All @@ -81,6 +85,7 @@ const PollAnswer = (props: AbstractProps) => {
type = { SECONDARY } />
<Button
accessibilityLabel = 'polls.answer.send'
id = { t('polls.answer.send') }
labelKey = 'polls.answer.send'
onClick = { sendPoll }
style = { pollsStyles.pollCreateButton }
Expand All @@ -89,13 +94,15 @@ const PollAnswer = (props: AbstractProps) => {
: <View style = { pollsStyles.buttonRow as ViewStyle }>
<Button
accessibilityLabel = 'polls.answer.skip'
id = { t('polls.answer.skip') }
labelKey = 'polls.answer.skip'
onClick = { changingVote ? skipChangeVote : skipAnswer }
style = { pollsStyles.pollCreateButton }
type = { SECONDARY } />
<Button
accessibilityLabel = 'polls.answer.submit'
disabled = { isSubmitAnswerDisabled(checkBoxStates) }
id = { t('polls.answer.submit') }
labelKey = 'polls.answer.submit'
onClick = { submitAnswer }
style = { pollsStyles.pollCreateButton }
Expand Down
6 changes: 6 additions & 0 deletions react/features/polls/components/native/PollCreate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ const PollCreate = (props: AbstractProps) => {
/* eslint-disable react/no-multi-comp */
const createRemoveOptionButton = (onPress: () => void) => (
<Button
id = { t('polls.create.removeOption') }
labelKey = 'polls.create.removeOption'
labelStyle = { dialogStyles.optionRemoveButtonText }
onClick = { onPress }
Expand All @@ -107,6 +108,7 @@ const PollCreate = (props: AbstractProps) => {

return (
<View
id = 'option-container'
style = { dialogStyles.optionContainer as ViewStyle }>
<Input
blurOnSubmit = { false }
Expand Down Expand Up @@ -142,6 +144,7 @@ const PollCreate = (props: AbstractProps) => {
autoFocus = { true }
blurOnSubmit = { false }
customStyles = {{ container: dialogStyles.customContainer }}
id = { t('polls.create.pollQuestion') }
label = { t('polls.create.pollQuestion') }
maxLength = { CHAR_LIMIT }
onChange = { setQuestion }
Expand Down Expand Up @@ -169,6 +172,7 @@ const PollCreate = (props: AbstractProps) => {
<Button
accessibilityLabel = 'polls.create.addOption'
disabled = { answers.length >= ANSWERS_LIMIT }
id = { t('polls.create.addOption') }
labelKey = 'polls.create.addOption'
onClick = { () => {
// adding and answer
Expand All @@ -181,6 +185,7 @@ const PollCreate = (props: AbstractProps) => {
style = { pollsStyles.buttonRow as ViewStyle }>
<Button
accessibilityLabel = 'polls.create.cancel'
id = { t('polls.create.cancel') }
labelKey = 'polls.create.cancel'
onClick = { () => {
setCreateMode(false);
Expand All @@ -193,6 +198,7 @@ const PollCreate = (props: AbstractProps) => {
<Button
accessibilityLabel = 'polls.create.save'
disabled = { isSubmitDisabled }
id = { t('polls.create.save') }
labelKey = 'polls.create.save'
onClick = { onSubmit }
style = { pollsStyles.pollCreateButton }
Expand Down
1 change: 1 addition & 0 deletions react/features/polls/components/native/PollItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const PollItem = ({ pollId, setCreateMode }: IProps) => {

return (
<View
id = 'poll-item-container'
style = { pollsStyles.pollItemContainer as ViewStyle }>
{ showResults
? <PollResults
Expand Down
18 changes: 16 additions & 2 deletions react/features/polls/components/native/PollResults.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,12 @@ const PollResults = (props: AbstractProps) => {
/* eslint-disable react/jsx-no-bind */
return (
<View>
<Text style = { dialogStyles.questionText as TextStyle } >{ question }</Text>
<Text style = { dialogStyles.questionOwnerText as TextStyle } >
<Text
id = 'question-text'
style = { dialogStyles.questionText as TextStyle } >{ question }</Text>
<Text
id = 'poll-owner-text'
style = { dialogStyles.questionOwnerText as TextStyle } >
{ t('polls.by', { name: creatorName }) }
</Text>
<FlatList
Expand All @@ -102,6 +106,11 @@ const PollResults = (props: AbstractProps) => {
renderItem = { answer => renderRow(answer.item) } />
<View style = { pollsStyles.bottomLinks as ViewStyle }>
<Button
id = {
showDetails
? t('polls.results.hideDetailedResults')
: t('polls.results.showDetailedResults')
}
labelKey = {
showDetails
? 'polls.results.hideDetailedResults'
Expand All @@ -111,6 +120,11 @@ const PollResults = (props: AbstractProps) => {
onClick = { toggleIsDetailed }
type = { BUTTON_TYPES.TERTIARY } />
<Button
id = {
haveVoted
? t('polls.results.changeVote')
: t('polls.results.vote')
}
labelKey = {
haveVoted
? 'polls.results.changeVote'
Expand Down
4 changes: 3 additions & 1 deletion react/features/polls/components/native/PollsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ const PollsList = ({ setCreateMode }: IPollListProps) => {
color = { BaseTheme.palette.icon03 }
size = { 160 }
src = { IconMessage } />
<Text style = { pollsStyles.noPollText as TextStyle } >
<Text
id = 'no-polls-text'
style = { pollsStyles.noPollText as TextStyle } >
{
t('polls.results.empty')
}
Expand Down
1 change: 1 addition & 0 deletions react/features/polls/components/native/PollsPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const PollsPane = (props: AbstractProps) => {
<PollsList setCreateMode = { setCreateMode } />
<Button
accessibilityLabel = 'polls.create.create'
id = { t('polls.create.create') }
labelKey = 'polls.create.create'
onClick = { onCreate }
style = { createPollButtonStyles }
Expand Down

0 comments on commit 3fb954e

Please sign in to comment.