-
Notifications
You must be signed in to change notification settings - Fork 127
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
[10-10CG] Add aria-live div to Show More Facilities functionality #33786
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,6 +78,7 @@ describe('CG <FacilitySearch>', () => { | |
radioList: container.querySelector('va-radio'), | ||
searchInputError: queryByRole('alert'), | ||
moreFacilities: queryByText('Load more facilities'), | ||
ariaLiveStatus: queryByRole('status'), | ||
formNavButtons: { | ||
back: getByText('Back'), | ||
forward: getByText('Continue'), | ||
|
@@ -100,6 +101,7 @@ describe('CG <FacilitySearch>', () => { | |
expect(selectors().input).to.exist; | ||
expect(selectors().radioList).not.to.exist; | ||
expect(selectors().moreFacilities).not.to.exist; | ||
expect(selectors().ariaLiveStatus).not.to.exist; | ||
expect(queryByText(content['form-facilities-search-label'])).to.exist; | ||
expect(queryByText('(*Required)')).to.exist; | ||
}); | ||
|
@@ -138,6 +140,7 @@ describe('CG <FacilitySearch>', () => { | |
await waitFor(() => { | ||
expect(selectors().radioList).to.exist; | ||
expect(selectors().loader).to.not.exist; | ||
expect(selectors().ariaLiveStatus.textContent).to.eq(''); | ||
expect(selectors().input).to.not.have.attr('error'); | ||
sinon.assert.calledWith(mapboxStub, 'Tampa'); | ||
sinon.assert.calledWith(facilitiesStub, { | ||
|
@@ -382,7 +385,7 @@ describe('CG <FacilitySearch>', () => { | |
}); | ||
|
||
context('more facilities buttons', () => { | ||
it('successfully loads more facilities on click', async () => { | ||
it('successfully loads 1 more facility on click', async () => { | ||
const { props, mockStore } = getData({}); | ||
const { selectors, getByText, container } = subject({ | ||
props, | ||
|
@@ -405,19 +408,83 @@ describe('CG <FacilitySearch>', () => { | |
expect(selectors().loader).to.not.exist; | ||
expect(selectors().input).to.not.have.attr('error'); | ||
expect(getByText(/Showing 1-1 of 1 facilities for/)).to.exist; | ||
expect(selectors().ariaLiveStatus.textContent).to.eq(''); | ||
}); | ||
|
||
await waitFor(() => { | ||
userEvent.click(selectors().moreFacilities); | ||
expect(selectors().radioList).to.exist; | ||
expect(selectors().loader).to.exist; | ||
expect(selectors().ariaLiveStatus.textContent).to.eq(''); | ||
}); | ||
|
||
await waitFor(() => { | ||
expect(selectors().radioList).to.exist; | ||
expect(selectors().loader).to.not.exist; | ||
expect(getByText(/Showing 1-2 of 2 facilities for/)).to.exist; | ||
expect(selectors().input).to.not.have.attr('error'); | ||
expect(selectors().ariaLiveStatus.textContent).to.eq( | ||
'1 new facility loaded', | ||
); | ||
}); | ||
|
||
await waitFor(() => { | ||
sinon.assert.calledWith(mapboxStub, 'Tampa'); | ||
sinon.assert.calledWith(facilitiesStub, { | ||
lat, | ||
long, | ||
perPage, | ||
radius, | ||
page: 2, | ||
}); | ||
expect(mapboxStub.callCount).to.equal(1); | ||
// This is 3 because there is an existing bug that using submit with the va-search-input component triggers two requests | ||
// https://github.com/department-of-veterans-affairs/vets-design-system-documentation/issues/3117 | ||
expect(facilitiesStub.callCount).to.equal(3); | ||
}); | ||
}); | ||
|
||
it('successfully loads 2 more facilities on click', async () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I ended up somewhat duplicating the previous test for the different facility message texts that can show up. I started a refactor to make a reusable helper since a lot of the |
||
const { props, mockStore } = getData({}); | ||
const { selectors, getByText, container } = subject({ | ||
props, | ||
mockStore, | ||
}); | ||
|
||
mapboxStub.resolves(mapBoxSuccessResponse); | ||
facilitiesStub | ||
.onFirstCall() | ||
.resolves(mockFetchChildFacilityWithCaregiverSupportResponse); | ||
facilitiesStub.onSecondCall().resolves(mockFetchFacilitiesResponse); | ||
|
||
await waitFor(() => { | ||
inputVaSearchInput(container, 'Tampa', selectors().input); | ||
expect(selectors().loader).to.exist; | ||
}); | ||
|
||
await waitFor(() => { | ||
expect(selectors().radioList).to.exist; | ||
expect(selectors().loader).to.not.exist; | ||
expect(selectors().input).to.not.have.attr('error'); | ||
expect(getByText(/Showing 1-1 of 1 facilities for/)).to.exist; | ||
expect(selectors().ariaLiveStatus.textContent).to.eq(''); | ||
}); | ||
|
||
await waitFor(() => { | ||
userEvent.click(selectors().moreFacilities); | ||
expect(selectors().radioList).to.exist; | ||
expect(selectors().loader).to.exist; | ||
expect(selectors().ariaLiveStatus.textContent).to.eq(''); | ||
}); | ||
|
||
await waitFor(() => { | ||
expect(selectors().radioList).to.exist; | ||
expect(selectors().loader).to.not.exist; | ||
expect(getByText(/Showing 1-3 of 3 facilities for/)).to.exist; | ||
expect(selectors().input).to.not.have.attr('error'); | ||
expect(selectors().ariaLiveStatus.textContent).to.eq( | ||
'2 new facilities loaded', | ||
); | ||
}); | ||
|
||
await waitFor(() => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added helper to return either
1 new facility loaded
,x new facilities loaded
or it returns an empty string.