Skip to content

Commit

Permalink
LG-11082 Add Conditional Text To FullAddressSearch Component (#9331)
Browse files Browse the repository at this point in the history
* Add conditional text to view

* add new tests

* Add period to display text

* package version increase from 3.1.0 to 3.1.1

* fix linter errors

* changelog: Upcoming feature, USPS Full Address Search, Added conditional logic to display/hide text on the Find a participating Post Office view that will display in Help Center only
  • Loading branch information
gina-yamada committed Oct 10, 2023
1 parent a3e45a7 commit 214b400
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,51 @@ describe('FullAddressSearch', () => {
});
});

context('Address Search Label Text', () => {
it('does not render when handleLocationSelect is not null', async () => {
const handleLocationsFound = sandbox.stub();
const onSelect = sinon.stub();
const { queryByText } = render(
<SWRConfig value={{ provider: () => new Map() }}>
<FullAddressSearch
usStatesTerritories={usStatesTerritories}
onFoundLocations={handleLocationsFound}
locationsURL={locationsURL}
registerField={() => undefined}
handleLocationSelect={onSelect}
disabled={false}
/>
</SWRConfig>,
);

const searchLabel = await queryByText(
'in_person_proofing.headings.po_search.address_search_label',
);
expect(searchLabel).to.be.empty;
});

it('renders when handleLocationSelect is null', async () => {
const handleLocationsFound = sandbox.stub();
const { queryByText } = render(
<SWRConfig value={{ provider: () => new Map() }}>
<FullAddressSearch
usStatesTerritories={usStatesTerritories}
onFoundLocations={handleLocationsFound}
locationsURL={locationsURL}
registerField={() => undefined}
handleLocationSelect={null}
disabled={false}
/>
</SWRConfig>,
);

const searchLabel = await queryByText(
'in_person_proofing.body.location.po_search.address_search_label',
);
expect(searchLabel).to.exist();
});
});

context('validates form', () => {
it('displays an error for all required fields when input is empty', async () => {
const handleLocationsFound = sandbox.stub();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ function FullAddressSearch({
{t('idv.failure.exceptions.post_office_search_error')}
</Alert>
)}
{handleLocationSelect && (
{handleLocationSelect ? (
<>
<PageHeading>{t('in_person_proofing.headings.po_search.location')}</PageHeading>
<p>{t('in_person_proofing.body.location.po_search.po_search_about')}</p>
</>
) : (
<p>{t('in_person_proofing.body.location.po_search.address_search_label')}</p>
)}
<FullAddressSearchInput
usStatesTerritories={usStatesTerritories}
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/packages/address-search/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@18f/identity-address-search",
"version": "3.1.0",
"version": "3.1.1",
"type": "module",
"private": false,
"files": [
Expand Down
2 changes: 1 addition & 1 deletion config/locales/in_person_proofing/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ en:
po_search:
address_label: Address
address_search_hint: 'Example: 1234 N Example St., Allentown, PA 12345'
address_search_label: Enter an address to find a Post Office near you
address_search_label: Enter an address to find a Post Office near you.
city_label: City
is_searching_message: Searching for Post Office locations…
none_found: Sorry, there are no participating Post Offices within 50 miles of
Expand Down
2 changes: 1 addition & 1 deletion config/locales/in_person_proofing/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ es:
address_label: Dirección
address_search_hint: 'Ejemplo: 1234 N Example St., Allentown, PA 12345'
address_search_label: Introduzca una dirección para encontrar una Oficina de
Correos cercana a usted
Correos cercana a usted.
city_label: Ciudad
is_searching_message: Buscando oficinas de correos…
none_found: Lo sentimos, no hay Oficinas de Correos participantes en un radio de
Expand Down

0 comments on commit 214b400

Please sign in to comment.