-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Broaden billing field queries from form-scoped to document-scoped (#1…
…0134) Co-authored-by: Timur Karimov <[email protected]>
- Loading branch information
Showing
4 changed files
with
28 additions
and
16 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: minor | ||
Type: fix | ||
|
||
Broaden billing field queries from form-scoped to document-scoped |
This file contains 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 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 |
---|---|---|
|
@@ -36,6 +36,7 @@ function buildForm( fields ) { | |
input.value = field.value; | ||
form.appendChild( input ); | ||
} ); | ||
document.body.appendChild( form ); | ||
return form; | ||
} | ||
|
||
|
@@ -57,6 +58,11 @@ describe( 'UPE checkout utils', () => { | |
} ); | ||
|
||
beforeEach( () => { | ||
const existingCheckoutForm = document.querySelector( 'form' ); | ||
if ( existingCheckoutForm ) { | ||
existingCheckoutForm.remove(); | ||
} | ||
|
||
getUPEConfig.mockImplementation( ( argument ) => { | ||
if ( argument === 'enabledBillingFields' ) { | ||
return { | ||
|
@@ -99,7 +105,7 @@ describe( 'UPE checkout utils', () => { | |
} ); | ||
|
||
it( 'should return false when the billing information is not missing', () => { | ||
const form = buildForm( [ | ||
buildForm( [ | ||
{ id: 'billing_first_name', value: 'Test' }, | ||
{ id: 'billing_last_name', value: 'User' }, | ||
{ id: 'billing_email', value: '[email protected]' }, | ||
|
@@ -108,11 +114,11 @@ describe( 'UPE checkout utils', () => { | |
{ id: 'billing_city', value: 'Anytown' }, | ||
{ id: 'billing_postcode', value: '12345' }, | ||
] ); | ||
expect( isBillingInformationMissing( form ) ).toBe( false ); | ||
expect( isBillingInformationMissing() ).toBe( false ); | ||
} ); | ||
|
||
it( 'should return true when the billing information is missing', () => { | ||
const form = buildForm( [ | ||
buildForm( [ | ||
{ id: 'billing_first_name', value: 'Test' }, | ||
{ id: 'billing_last_name', value: 'User' }, | ||
{ id: 'billing_email', value: '[email protected]' }, | ||
|
@@ -121,11 +127,11 @@ describe( 'UPE checkout utils', () => { | |
{ id: 'billing_city', value: 'Anytown' }, | ||
{ id: 'billing_postcode', value: '' }, | ||
] ); | ||
expect( isBillingInformationMissing( form ) ).toBe( true ); | ||
expect( isBillingInformationMissing() ).toBe( true ); | ||
} ); | ||
|
||
it( 'should use the defaults when there is no specific locale data for a country', () => { | ||
const form = buildForm( [ | ||
buildForm( [ | ||
{ id: 'billing_first_name', value: 'Test' }, | ||
{ id: 'billing_last_name', value: 'User' }, | ||
{ id: 'billing_email', value: '[email protected]' }, | ||
|
@@ -134,11 +140,11 @@ describe( 'UPE checkout utils', () => { | |
{ id: 'billing_city', value: 'Anytown' }, | ||
{ id: 'billing_postcode', value: '' }, | ||
] ); | ||
expect( isBillingInformationMissing( form ) ).toBe( true ); | ||
expect( isBillingInformationMissing() ).toBe( true ); | ||
} ); | ||
|
||
it( 'should return false when the locale data for a country has no required fields', () => { | ||
const form = buildForm( [ | ||
buildForm( [ | ||
{ id: 'billing_first_name', value: 'Test' }, | ||
{ id: 'billing_last_name', value: 'User' }, | ||
{ id: 'billing_email', value: '[email protected]' }, | ||
|
@@ -147,7 +153,7 @@ describe( 'UPE checkout utils', () => { | |
{ id: 'billing_city', value: 'Anytown' }, | ||
{ id: 'billing_postcode', value: '' }, | ||
] ); | ||
expect( isBillingInformationMissing( form ) ).toBe( true ); | ||
expect( isBillingInformationMissing() ).toBe( true ); | ||
} ); | ||
} ); | ||
|
||
|
This file contains 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