Merge pull request #29467 from woocommerce/e2e/e2e-merchant-settings-add-shipping-classes

E2e/e2e merchant settings add shipping classes
This commit is contained in:
Ron Rennick 2021-04-12 10:45:25 -03:00 committed by GitHub
commit d950a3298e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 85 additions and 2 deletions

View File

@ -11,7 +11,8 @@
"main": "index.js",
"dependencies": {
"@jest/globals": "^26.4.2",
"config": "3.3.3"
"config": "3.3.3",
"faker": "^5.1.0"
},
"peerDependencies": {
"@woocommerce/api": "^0.1.2",

View File

@ -24,6 +24,7 @@ const runCheckoutLoginAccountTest = require( './shopper/front-end-checkout-login
// Merchant tests
const runAddNewShippingZoneTest = require ( './merchant/wp-admin-settings-shipping-zones.test' );
const runAddShippingClassesTest = require('./merchant/wp-admin-settings-shipping-classes.test')
const runCreateCouponTest = require( './merchant/wp-admin-coupon-new.test' );
const runCreateOrderTest = require( './merchant/wp-admin-order-new.test' );
const runEditOrderTest = require( './merchant/wp-admin-order-edit.test' );
@ -71,6 +72,7 @@ const runShopperTests = () => {
};
const runMerchantTests = () => {
runAddShippingClassesTest();
runImportProductsTest();
runOrderSearchingTest();
runAddNewShippingZoneTest();
@ -137,9 +139,10 @@ module.exports = {
runAddNewShippingZoneTest,
runProductBrowseSearchSortTest,
runApiTests,
runAddShippingClassesTest,
runAnalyticsPageLoadsTest,
runCheckoutCreateAccountTest,
runImportProductsTest,
runCheckoutLoginAccountTest,
runMyAccountCreateAccountTest,
runMyAccountCreateAccountTest
};

View File

@ -0,0 +1,73 @@
/* eslint-disable jest/no-export*/
/**
* Internal dependencies
*/
const { merchant } = require('@woocommerce/e2e-utils');
const { lorem, helpers } = require('faker');
const runAddShippingClassesTest = () => {
describe('Merchant can add shipping classes', () => {
beforeAll(async () => {
await merchant.login();
// Go to Shipping Classes page
await merchant.openSettings('shipping', 'classes');
});
it('can add shipping classes', async () => {
const shippingClassSlug = {
name: lorem.words(),
slug: lorem.slug(),
description: lorem.sentence()
};
const shippingClassNoSlug = {
name: lorem.words(3),
slug: '',
description: lorem.sentence()
};
const shippingClasses = [shippingClassSlug, shippingClassNoSlug];
// Add shipping classes
for (const { name, slug, description } of shippingClasses) {
await expect(page).toClick('.wc-shipping-class-add');
await expect(page).toFill(
'.editing:last-child [data-attribute="name"]',
name
);
await expect(page).toFill(
'.editing:last-child [data-attribute="slug"]',
slug
);
await expect(page).toFill(
'.editing:last-child [data-attribute="description"]',
description
);
}
await expect(page).toClick('.wc-shipping-class-save');
// Set the expected auto-generated slug
shippingClassNoSlug.slug = helpers.slugify(
shippingClassNoSlug.name
);
// Verify that the specified shipping classes were saved
for (const { name, slug, description } of shippingClasses) {
const row = await expect(
page
).toMatchElement('.wc-shipping-class-rows tr', { text: slug });
await expect(row).toMatchElement(
'.wc-shipping-class-name',
name
);
await expect(row).toMatchElement(
'.wc-shipping-class-description',
description
);
}
});
});
};
module.exports = runAddShippingClassesTest;

View File

@ -0,0 +1,6 @@
/*
* Internal dependencies
*/
const { runAddShippingClassesTest } = require( '@woocommerce/e2e-core-tests' );
runAddShippingClassesTest();