wip: first test in add shipping classes

This commit is contained in:
rodel 2021-03-21 05:17:37 -07:00
parent a46e889e37
commit f19f39aabb
2 changed files with 87 additions and 16 deletions

View File

@ -21,6 +21,7 @@ const runVariableProductUpdateTest = require( './shopper/front-end-variable-prod
// Merchant tests // Merchant tests
const runAddNewShippingZoneTest = require ( './merchant/wp-admin-settings-shipping-zones.test' ); 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 runCreateCouponTest = require( './merchant/wp-admin-coupon-new.test' );
const runCreateOrderTest = require( './merchant/wp-admin-order-new.test' ); const runCreateOrderTest = require( './merchant/wp-admin-order-new.test' );
const runEditOrderTest = require( './merchant/wp-admin-order-edit.test' ); const runEditOrderTest = require( './merchant/wp-admin-order-edit.test' );
@ -63,22 +64,24 @@ const runShopperTests = () => {
}; };
const runMerchantTests = () => { const runMerchantTests = () => {
runOrderSearchingTest(); runAddShippingClassesTest()
runAddNewShippingZoneTest(); // todo re-enable
runCreateCouponTest(); // runOrderSearchingTest();
runCreateOrderTest(); // runAddNewShippingZoneTest();
runEditOrderTest(); // runCreateCouponTest();
runAddSimpleProductTest(); // runCreateOrderTest();
runAddVariableProductTest(); // runEditOrderTest();
runUpdateGeneralSettingsTest(); // runAddSimpleProductTest();
runProductSettingsTest(); // runAddVariableProductTest();
runTaxSettingsTest(); // runUpdateGeneralSettingsTest();
runOrderStatusFiltersTest(); // runProductSettingsTest();
runOrderRefundTest(); // runTaxSettingsTest();
runOrderApplyCouponTest(); // runOrderStatusFiltersTest();
runProductEditDetailsTest(); // runOrderRefundTest();
runProductSearchTest(); // runOrderApplyCouponTest();
runMerchantOrdersCustomerPaymentPage(); // runProductEditDetailsTest();
// runProductSearchTest();
// runMerchantOrdersCustomerPaymentPage();
} }
const runApiTests = () => { const runApiTests = () => {

View File

@ -0,0 +1,68 @@
/* eslint-disable jest/no-export, jest/no-disabled-tests */
import faker from 'faker'
/**
* Internal dependencies
*/
const { merchant } = require('@woocommerce/e2e-utils');
/**
* Add shipping class(es) by filling up and submitting the 'Add shipping class' form
*/
const addShippingClasses = async (...shippingClasses) => {
for (const { name, slug, description } of shippingClasses) {
await expect(page).toClick('.wc-shipping-class-add')
await expect(page).toFill('.editing [data-attribute="name"]', name)
await expect(page).toFill('.editing [data-attribute="slug"]', slug)
await expect(page).toFill('.editing [data-attribute="description"]', description)
}
await expect(page).toClick('.wc-shipping-class-save')
}
/**
* Verify that the specified shipping classes were saved
*/
const verifyThatShippingClassWasSaved = async (...savedShippingClasses) => {
for (const { name, slug, description } of savedShippingClasses) {
const savedClass = await expect(page).toMatchElement('.wc-shipping-class-rows tr', { text: slug })
await expect(savedClass).toMatchElement('.wc-shipping-class-name', name)
await expect(savedClass).toMatchElement('.wc-shipping-class-slug', slug)
await expect(savedClass).toMatchElement('.wc-shipping-class-description', description)
}
}
const runAddShippingClassesTest = () => {
describe('Merchant can add a shipping class', () => {
beforeAll(async () => {
await merchant.login();
// Go to Shipping Classes page
await merchant.openSettings('shipping', 'classes');
});
// wip
it('can add a new shipping class', async () => {
const expectedShippingClasses = {
name: faker.lorem.words(),
slug: faker.lorem.slug(),
description: faker.lorem.sentence()
}
await addShippingClasses(expectedShippingClasses)
await verifyThatShippingClassWasSaved(expectedShippingClasses)
});
// it('can add multiple shipping classes at once', async () => {
// // todo
// });
// it('can automatically generate slug', async () => {
// // todo
// });
});
};
module.exports = runAddShippingClassesTest;