From ac7574ca79dbac65b4f3f19f6d93e6ca67231126 Mon Sep 17 00:00:00 2001 From: Saad Tarhi Date: Tue, 15 Aug 2023 22:58:31 +0100 Subject: [PATCH] Complete the place order test cases --- ...ace-order.block_theme.side_effects.spec.ts | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/tests/e2e/tests/checkout/checkout-block-place-order.block_theme.side_effects.spec.ts b/tests/e2e/tests/checkout/checkout-block-place-order.block_theme.side_effects.spec.ts index 486f2256635..cc9905964f9 100644 --- a/tests/e2e/tests/checkout/checkout-block-place-order.block_theme.side_effects.spec.ts +++ b/tests/e2e/tests/checkout/checkout-block-place-order.block_theme.side_effects.spec.ts @@ -19,14 +19,21 @@ const test = base.extend< { pageObject: CheckoutPage } >( { } ); test.describe( 'Shopper → Checkout block → Place Order', () => { - test.beforeEach( async ( { frontendUtils } ) => { + test( 'Guest user can place order', async ( { + pageObject, + frontendUtils, + page, + } ) => { + // We want to logout if we are logged in. + // eslint-disable-next-line playwright/no-conditional-in-test + if ( await frontendUtils.isLoggedIn() ) { + await frontendUtils.logout(); + } + await frontendUtils.emptyCart(); await frontendUtils.goToShop(); await frontendUtils.addToCart( SIMPLE_VIRTUAL_PRODUCT_NAME ); await frontendUtils.goToCheckout(); - } ); - - test( 'Guest user can place order', async ( { pageObject, page } ) => { await pageObject.fillInCheckoutWithTestData(); await pageObject.placeOrder(); await expect( @@ -36,8 +43,14 @@ test.describe( 'Shopper → Checkout block → Place Order', () => { test( 'Logged in user can place an order', async ( { pageObject, + frontendUtils, page, } ) => { + await frontendUtils.login(); + await frontendUtils.emptyCart(); + await frontendUtils.goToShop(); + await frontendUtils.addToCart( SIMPLE_VIRTUAL_PRODUCT_NAME ); + await frontendUtils.goToCheckout(); await pageObject.fillInCheckoutWithTestData(); await pageObject.placeOrder(); await expect(