woocommerce/tests/e2e/core-tests/specs/merchant/wp-admin-settings-shipping-...

55 lines
1.8 KiB
JavaScript
Raw Normal View History

2021-03-23 16:56:39 +00:00
/* eslint-disable jest/no-export*/
/**
* Internal dependencies
*/
const { merchant } = require('@woocommerce/e2e-utils');
2021-03-23 16:56:39 +00:00
const { lorem, helpers } = require("faker");
2021-03-21 13:07:50 +00:00
const runAddShippingClassesTest = () => {
2021-03-23 16:56:39 +00:00
describe('Merchant can add shipping classes', () => {
beforeAll(async () => {
await merchant.login();
// Go to Shipping Classes page
await merchant.openSettings('shipping', 'classes');
});
2021-03-23 16:56:39 +00:00
it('can add shipping classes', async () => {
const shippingClassSlug = {
name: lorem.words(),
slug: lorem.slug(),
description: lorem.sentence()
}
const shippingClassNoSlug = {
name: lorem.words(3),
2021-03-21 13:07:50 +00:00
slug: '',
2021-03-23 16:56:39 +00:00
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)
}
2021-03-21 13:07:50 +00:00
});
});
};
module.exports = runAddShippingClassesTest;