Skip to content

Commit

Permalink
[refactor] move all accessibility hints to single obj
Browse files Browse the repository at this point in the history
Signed-off-by: Prince Mendiratta <[email protected]>
  • Loading branch information
Prince-Mendiratta committed Mar 27, 2023
1 parent 5a6b3b3 commit c3751b7
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 46 deletions.
2 changes: 1 addition & 1 deletion src/components/LHNOptionsList/OptionRowLHN.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ const OptionRowLHN = (props) => {
<View style={contentContainerStyles}>
<View style={[styles.flexRow, styles.alignItemsCenter, styles.mw100, styles.overflowHidden]}>
<DisplayNames
accessibilityLabel={props.translate('common.chatUserDisplayNames')}
accessibilityLabel={props.translate('accessibilityHints.chatUserDisplayNames')}
fullTitle={optionItem.text}
displayNamesWithTooltips={optionItem.displayNamesWithTooltips}
tooltipEnabled
Expand Down
2 changes: 1 addition & 1 deletion src/components/OptionRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class OptionRow extends Component {
}
<View style={contentContainerStyles}>
<DisplayNames
accessibilityLabel={this.props.translate('common.chatUserDisplayNames')}
accessibilityLabel={this.props.translate('accessibilityHints.chatUserDisplayNames')}
fullTitle={this.props.option.text}
displayNamesWithTooltips={displayNamesWithTooltips}
tooltipEnabled={this.props.showTitleTooltip}
Expand Down
8 changes: 3 additions & 5 deletions src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ export default {
areYouSure: 'Are you sure?',
zipCodeExample: 'e.g. 12345, 12345-1234, 12345 1234',
websiteExample: 'e.g. https://www.expensify.com',
chatUserDisplayNames: 'Chat user display names',
},
attachmentPicker: {
cameraPermissionRequired: 'Camera access',
Expand Down Expand Up @@ -253,10 +252,7 @@ export default {
sayHello: 'Say hello!',
usePlusButton: '\n\nYou can also use the + button below to send or request money!',
},
floatingMessageCounter: {
newMessages: 'New messages',
scrollToNewestMessages: 'Scroll to newest messages',
},
newMessages: 'New messages',
reportTypingIndicator: {
isTyping: 'is typing...',
areTyping: 'are typing...',
Expand Down Expand Up @@ -1218,5 +1214,7 @@ export default {
loginForm: 'Login form',
listOfChats: 'List of chats',
workspaceName: 'Workspace name',
chatUserDisplayNames: 'Chat user display names',
scrollToNewestMessages: 'Scroll to newest messages',
},
};
8 changes: 3 additions & 5 deletions src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ export default {
areYouSure: '¿Estás seguro?',
zipCodeExample: 'p. ej. 12345, 12345-1234, 12345 1234',
websiteExample: 'p. ej. https://www.expensify.com',
chatUserDisplayNames: 'Nombres para mostrar de los usuarios de chat',
},
attachmentPicker: {
cameraPermissionRequired: 'Permiso para acceder a la cámara',
Expand Down Expand Up @@ -252,10 +251,6 @@ export default {
sayHello: '¡Saluda!',
usePlusButton: '\n\n¡También puedes usar el botón + de abajo para enviar o pedir dinero!',
},
floatingMessageCounter: {
newMessages: 'Mensajes nuevos',
scrollToNewestMessages: 'Desplácese a los mensajes más recientes',
},
reportTypingIndicator: {
isTyping: 'está escribiendo...',
areTyping: 'están escribiendo...',
Expand Down Expand Up @@ -1684,5 +1679,8 @@ export default {
loginForm: 'Formulario de inicio de sesión',
listOfChats: 'lista de charlas',
workspaceName: 'Nombre del espacio de trabajo',
chatUserDisplayNames: 'Nombres para mostrar de los usuarios de chat',
newMessages: 'Mensajes nuevos',
scrollToNewestMessages: 'Desplácese a los mensajes más recientes',
},
};
4 changes: 2 additions & 2 deletions src/pages/home/report/FloatingMessageCounter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class FloatingMessageCounter extends PureComponent {
render() {
return (
<FloatingMessageCounterContainer
accessibilityHint={this.props.translate('floatingMessageCounter.scrollToNewestMessages')}
accessibilityHint={this.props.translate('accessibilityHints.scrollToNewestMessages')}
containerStyles={[styles.floatingMessageCounterTransformation(this.translateY)]}
>
<View style={styles.floatingMessageCounter}>
Expand All @@ -88,7 +88,7 @@ class FloatingMessageCounter extends PureComponent {
styles.textWhite,
]}
>
{this.props.translate('floatingMessageCounter.newMessages')}
{this.props.translate('newMessages')}
</Text>
</View>
)}
Expand Down
18 changes: 9 additions & 9 deletions tests/ui/UnreadIndicatorsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function scrollUpToRevealNewMessagesBadge() {
* @return {Boolean}
*/
function isNewMessagesBadgeVisible() {
const hintText = Localize.translateLocal('floatingMessageCounter.scrollToNewestMessages');
const hintText = Localize.translateLocal('accessibilityHints.scrollToNewestMessages');
const badge = screen.queryByAccessibilityHint(hintText);
return Math.round(badge.props.style.transform[0].translateY) === 10;
}
Expand Down Expand Up @@ -219,7 +219,7 @@ describe('Unread Indicators', () => {
expect(optionRows).toHaveLength(1);

// And that the text is bold
const displayNameHintText = Localize.translateLocal('common.chatUserDisplayNames');
const displayNameHintText = Localize.translateLocal('accessibilityHints.chatUserDisplayNames');
const displayNameText = screen.queryByLabelText(displayNameHintText);
expect(lodashGet(displayNameText, ['props', 'style', 0, 'fontWeight'])).toBe(fontWeightBold);

Expand Down Expand Up @@ -265,7 +265,7 @@ describe('Unread Indicators', () => {
expect(isDrawerOpen()).toBe(true);

// Verify that the option row in the LHN is no longer bold (since OpenReport marked it as read)
const hintText = Localize.translateLocal('common.chatUserDisplayNames');
const hintText = Localize.translateLocal('accessibilityHints.chatUserDisplayNames');
const updatedDisplayNameText = screen.queryByLabelText(hintText);
expect(lodashGet(updatedDisplayNameText, ['props', 'style', 0, 'fontWeight'])).toBe(undefined);

Expand Down Expand Up @@ -354,7 +354,7 @@ describe('Unread Indicators', () => {
expect(optionRows).toHaveLength(2);

// Verify the text for both chats are bold indicating that nothing has not yet been read
const displayNameHintTexts = Localize.translateLocal('common.chatUserDisplayNames');
const displayNameHintTexts = Localize.translateLocal('accessibilityHints.chatUserDisplayNames');
const displayNameTexts = screen.queryAllByLabelText(displayNameHintTexts);
expect(displayNameTexts).toHaveLength(2);
const firstReportOption = displayNameTexts[0];
Expand All @@ -370,7 +370,7 @@ describe('Unread Indicators', () => {
})
.then(() => {
// Verify that report we navigated to appears in a "read" state while the original unread report still shows as unread
const hintText = Localize.translateLocal('common.chatUserDisplayNames');
const hintText = Localize.translateLocal('accessibilityHints.chatUserDisplayNames');
const displayNameTexts = screen.queryAllByLabelText(hintText);
expect(displayNameTexts).toHaveLength(2);
expect(lodashGet(displayNameTexts[0], ['props', 'style', 0, 'fontWeight'])).toBe(undefined);
Expand Down Expand Up @@ -406,7 +406,7 @@ describe('Unread Indicators', () => {
.then(navigateToSidebar)
.then(() => {
// Verify the report is marked as unread in the sidebar
const hintText = Localize.translateLocal('common.chatUserDisplayNames');
const hintText = Localize.translateLocal('accessibilityHints.chatUserDisplayNames');
const displayNameTexts = screen.queryAllByLabelText(hintText);
expect(displayNameTexts).toHaveLength(1);
expect(lodashGet(displayNameTexts[0], ['props', 'style', 0, 'fontWeight'])).toBe(fontWeightBold);
Expand All @@ -418,7 +418,7 @@ describe('Unread Indicators', () => {
.then(() => navigateToSidebar())
.then(() => {
// Verify the report is now marked as read
const hintText = Localize.translateLocal('common.chatUserDisplayNames');
const hintText = Localize.translateLocal('accessibilityHints.chatUserDisplayNames');
const displayNameTexts = screen.queryAllByLabelText(hintText);
expect(displayNameTexts).toHaveLength(1);
expect(lodashGet(displayNameTexts[0], ['props', 'style', 0, 'fontWeight'])).toBe(undefined);
Expand All @@ -442,7 +442,7 @@ describe('Unread Indicators', () => {
// Verify we are on the LHN and that the chat shows as unread in the LHN
expect(isDrawerOpen()).toBe(true);

const hintText = Localize.translateLocal('common.chatUserDisplayNames');
const hintText = Localize.translateLocal('accessibilityHints.chatUserDisplayNames');
const displayNameTexts = screen.queryAllByLabelText(hintText);
expect(displayNameTexts).toHaveLength(1);
expect(lodashGet(displayNameTexts[0], ['props', 'children'])).toBe('B User');
Expand Down Expand Up @@ -471,7 +471,7 @@ describe('Unread Indicators', () => {
// Verify we are on the LHN and that the chat shows as unread in the LHN
expect(isDrawerOpen()).toBe(true);

const hintText = Localize.translateLocal('common.chatUserDisplayNames');
const hintText = Localize.translateLocal('accessibilityHints.chatUserDisplayNames');
const displayNameTexts = screen.queryAllByLabelText(hintText);
expect(displayNameTexts).toHaveLength(1);
expect(lodashGet(displayNameTexts[0], ['props', 'children'])).toBe('B User');
Expand Down
16 changes: 8 additions & 8 deletions tests/unit/SidebarFilterTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ describe('Sidebar', () => {
.then(() => {
if (booleansWhichRemovesActiveReport.indexOf(JSON.stringify(boolArr)) > -1) {
// Only one report visible
const displayNamesHintText = Localize.translateLocal('common.chatUserDisplayNames');
const displayNamesHintText = Localize.translateLocal('accessibilityHints.chatUserDisplayNames');
const displayNames = screen.queryAllByLabelText(displayNamesHintText);
const navigatesToChatHintText = Localize.translateLocal('accessibilityHints.navigatesToChat');
expect(screen.queryAllByAccessibilityHint(navigatesToChatHintText)).toHaveLength(1);
Expand Down Expand Up @@ -344,7 +344,7 @@ describe('Sidebar', () => {

// Then the reports 1 and 2 are shown and 3 is not
.then(() => {
const hintText = Localize.translateLocal('common.chatUserDisplayNames');
const hintText = Localize.translateLocal('accessibilityHints.chatUserDisplayNames');
const displayNames = screen.queryAllByLabelText(hintText);
expect(displayNames).toHaveLength(2);
expect(lodashGet(displayNames, [0, 'props', 'children'])).toBe('One, Two');
Expand Down Expand Up @@ -410,7 +410,7 @@ describe('Sidebar', () => {

// Then both reports are visible
.then(() => {
const hintText = Localize.translateLocal('common.chatUserDisplayNames');
const hintText = Localize.translateLocal('accessibilityHints.chatUserDisplayNames');
const displayNames = screen.queryAllByLabelText(hintText);
expect(displayNames).toHaveLength(2);
expect(lodashGet(displayNames, [0, 'props', 'children'])).toBe('Three, Four');
Expand Down Expand Up @@ -459,7 +459,7 @@ describe('Sidebar', () => {

// Then neither reports are visible
.then(() => {
const hintText = Localize.translateLocal('common.chatUserDisplayNames');
const hintText = Localize.translateLocal('accessibilityHints.chatUserDisplayNames');
const displayNames = screen.queryAllByLabelText(hintText);
expect(displayNames).toHaveLength(0);
})
Expand All @@ -480,7 +480,7 @@ describe('Sidebar', () => {

// Then they are all visible
.then(() => {
const hintText = Localize.translateLocal('common.chatUserDisplayNames');
const hintText = Localize.translateLocal('accessibilityHints.chatUserDisplayNames');
const displayNames = screen.queryAllByLabelText(hintText);
expect(displayNames).toHaveLength(3);
});
Expand Down Expand Up @@ -517,7 +517,7 @@ describe('Sidebar', () => {

// Then neither reports are visible
.then(() => {
const hintText = Localize.translateLocal('common.chatUserDisplayNames');
const hintText = Localize.translateLocal('accessibilityHints.chatUserDisplayNames');
const displayNames = screen.queryAllByLabelText(hintText);
expect(displayNames).toHaveLength(0);
})
Expand All @@ -535,7 +535,7 @@ describe('Sidebar', () => {

// Then both rooms are visible
.then(() => {
const hintText = Localize.translateLocal('common.chatUserDisplayNames');
const hintText = Localize.translateLocal('accessibilityHints.chatUserDisplayNames');
const displayNames = screen.queryAllByLabelText(hintText);
expect(displayNames).toHaveLength(2);
});
Expand Down Expand Up @@ -617,7 +617,7 @@ describe('Sidebar', () => {
.then(() => {
if (booleansWhichRemovesActiveReport.indexOf(JSON.stringify(boolArr)) > -1) {
// Only one report visible
const displayNamesHintText = Localize.translateLocal('common.chatUserDisplayNames');
const displayNamesHintText = Localize.translateLocal('accessibilityHints.chatUserDisplayNames');
const displayNames = screen.queryAllByLabelText(displayNamesHintText);
const navigatesToChatHintText = Localize.translateLocal('accessibilityHints.navigatesToChat');
expect(screen.queryAllByAccessibilityHint(navigatesToChatHintText)).toHaveLength(1);
Expand Down
Loading

0 comments on commit c3751b7

Please sign in to comment.