-
Notifications
You must be signed in to change notification settings - Fork 166
LG-10302: Change Address Search i18n lib #9109
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,11 @@ | ||
| import { render } from '@testing-library/react'; | ||
| import userEvent from '@testing-library/user-event'; | ||
| import { I18n } from '@18f/identity-i18n'; | ||
| import { i18n } from '@18f/identity-i18n'; | ||
| import { setupServer } from 'msw/node'; | ||
| import type { SetupServer } from 'msw/node'; | ||
| import { rest } from 'msw'; | ||
| import { SWRConfig } from 'swr'; | ||
| import { I18nContext } from '@18f/identity-react-i18n'; | ||
| import { usePropertyValue } from '@18f/identity-test-helpers'; | ||
| import { ComponentType } from 'react'; | ||
| import { InPersonContext } from '../context'; | ||
| import InPersonLocationFullAddressEntryPostOfficeSearchStep from './in-person-location-full-address-entry-post-office-search-step'; | ||
|
|
@@ -243,21 +243,16 @@ describe('InPersonLocationFullAddressEntryPostOfficeSearchStep', () => { | |
| await findAllByText('in_person_proofing.body.location.location_button'); | ||
| }); | ||
|
|
||
| it('displays correct pluralization for a single location result', async () => { | ||
| const { findByLabelText, findByText } = render( | ||
| <I18nContext.Provider | ||
| value={ | ||
| new I18n({ | ||
| strings: { | ||
| 'in_person_proofing.body.location.po_search.results_description': { | ||
| one: 'There is one participating Post Office within 50 miles of %{address}.', | ||
| other: | ||
| 'There are %{count} participating Post Offices within 50 miles of %{address}.', | ||
| }, | ||
| }, | ||
| }) | ||
| } | ||
| > | ||
| context('pluralized and singularized translations are set', () => { | ||
| usePropertyValue(i18n, 'strings', { | ||
| 'in_person_proofing.body.location.po_search.results_description': { | ||
| one: 'There is one participating Post Office within 50 miles of %{address}.', | ||
| other: 'There are %{count} participating Post Offices within 50 miles of %{address}.', | ||
| }, | ||
| }); | ||
|
Comment on lines
-248
to
+252
Contributor
Author
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. Because we aren't using the Provider to set the translation values, we instead override the locale data in the |
||
|
|
||
| it('displays correct pluralization for a single location result', async () => { | ||
| const { findByLabelText, findByText } = render( | ||
| <InPersonContext.Provider | ||
| value={{ | ||
| inPersonOutageMessageEnabled: false, | ||
|
|
@@ -267,58 +262,43 @@ describe('InPersonLocationFullAddressEntryPostOfficeSearchStep', () => { | |
| }} | ||
| > | ||
| <InPersonLocationFullAddressEntryPostOfficeSearchStep {...DEFAULT_PROPS} />, | ||
| </InPersonContext.Provider> | ||
| , | ||
| </I18nContext.Provider>, | ||
| { wrapper }, | ||
| ); | ||
| await userEvent.type( | ||
| await findByLabelText('in_person_proofing.body.location.po_search.address_label'), | ||
| '222 Merchandise Mart Plaza', | ||
| ); | ||
| await userEvent.type( | ||
| await findByLabelText('in_person_proofing.body.location.po_search.city_label'), | ||
| 'Endeavor', | ||
| ); | ||
| await userEvent.selectOptions( | ||
| await findByLabelText('in_person_proofing.body.location.po_search.state_label'), | ||
| 'DE', | ||
| ); | ||
| await userEvent.type( | ||
| await findByLabelText('in_person_proofing.body.location.po_search.zipcode_label'), | ||
| '19701', | ||
| ); | ||
| await userEvent.click( | ||
| await findByText('in_person_proofing.body.location.po_search.search_button'), | ||
| ); | ||
| await userEvent.click( | ||
| await findByText('in_person_proofing.body.location.po_search.search_button'), | ||
| ); | ||
| </InPersonContext.Provider>, | ||
| { wrapper }, | ||
| ); | ||
| await userEvent.type( | ||
| await findByLabelText('in_person_proofing.body.location.po_search.address_label'), | ||
| '222 Merchandise Mart Plaza', | ||
| ); | ||
| await userEvent.type( | ||
| await findByLabelText('in_person_proofing.body.location.po_search.city_label'), | ||
| 'Endeavor', | ||
| ); | ||
| await userEvent.selectOptions( | ||
| await findByLabelText('in_person_proofing.body.location.po_search.state_label'), | ||
| 'DE', | ||
| ); | ||
| await userEvent.type( | ||
| await findByLabelText('in_person_proofing.body.location.po_search.zipcode_label'), | ||
| '19701', | ||
| ); | ||
| await userEvent.click( | ||
| await findByText('in_person_proofing.body.location.po_search.search_button'), | ||
| ); | ||
| await userEvent.click( | ||
| await findByText('in_person_proofing.body.location.po_search.search_button'), | ||
| ); | ||
|
|
||
| const addressQuery = '222 Merchandise Mart Plaza, Endeavor, DE 19701'; | ||
| const searchResultAlert = await findByText( | ||
| `There is one participating Post Office within 50 miles of ${addressQuery}.`, | ||
| ); | ||
| expect(searchResultAlert).to.exist(); | ||
| }); | ||
| const addressQuery = '222 Merchandise Mart Plaza, Endeavor, DE 19701'; | ||
| const searchResultAlert = await findByText( | ||
| `There is one participating Post Office within 50 miles of ${addressQuery}.`, | ||
| ); | ||
| expect(searchResultAlert).to.exist(); | ||
| }); | ||
|
|
||
| it('displays correct pluralization for multiple location results', async () => { | ||
| server.resetHandlers(); | ||
| server.use(rest.post(LOCATIONS_URL, (_req, res, ctx) => res(ctx.json(USPS_RESPONSE)))); | ||
| const { findByLabelText, findByText } = render( | ||
| <I18nContext.Provider | ||
| value={ | ||
| new I18n({ | ||
| strings: { | ||
| 'in_person_proofing.body.location.po_search.results_description': { | ||
| one: 'There is one participating Post Office within 50 miles of %{address}.', | ||
| other: | ||
| 'There are %{count} participating Post Offices within 50 miles of %{address}.', | ||
| }, | ||
| }, | ||
| }) | ||
| } | ||
| > | ||
| it('displays correct pluralization for multiple location results', async () => { | ||
| server.resetHandlers(); | ||
| server.use(rest.post(LOCATIONS_URL, (_req, res, ctx) => res(ctx.json(USPS_RESPONSE)))); | ||
| const { findByLabelText, findByText } = render( | ||
| <InPersonContext.Provider | ||
| value={{ | ||
| inPersonOutageMessageEnabled: false, | ||
|
|
@@ -328,40 +308,39 @@ describe('InPersonLocationFullAddressEntryPostOfficeSearchStep', () => { | |
| }} | ||
| > | ||
| <InPersonLocationFullAddressEntryPostOfficeSearchStep {...DEFAULT_PROPS} />, | ||
| </InPersonContext.Provider> | ||
| , | ||
| </I18nContext.Provider>, | ||
| { wrapper }, | ||
| ); | ||
| </InPersonContext.Provider>, | ||
| { wrapper }, | ||
| ); | ||
|
|
||
| await userEvent.type( | ||
| await findByLabelText('in_person_proofing.body.location.po_search.address_label'), | ||
| '222 Merchandise Mart Plaza', | ||
| ); | ||
| await userEvent.type( | ||
| await findByLabelText('in_person_proofing.body.location.po_search.city_label'), | ||
| 'Endeavor', | ||
| ); | ||
| await userEvent.selectOptions( | ||
| await findByLabelText('in_person_proofing.body.location.po_search.state_label'), | ||
| 'DE', | ||
| ); | ||
| await userEvent.type( | ||
| await findByLabelText('in_person_proofing.body.location.po_search.zipcode_label'), | ||
| '19701', | ||
| ); | ||
| await userEvent.click( | ||
| await findByText('in_person_proofing.body.location.po_search.search_button'), | ||
| ); | ||
| await userEvent.click( | ||
| await findByText('in_person_proofing.body.location.po_search.search_button'), | ||
| ); | ||
| await userEvent.type( | ||
| await findByLabelText('in_person_proofing.body.location.po_search.address_label'), | ||
| '222 Merchandise Mart Plaza', | ||
| ); | ||
| await userEvent.type( | ||
| await findByLabelText('in_person_proofing.body.location.po_search.city_label'), | ||
| 'Endeavor', | ||
| ); | ||
| await userEvent.selectOptions( | ||
| await findByLabelText('in_person_proofing.body.location.po_search.state_label'), | ||
| 'DE', | ||
| ); | ||
| await userEvent.type( | ||
| await findByLabelText('in_person_proofing.body.location.po_search.zipcode_label'), | ||
| '19701', | ||
| ); | ||
| await userEvent.click( | ||
| await findByText('in_person_proofing.body.location.po_search.search_button'), | ||
| ); | ||
| await userEvent.click( | ||
| await findByText('in_person_proofing.body.location.po_search.search_button'), | ||
| ); | ||
|
|
||
| const addressQuery = '222 Merchandise Mart Plaza, Endeavor, DE 19701'; | ||
| const searchResultAlert = await findByText( | ||
| `There are ${USPS_RESPONSE.length} participating Post Offices within 50 miles of ${addressQuery}.`, | ||
| ); | ||
| expect(searchResultAlert).to.exist(); | ||
| const addressQuery = '222 Merchandise Mart Plaza, Endeavor, DE 19701'; | ||
| const searchResultAlert = await findByText( | ||
| `There are ${USPS_RESPONSE.length} participating Post Offices within 50 miles of ${addressQuery}.`, | ||
| ); | ||
| expect(searchResultAlert).to.exist(); | ||
| }); | ||
| }); | ||
|
|
||
| it('allows user to select a location', async () => { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is this change expected here? I suppose it shouldn't matter much if it's already in
mainvia #9103.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.
@aduth Weird, I don't know why it appears in the diff. It's not expected because we already merged it. Maybe I branched off #9103 or something.