Add e2e tests for virtual orders (#45824)

* Add e2e tests for virtual orders and refactor test names

* Add changefile(s) from automation for the following project(s): woocommerce-blocks

* Optimise setup and teardown

---------

Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
Niels Lange 2024-03-27 21:28:54 +07:00 committed by GitHub
parent 89bbebe6b8
commit 5cde8c5efe
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 92 additions and 6 deletions

View File

@ -105,7 +105,7 @@ test.describe( 'Shopper → Account (guest user)', () => {
} );
} );
test.describe( 'shopper → Local pickup', () => {
test.describe( 'Shopper → Local pickup', () => {
test.beforeEach( async ( { admin } ) => {
// Enable local pickup.
await admin.visitAdminPage(
@ -204,7 +204,7 @@ test.describe( 'shopper → Local pickup', () => {
} );
} );
test.describe( 'Payment Methods', () => {
test.describe( 'Shopper → Payment Methods', () => {
test( 'User can change payment methods', async ( {
frontendUtils,
page,
@ -228,7 +228,7 @@ test.describe( 'Payment Methods', () => {
} );
} );
test.describe( 'Shipping and Billing Addresses', () => {
test.describe( 'Shopper → Shipping and Billing Addresses', () => {
const billingTestData = {
firstname: 'John',
lastname: 'Doe',
@ -333,7 +333,7 @@ test.describe( 'Shipping and Billing Addresses', () => {
} );
} );
test.describe( 'Shopper → Checkout block → Shipping (customer user)', () => {
test.describe( 'Shopper → Shipping (customer user)', () => {
test.use( { storageState: customerFile } );
test( 'Shopper can choose free shipping, flat rate shipping, and can have different billing and shipping addresses', async ( {
@ -406,7 +406,7 @@ test.describe( 'Shopper → Checkout block → Shipping (customer user)', () =>
} );
} );
test.describe( 'Shopper → Checkout block → Place Order (guest user)', () => {
test.describe( 'Shopper → Place Guest Order', () => {
test.use( { storageState: guestFile } );
test( 'Guest user can place order', async ( {
@ -432,7 +432,89 @@ test.describe( 'Shopper → Checkout block → Place Order (guest user)', () =>
} );
} );
test.describe( 'Checkout Form Errors (guest user)', () => {
test.describe( 'Shopper → Place Virtual Order', () => {
test.beforeAll( async ( { requestUtils } ) => {
await requestUtils.rest( {
method: 'PUT',
path: 'wc/v3/settings/general/woocommerce_ship_to_countries',
data: { value: 'disabled' },
} );
} );
test.afterAll( async ( { requestUtils } ) => {
await requestUtils.rest( {
method: 'PUT',
path: 'wc/v3/settings/general/woocommerce_ship_to_countries',
data: { value: 'all' },
} );
} );
test( 'can place a digital order when shipping is disabled', async ( {
checkoutPageObject,
frontendUtils,
localPickupUtils,
page,
} ) => {
await localPickupUtils.disableLocalPickup();
await frontendUtils.emptyCart();
await frontendUtils.goToShop();
await frontendUtils.addToCart( SIMPLE_PHYSICAL_PRODUCT_NAME );
await frontendUtils.goToCart();
await expect(
page.getByText( 'Shipping', { exact: true } )
).toBeHidden();
await frontendUtils.goToCheckout();
await expect(
page.getByText( 'Shipping', { exact: true } )
).toBeHidden();
await checkoutPageObject.fillInCheckoutWithTestData();
await checkoutPageObject.placeOrder();
await expect(
page.getByText( 'Thank you. Your order has been received.' )
).toBeVisible();
await localPickupUtils.enableLocalPickup();
} );
test( 'can place a digital order when shipping is disabled, but Local Pickup is still enabled', async ( {
checkoutPageObject,
frontendUtils,
localPickupUtils,
page,
} ) => {
await localPickupUtils.enableLocalPickup();
await frontendUtils.emptyCart();
await frontendUtils.goToShop();
await frontendUtils.addToCart( SIMPLE_PHYSICAL_PRODUCT_NAME );
await frontendUtils.goToCart();
await expect(
page.getByText( 'Shipping', { exact: true } )
).toBeHidden();
await frontendUtils.goToCheckout();
await expect(
page.getByText( 'Shipping', { exact: true } )
).toBeHidden();
await checkoutPageObject.fillInCheckoutWithTestData();
await checkoutPageObject.placeOrder();
await expect(
page.getByText( 'Thank you. Your order has been received.' )
).toBeVisible();
} );
} );
test.describe( 'Shopper → Checkout Form Errors (guest user)', () => {
test.use( { storageState: guestFile } );
test( 'can see errors when form is incomplete', async ( {

View File

@ -0,0 +1,4 @@
Significance: patch
Type: add
Add e2e tests for virtual orders