This repository has been archived by the owner on Feb 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shopper → Checkout → Can have different shipping and billing addresses (
#5860) * Shopper can have different shipping and billing addresses * Shopper can have different shipping and billing addresses * Shopper can have different shipping and billing addresses * Correct billing field IDs * Remove unused variable * Remove unused timeout * Remove unused commands * Activate company field using setCheckbox * Deactivate company field using unsetCheckbox * Remove obsolete command * Empty cart before and after each test * Remove obsolete import * Check billing and shipping company * Remove manual code with unsetCheckbox * Fill company if field exist * Get checkbox ID from label * Remove duplicate company field toFill method Co-authored-by: Saad Tarhi <[email protected]> Co-authored-by: Saad Tarhi <[email protected]>
- Loading branch information
1 parent
97778a6
commit a0ffa4b
Showing
6 changed files
with
192 additions
and
80 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 |
---|---|---|
|
@@ -39,24 +39,25 @@ | |
"lastname": "Doe", | ||
"company": "Automattic", | ||
"country": "United States (US)", | ||
"addressfirstline": "addr 1", | ||
"addresssecondline": "addr 2", | ||
"addressfirstline": "123 Main Road", | ||
"addresssecondline": "Unit 23", | ||
"city": "San Francisco", | ||
"state": "CA", | ||
"postcode": "94107", | ||
"phone": "123456789", | ||
"email": "[email protected]" | ||
}, | ||
"shipping": { | ||
"firstname": "John", | ||
"firstname": "Jane", | ||
"lastname": "Doe", | ||
"company": "Automattic", | ||
"company": "WooCommerce", | ||
"country": "United States (US)", | ||
"addressfirstline": "addr 1", | ||
"addresssecondline": "addr 2", | ||
"city": "San Francisco", | ||
"addressfirstline": "123 Main Avenue", | ||
"addresssecondline": "Unit 42", | ||
"city": "Los Angeles", | ||
"state": "CA", | ||
"postcode": "94107" | ||
"postcode": "90010", | ||
"phone": "987654321" | ||
} | ||
} | ||
} | ||
|
83 changes: 83 additions & 0 deletions
83
tests/e2e/specs/shopper/checkout-different-addresses.test.js
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,83 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { | ||
merchant, | ||
openDocumentSettingsSidebar, | ||
setCheckbox, | ||
unsetCheckbox, | ||
} from '@woocommerce/e2e-utils'; | ||
|
||
import { | ||
visitBlockPage, | ||
selectBlockByName, | ||
saveOrPublish, | ||
} from '@woocommerce/blocks-test-utils'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { | ||
shopper, | ||
preventCompatibilityNotice, | ||
reactivateCompatibilityNotice, | ||
} from '../../../utils'; | ||
|
||
import { BILLING_DETAILS, SHIPPING_DETAILS } from '../../../utils/constants'; | ||
const SIMPLE_PRODUCT_NAME = '128GB USB Stick'; | ||
|
||
if ( process.env.WOOCOMMERCE_BLOCKS_PHASE < 2 ) | ||
// eslint-disable-next-line jest/no-focused-tests | ||
test.only( 'Skipping Checkout tests', () => {} ); | ||
|
||
let companyCheckboxId = null; | ||
|
||
describe( 'Shopper → Checkout → Can have different shipping and billing addresses', () => { | ||
beforeAll( async () => { | ||
await preventCompatibilityNotice(); | ||
await merchant.login(); | ||
await visitBlockPage( 'Checkout Block' ); | ||
await openDocumentSettingsSidebar(); | ||
await selectBlockByName( | ||
'woocommerce/checkout-shipping-address-block' | ||
); | ||
|
||
// This checkbox ID is unstable, so, we're getting its value from "for" attribute of the label | ||
const [ companyCheckboxLabel ] = await page.$x( | ||
`//label[contains(text(), "Company") and contains(@class, "components-toggle-control__label")]` | ||
); | ||
companyCheckboxId = await page.evaluate( | ||
( label ) => `#${ label.getAttribute( 'for' ) }`, | ||
companyCheckboxLabel | ||
); | ||
|
||
await setCheckbox( companyCheckboxId ); | ||
await saveOrPublish(); | ||
await shopper.block.emptyCart(); | ||
} ); | ||
|
||
afterAll( async () => { | ||
await shopper.block.emptyCart(); | ||
await visitBlockPage( 'Checkout Block' ); | ||
await openDocumentSettingsSidebar(); | ||
await selectBlockByName( | ||
'woocommerce/checkout-shipping-address-block' | ||
); | ||
await unsetCheckbox( companyCheckboxId ); | ||
await saveOrPublish(); | ||
await merchant.logout(); | ||
await reactivateCompatibilityNotice(); | ||
} ); | ||
|
||
it( 'allows customer to have different shipping and billing addresses', async () => { | ||
await shopper.goToShop(); | ||
await shopper.addToCartFromShopPage( SIMPLE_PRODUCT_NAME ); | ||
await shopper.block.goToCheckout(); | ||
await unsetCheckbox( '#checkbox-control-0' ); | ||
await shopper.block.fillShippingDetails( SHIPPING_DETAILS ); | ||
await shopper.block.fillBillingDetails( BILLING_DETAILS ); | ||
await shopper.block.placeOrder(); | ||
await shopper.block.verifyShippingDetails( SHIPPING_DETAILS ); | ||
await shopper.block.verifyBillingDetails( BILLING_DETAILS ); | ||
} ); | ||
} ); |
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,18 @@ | ||
/* global localStorage */ | ||
/* eslint-disable no-unused-expressions */ | ||
|
||
export async function preventCompatibilityNotice() { | ||
await page.evaluate( () => { | ||
localStorage.setItem( | ||
'wc-blocks_dismissed_compatibility_notices', | ||
'["checkout"]' | ||
); | ||
} ); | ||
} | ||
|
||
export async function reactivateCompatibilityNotice() { | ||
await page.evaluate( () => { | ||
localStorage.removeItem( 'wc-blocks_dismissed_compatibility_notices' ); | ||
} ); | ||
} | ||
4; |
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
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