Shopper can choose shipping option (https://github.com/woocommerce/woocommerce-blocks/pull/5844)
This commit is contained in:
parent
22e206d00a
commit
d9dd7a0df6
|
@ -18,5 +18,6 @@ wp rewrite flush
|
|||
wp core version --extra
|
||||
wp plugin list
|
||||
wp theme activate storefront
|
||||
wp wc customer update 1 --user=1 --billing='{"first_name":"John","last_name":"Doe","company":"Automattic","country":"US","address_1":"addr 1","address_2":"addr 2","city":"San Francisco","state":"CA","postcode":"94107","phone":"123456789"}' --shipping='{"first_name":"John","last_name":"Doe","company":"Automattic","country":"US","address_1":"addr 1","address_2":"addr 2","city":"San Francisco","state":"CA","postcode":"94107","phone":"123456789"}'
|
||||
|
||||
exit $EXIT_CODE
|
||||
|
|
|
@ -344,6 +344,30 @@ const Shipping = () => [
|
|||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'US',
|
||||
locations: [
|
||||
{
|
||||
code: 'US',
|
||||
},
|
||||
],
|
||||
methods: [
|
||||
{
|
||||
method_id: 'flat_rate',
|
||||
settings: {
|
||||
title: 'Normal Shipping',
|
||||
cost: '20.00',
|
||||
},
|
||||
},
|
||||
{
|
||||
method_id: 'free_shipping',
|
||||
settings: {
|
||||
title: 'Free Shipping',
|
||||
cost: '00.00',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
import { merchant } from '@woocommerce/e2e-utils';
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
import { shopper } from '../../../utils';
|
||||
|
||||
const productName = '128GB USB Stick';
|
||||
const freeShippingName = 'Free Shipping';
|
||||
const freeShippingPrice = '$0.00';
|
||||
const normalShippingName = 'Normal Shipping';
|
||||
const normalShippingPrice = '$20.00';
|
||||
|
||||
if ( process.env.WOOCOMMERCE_BLOCKS_PHASE < 2 )
|
||||
// eslint-disable-next-line jest/no-focused-tests
|
||||
test.only( 'Skipping Checkout tests', () => {} );
|
||||
|
||||
describe( `Shopper → Checkout → Can choose shipping option`, () => {
|
||||
beforeAll( async () => {
|
||||
await merchant.login();
|
||||
} );
|
||||
|
||||
afterAll( async () => {
|
||||
await merchant.logout();
|
||||
} );
|
||||
|
||||
it( 'allows customer to choose free shipping', async () => {
|
||||
await shopper.goToShop();
|
||||
await shopper.addToCartFromShopPage( productName );
|
||||
await shopper.block.goToCheckout();
|
||||
await shopper.block.selectAndVerifyShippingOption(
|
||||
freeShippingName,
|
||||
freeShippingPrice
|
||||
);
|
||||
await shopper.block.placeOrder();
|
||||
await page.waitForTimeout( 2000 );
|
||||
await expect( page ).toMatch( 'Order received' );
|
||||
await expect( page ).toMatch( freeShippingName );
|
||||
} );
|
||||
|
||||
it( 'allows customer to choose flat rate shipping', async () => {
|
||||
await shopper.goToShop();
|
||||
await shopper.addToCartFromShopPage( productName );
|
||||
await shopper.block.goToCheckout();
|
||||
await shopper.block.selectAndVerifyShippingOption(
|
||||
normalShippingName,
|
||||
normalShippingPrice
|
||||
);
|
||||
await shopper.block.placeOrder();
|
||||
await page.waitForTimeout( 2000 );
|
||||
await expect( page ).toMatch( 'Order received' );
|
||||
await expect( page ).toMatch( normalShippingName );
|
||||
} );
|
||||
} );
|
|
@ -274,5 +274,24 @@ export const shopper = {
|
|||
page.waitForNavigation( { waitUntil: 'networkidle0' } ),
|
||||
] );
|
||||
},
|
||||
|
||||
selectAndVerifyShippingOption: async (
|
||||
shippingName,
|
||||
shippingPrice
|
||||
) => {
|
||||
await expect( page ).toClick(
|
||||
'.wc-block-components-radio-control__label',
|
||||
{
|
||||
text: shippingName,
|
||||
}
|
||||
);
|
||||
await page.waitForTimeout( 1000 );
|
||||
await expect( page ).toMatchElement(
|
||||
'.wc-block-components-totals-shipping .wc-block-formatted-money-amount',
|
||||
{
|
||||
text: shippingPrice,
|
||||
}
|
||||
);
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue