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:
commit
d950a3298e
|
@ -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",
|
||||
|
|
|
@ -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
|
||||
};
|
||||
|
|
|
@ -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;
|
|
@ -0,0 +1,6 @@
|
|||
/*
|
||||
* Internal dependencies
|
||||
*/
|
||||
const { runAddShippingClassesTest } = require( '@woocommerce/e2e-core-tests' );
|
||||
|
||||
runAddShippingClassesTest();
|
Loading…
Reference in New Issue