Update existing test to include scenarios for adjusting shipping and payment options (#45755)
* Add test for shipping methods but as commented * Update comment with issue number
This commit is contained in:
parent
3842611975
commit
1ba4bcef58
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: dev
|
||||
|
||||
E2E tests: add remaining tests to cover merchant checkout block flow / milestone
|
|
@ -10,7 +10,7 @@ const transformedCheckoutBlockSlug = transformedCheckoutBlockTitle
|
|||
const simpleProductName = 'Very Simple Product';
|
||||
const singleProductPrice = '999.00';
|
||||
|
||||
let productId;
|
||||
let productId, shippingZoneId;
|
||||
|
||||
test.describe( 'Transform Classic Checkout To Checkout Block', () => {
|
||||
test.use( { storageState: process.env.ADMINSTATE } );
|
||||
|
@ -22,6 +22,10 @@ test.describe( 'Transform Classic Checkout To Checkout Block', () => {
|
|||
consumerSecret: process.env.CONSUMER_SECRET,
|
||||
version: 'wc/v3',
|
||||
} );
|
||||
// enable COD
|
||||
await api.put( 'payment_gateways/cod', {
|
||||
enabled: true,
|
||||
} );
|
||||
// add product
|
||||
await api
|
||||
.post( 'products', {
|
||||
|
@ -32,6 +36,17 @@ test.describe( 'Transform Classic Checkout To Checkout Block', () => {
|
|||
.then( ( response ) => {
|
||||
productId = response.data.id;
|
||||
} );
|
||||
// add shipping zone and method
|
||||
await api
|
||||
.post( 'shipping/zones', {
|
||||
name: 'Shipping Zone',
|
||||
} )
|
||||
.then( ( response ) => {
|
||||
shippingZoneId = response.data.id;
|
||||
} );
|
||||
await api.post( `shipping/zones/${ shippingZoneId }/methods`, {
|
||||
method_id: 'free_shipping',
|
||||
} );
|
||||
} );
|
||||
|
||||
test.afterAll( async ( { baseURL } ) => {
|
||||
|
@ -44,11 +59,28 @@ test.describe( 'Transform Classic Checkout To Checkout Block', () => {
|
|||
await api.delete( `products/${ productId }`, {
|
||||
force: true,
|
||||
} );
|
||||
await api.put( 'payment_gateways/bacs', {
|
||||
enabled: false,
|
||||
} );
|
||||
await api.put( 'payment_gateways/cod', {
|
||||
enabled: false,
|
||||
} );
|
||||
await api.delete( `shipping/zones/${ shippingZoneId }`, {
|
||||
force: true,
|
||||
} );
|
||||
} );
|
||||
|
||||
test( 'can transform classic checkout to checkout block', async ( {
|
||||
page,
|
||||
baseURL,
|
||||
} ) => {
|
||||
const api = new wcApi( {
|
||||
url: baseURL,
|
||||
consumerKey: process.env.CONSUMER_KEY,
|
||||
consumerSecret: process.env.CONSUMER_SECRET,
|
||||
version: 'wc/v3',
|
||||
} );
|
||||
|
||||
// go to create a new page
|
||||
await page.goto( 'wp-admin/post-new.php?post_type=page' );
|
||||
|
||||
|
@ -100,6 +132,43 @@ test.describe( 'Transform Classic Checkout To Checkout Block', () => {
|
|||
page.getByText( `${ transformedCheckoutBlockTitle } is now live.` )
|
||||
).toBeVisible();
|
||||
|
||||
// add additional payment option after page creation
|
||||
await api.put( 'payment_gateways/bacs', {
|
||||
enabled: true,
|
||||
} );
|
||||
await page.reload();
|
||||
|
||||
// verify that enabled payment options are in the block
|
||||
await expect(
|
||||
page.locator(
|
||||
'#radio-control-wc-payment-method-options-bacs__label'
|
||||
)
|
||||
).toContainText( 'Direct bank transfer' );
|
||||
await expect(
|
||||
page.locator(
|
||||
'#radio-control-wc-payment-method-options-cod__label'
|
||||
)
|
||||
).toContainText( 'Cash on delivery' );
|
||||
|
||||
// add additional shipping methods after page creation
|
||||
await api.post( `shipping/zones/${ shippingZoneId }/methods`, {
|
||||
method_id: 'flat_rate',
|
||||
settings: {
|
||||
cost: '5.00',
|
||||
},
|
||||
} );
|
||||
await api.post( `shipping/zones/${ shippingZoneId }/methods`, {
|
||||
method_id: 'local_pickup',
|
||||
} );
|
||||
await page.reload();
|
||||
|
||||
// verify that added shipping methods are present
|
||||
// there is issue in blocks: #45747 unable to verify the shipping methods
|
||||
// please uncomment below when the issue is resolved
|
||||
// await expect( page.getByLabel( 'Free shipping' ) ).toBeVisible();
|
||||
// await expect( page.getByLabel( 'Local pickup' ) ).toBeVisible();
|
||||
// await expect( page.getByLabel( 'Flat rate' ) ).toBeVisible();
|
||||
|
||||
// go to frontend to verify transformed checkout block
|
||||
// before that add product to cart to be able to visit checkout page
|
||||
await page.goto( `/cart/?add-to-cart=${ productId }` );
|
||||
|
|
Loading…
Reference in New Issue