Skip to content

Commit

Permalink
Revert "bug/9288-KeyboardNavigationFixes (#9457)"
Browse files Browse the repository at this point in the history
This reverts commit 43bc834.
  • Loading branch information
alexandec committed Sep 17, 2024
1 parent 179845b commit 007600f
Show file tree
Hide file tree
Showing 27 changed files with 85 additions and 212 deletions.
3 changes: 1 addition & 2 deletions VAMobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"env:test": "./env/env.sh -e staging -d true -t true",
"env:uat": "./env/env.sh -d true -t false",
"env:production": "./env/env.sh -e production -d false -t false",
"postinstall": "yarn prepare && yarn patch-package",
"postinstall": "yarn prepare",
"prepare": "cd .. && husky VAMobile/.husky",
"e2e:ios-build": "yarn run bundle:ios && detox build -c ios",
"e2e:ios-test": "yarn jest:clear && detox test -c ios --cleanup --record-logs all",
Expand Down Expand Up @@ -58,7 +58,6 @@
"jsc-android": "^250231.0.0",
"lottie-react-native": "^5.1.6",
"luxon": "^3.4.4",
"patch-package": "^8.0.0",
"postinstall-postinstall": "^2.1.0",
"react": "18.3.1",
"react-content-loader": "^7.0.0",
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion VAMobile/src/components/BaseListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ const BaseListItem: FC<BaseListItemProps> = (props) => {
}

// Default role for list item is menuitem
const accessibilityRole = a11yRole || (isSwitchRow ? 'switch' : 'link')
const accessibilityRole = a11yRole || (isSwitchRow ? 'switch' : 'menuitem')

const pressableProps: PressableProps = {
onPress: onOuterPress,
Expand Down
2 changes: 1 addition & 1 deletion VAMobile/src/components/DefaultList.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ context('DefaultList', () => {
})

it('calls onPress when item is clicked', () => {
fireEvent.press(screen.getByRole('link', { name: 'another line' }))
fireEvent.press(screen.getByRole('menuitem', { name: 'another line' }))
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const PickerList: FC<PickerListProps> = ({ items, title, titleA11yLabel }) => {
decorator,
testId: testIdToUse,
a11yValue,
a11yRole: 'link',
a11yRole: 'menuitem',
a11yState,
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ context('VAModalPicker', () => {

render(<VAModalPicker {...props} />)

fireEvent.press(screen.getByRole('button'))
fireEvent.press(screen.getByRole('spinbutton'))
}

describe('when an option is selected', () => {
Expand All @@ -37,15 +37,15 @@ context('VAModalPicker', () => {
})

it('should update selected to the value of that option and select done', () => {
fireEvent.press(screen.getByRole('link', { name: 'Java' }))
fireEvent.press(screen.getByRole('menuitem', { name: 'Java' }))

fireEvent.press(screen.getByRole('button', { name: 'Done' }))

expect(selected).toEqual('java')
})

it('should not update selected to the value of that option and select cancel', async () => {
fireEvent.press(screen.getByRole('link', { name: 'JavaScript2' }))
fireEvent.press(screen.getByRole('menuitem', { name: 'JavaScript2' }))

fireEvent.press(screen.getByRole('button', { name: 'Cancel' }))

Expand All @@ -59,7 +59,7 @@ context('VAModalPicker', () => {
})

it('should render a textview for the label if present', () => {
expect(screen.getByRole('button', { name: 'Back picker Navigates to the previous page' })).toBeTruthy()
expect(screen.getByRole('spinbutton', { name: 'Back picker Navigates to the previous page' })).toBeTruthy()
expect(screen.getAllByText(/Back/).length).toBeGreaterThan(0)
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ const VAModalPicker: FC<VAModalPickerProps> = ({

const parentProps: AccessibilityProps = {
...a11yValueProp({ text: generateA11yValue(currentlySelectedOption?.label, isFocused, t) }),
accessibilityRole: 'button',
accessibilityRole: 'spinbutton',
}

const renderSelectionBox = (): ReactElement => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ context('RadioGroup', () => {
})

it('initializes correctly', () => {
expect(screen.getAllByRole('link').length).toEqual(mockOptions.length)
expect(screen.getAllByRole('radio').length).toEqual(mockOptions.length)
expect(screen.getAllByLabelText('RadioEmpty').length).toEqual(mockOptions.length - 1)
expect(screen.getAllByLabelText('RadioFilled').length).toEqual(1)
})

it('calls setSelected on press', () => {
fireEvent.press(screen.getByRole('link', { name: '2 ' }))
fireEvent.press(screen.getByRole('radio', { name: '2 ' }))
expect(setSelected).toHaveBeenCalled()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ const RadioGroup = <T,>({
: ButtonDecoratorType.RadioEmpty,
onPress: onSelectorChange,
minHeight: 64,
a11yRole: 'link',
a11yRole: 'radio',
a11yState: { selected: selected },
backgroundColor: selected ? 'listActive' : undefined,
testId: `${option.a11yLabel || option.labelKey} ${t('optionOutOfTotal', { count: index + 1, totalOptions: options.length })}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ const VASelector: FC<VASelectorProps> = ({
}

const hintProp = a11yHint ? a11yHintProp(a11yHint) : {}
const a11yRole = selectorType === SelectorType.Checkbox ? 'checkbox' : 'link'
const a11yRole = selectorType === SelectorType.Checkbox ? 'checkbox' : 'radio'
const a11yState = selectorType === SelectorType.Checkbox ? { checked: selected } : { selected }
const labelToUse = `${a11yLabel || getTranslation(labelKey, t, labelArgs)} ${error ? t('error', { error }) : ''}`

Expand Down
2 changes: 1 addition & 1 deletion VAMobile/src/components/List.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ context('List', () => {
})

it('should call onPress when one of the buttons has been clicked', () => {
fireEvent.press(screen.getByRole('link', { name: 'Hello' }))
fireEvent.press(screen.getByRole('menuitem', { name: 'Hello' }))
expect(onPressSpy).toBeCalled()
})
})
2 changes: 1 addition & 1 deletion VAMobile/src/components/MessageList.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ context('MessageList', () => {
})

it('should call onPress when one of the buttons has been clicked', () => {
fireEvent.press(screen.getByRole('link', { name: 'another line' }))
fireEvent.press(screen.getByRole('menuitem', { name: 'another line' }))
expect(onPressSpy).toBeCalled()
})

Expand Down
14 changes: 7 additions & 7 deletions VAMobile/src/components/NavigationTabBar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,38 +50,38 @@ context('NavigationTabBar', () => {
})

it('navigates when tab is pressed', () => {
fireEvent.press(screen.getByRole('link', { name: 'Home' }))
fireEvent.press(screen.getByRole('tab', { name: 'Home' }))
expect(emitSpy).toBeCalled()
})

it('navigates when tab is long pressed', async () => {
await userEvent.longPress(screen.getByRole('link', { name: 'Benefits' }))
await userEvent.longPress(screen.getByRole('tab', { name: 'Benefits' }))
expect(emitSpy).toBeCalled()
})

it('calls nav and emit spies when tab is not focused and defaultPrevented is false', () => {
emitSpy.mockReturnValue({ defaultPrevented: false })
fireEvent.press(screen.getByRole('link', { name: 'Benefits' }))
fireEvent.press(screen.getByRole('tab', { name: 'Benefits' }))
expect(emitSpy).toBeCalled()
expect(mockNavigationSpy).toBeCalled()
})

it('selects correct tab for Home route', () => {
expect(screen.getByRole('link', { name: 'Home', selected: true })).toBeTruthy()
expect(screen.getByRole('tab', { name: 'Home', selected: true })).toBeTruthy()
})

it('selects correct tab for Benefits route', () => {
renderWithRoute(1)
expect(screen.getByRole('link', { name: 'Benefits', selected: true })).toBeTruthy()
expect(screen.getByRole('tab', { name: 'Benefits', selected: true })).toBeTruthy()
})

it('selects correct tab for Health route', () => {
renderWithRoute(2)
expect(screen.getByRole('link', { name: 'Health', selected: true })).toBeTruthy()
expect(screen.getByRole('tab', { name: 'Health', selected: true })).toBeTruthy()
})

it('selects correct tab for Payments route', () => {
renderWithRoute(3)
expect(screen.getByRole('link', { name: 'Payments', selected: true })).toBeTruthy()
expect(screen.getByRole('tab', { name: 'Payments', selected: true })).toBeTruthy()
})
})
2 changes: 1 addition & 1 deletion VAMobile/src/components/NavigationTabBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const NavigationTabBar: FC<NavigationTabBarProps> = ({ state, navigation, transl
key: route.name,
onPress: (): void => onPress(route as TabBarRoute, isFocused),
onLongPress: (): void => onLongPress(route as TabBarRoute),
accessibilityRole: 'link',
accessibilityRole: 'tab',
accessibilityState: isFocused ? { selected: true } : { selected: false },
accessible: true,
}
Expand Down
8 changes: 4 additions & 4 deletions VAMobile/src/components/RadioGroupModal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ context('RadioGroupModal', () => {
})

it('renders options with roles and a11yLabels', () => {
expect(screen.getByRole('link', { name: 'Option One' })).toBeTruthy()
expect(screen.getByRole('radio', { name: 'Option One' })).toBeTruthy()
expect(screen.getByLabelText('Option One option 1 of 2')).toBeTruthy()
expect(screen.getByRole('link', { name: 'Option Two' })).toBeTruthy()
expect(screen.getByRole('radio', { name: 'Option Two' })).toBeTruthy()
expect(screen.getByLabelText('Option Two option 2 of 2')).toBeTruthy()
})

it('calls onSetOption when option is pressed', () => {
fireEvent.press(screen.getByRole('link', { name: 'Option One' }))
fireEvent.press(screen.getByRole('radio', { name: 'Option One' }))
expect(onSetSpy).toHaveBeenCalledWith('option-one')
fireEvent.press(screen.getByRole('link', { name: 'Option Two' }))
fireEvent.press(screen.getByRole('radio', { name: 'Option Two' }))
expect(onSetSpy).toHaveBeenCalledWith('option-two')
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ context('AppealDetailsScreen', () => {
...appealData,
type: 'appeal',
})
await waitFor(() => fireEvent.press(screen.getByRole('link', { name: 'Status' })))
await waitFor(() => fireEvent.press(screen.getByRole('tab', { name: 'Status' })))
await waitFor(() => expect(screen.getByRole('header', { name: 'Appeal for compensation' })).toBeTruthy())
await waitFor(() => expect(screen.getByText('Up to date as of ' + dateTime)).toBeTruthy())
await waitFor(() => expect(screen.getByText('Received')).toBeTruthy())
Expand Down Expand Up @@ -126,7 +126,7 @@ context('AppealDetailsScreen', () => {
...appealData,
type: 'appeal',
})
await waitFor(() => fireEvent.press(screen.getByRole('link', { name: 'Issues' })))
await waitFor(() => fireEvent.press(screen.getByRole('tab', { name: 'Issues' })))
await waitFor(() => expect(screen.getByRole('header', { name: 'Appeal for compensation' })).toBeTruthy())
await waitFor(() => expect(screen.getByText('Received')).toBeTruthy())
await waitFor(() => expect(screen.getByRole('header', { name: 'Currently on appeal' })).toBeTruthy())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ context('FileRequest', () => {
),
).toBeTruthy(),
)
await waitFor(() => fireEvent.press(screen.getByRole('link', { name: 'Request 1' })))
await waitFor(() => fireEvent.press(screen.getByRole('menuitem', { name: 'Request 1' })))
await waitFor(() =>
expect(mockNavigationSpy).toHaveBeenCalledWith('FileRequestDetails', {
claimID: '600156928',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,17 @@ context('UploadFile', () => {

describe('on click of the upload button', () => {
it('should display an error if the checkbox is not checked', () => {
fireEvent.press(screen.getByRole('button', { name: 'Document type picker required' }))
fireEvent.press(screen.getByRole('link', { name: 'Civilian Police Reports' }))
fireEvent.press(screen.getByRole('spinbutton', { name: 'Document type picker required' }))
fireEvent.press(screen.getByRole('menuitem', { name: 'Civilian Police Reports' }))
fireEvent.press(screen.getByRole('button', { name: 'Done' }))
fireEvent.press(screen.getByRole('button', { name: 'Submit file' }))
expect(screen.getByRole('checkbox', { name: 'Check the box to confirm the information is correct' })).toBeTruthy()
expect(mockAlertSpy).not.toHaveBeenCalled()
})

it('should bring up confirmation requirements are met', () => {
fireEvent.press(screen.getByRole('button', { name: 'Document type picker required' }))
fireEvent.press(screen.getByRole('link', { name: 'Civilian Police Reports' }))
fireEvent.press(screen.getByRole('spinbutton', { name: 'Document type picker required' }))
fireEvent.press(screen.getByRole('menuitem', { name: 'Civilian Police Reports' }))
fireEvent.press(screen.getByRole('button', { name: 'Done' }))
fireEvent.press(screen.getByLabelText('The file I uploaded is evidence for this claim. (Required) '))
fireEvent.press(screen.getByRole('button', { name: 'Submit file' }))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ context('UploadOrAddPhotos', () => {
expect(screen.getByRole('button', { name: 'Add photo' })).toBeTruthy()
expect(screen.getByText('of 10 photos')).toBeTruthy()
expect(screen.getByText('0 Bytes of 50MB')).toBeTruthy()
expect(screen.getByRole('button', { name: 'Document type (Required)' })).toBeTruthy()
expect(screen.getByRole('spinbutton', { name: 'Document type (Required)' })).toBeTruthy()
expect(screen.getByRole('checkbox')).toBeTruthy()
expect(screen.getByRole('button', { name: 'Submit file' })).toBeTruthy()
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ context('ClaimsAndAppealsListView', () => {
.mockResolvedValue(mockPayload)
await waitFor(() =>
fireEvent.press(
screen.getByRole('link', {
screen.getByRole('menuitem', {
name: 'Compensation More information needed Received October 01, 2020 Step 3 of 5: Evidence gathering, review, and decision Moved to this step on October 05, 2020',
}),
),
Expand All @@ -178,7 +178,7 @@ context('ClaimsAndAppealsListView', () => {
.mockResolvedValue(mockPayload)
await waitFor(() =>
fireEvent.press(
screen.getByRole('link', {
screen.getByRole('menuitem', {
name: 'Insurance on docket appeal Received December 22, 2020 Moved to this step on December 28, 2020',
}),
),
Expand Down
Loading

0 comments on commit 007600f

Please sign in to comment.