move merchant tests to package
This commit is contained in:
parent
76f591251a
commit
72219b2323
|
@ -11,7 +11,15 @@ const {
|
|||
runCheckoutPageTest,
|
||||
runMyAccountPageTest,
|
||||
runSingleProductPageTest,
|
||||
runFrontEndTests,
|
||||
runShopperTests,
|
||||
runCreateCouponTest,
|
||||
runCreateOrderTest,
|
||||
runAddSimpleProductTest,
|
||||
runAddVariableProductTest,
|
||||
runUpdateGeneralSettingsTest,
|
||||
runProductSettingsTest,
|
||||
runTaxSettingsTest,
|
||||
runMerchantTests,
|
||||
} = require( './specs' );
|
||||
|
||||
module.exports = {
|
||||
|
@ -24,5 +32,13 @@ module.exports = {
|
|||
runCheckoutPageTest,
|
||||
runMyAccountPageTest,
|
||||
runSingleProductPageTest,
|
||||
runFrontEndTests,
|
||||
runShopperTests,
|
||||
runCreateCouponTest,
|
||||
runCreateOrderTest,
|
||||
runAddSimpleProductTest,
|
||||
runAddVariableProductTest,
|
||||
runUpdateGeneralSettingsTest,
|
||||
runProductSettingsTest,
|
||||
runTaxSettingsTest,
|
||||
runMerchantTests,
|
||||
};
|
||||
|
|
|
@ -5,10 +5,16 @@
|
|||
const runActivationTest = require( './activate-and-setup/activate.test' );
|
||||
const { runOnboardingFlowTest, runTaskListTest } = require( './activate-and-setup/onboarding-tasklist.test' );
|
||||
const runInitialStoreSettingsTest = require( './activate-and-setup/setup.test' );
|
||||
const runCartPageTest = require( './front-end/front-end-cart.test' );
|
||||
const runCheckoutPageTest = require( './front-end/front-end-checkout.test' );
|
||||
const runMyAccountPageTest = require( './front-end/front-end-my-account.test' );
|
||||
const runSingleProductPageTest = require( './front-end/front-end-single-product.test' );
|
||||
const runCartPageTest = require( './shopper/front-end-cart.test' );
|
||||
const runCheckoutPageTest = require( './shopper/front-end-checkout.test' );
|
||||
const runMyAccountPageTest = require( './shopper/front-end-my-account.test' );
|
||||
const runSingleProductPageTest = require( './shopper/front-end-single-product.test' );
|
||||
const runCreateCouponTest = require( './merchant/wp-admin-coupon-new.test' );
|
||||
const runCreateOrderTest = require( './merchant/wp-admin-order-new.test' );
|
||||
const { runAddSimpleProductTest, runAddVariableProductTest } = require( './merchant/wp-admin-product-new.test' );
|
||||
const runUpdateGeneralSettingsTest = require( './merchant/wp-admin-settings-general.test' );
|
||||
const runProductSettingsTest = require( './merchant/wp-admin-settings-product.test' );
|
||||
const runTaxSettingsTest = require( './merchant/wp-admin-settings-tax.test' );
|
||||
|
||||
const runSetupOnboardingTests = () => {
|
||||
runActivationTest();
|
||||
|
@ -17,13 +23,23 @@ const runSetupOnboardingTests = () => {
|
|||
runInitialStoreSettingsTest();
|
||||
};
|
||||
|
||||
const runFrontEndTests = () => {
|
||||
const runShopperTests = () => {
|
||||
runCartPageTest();
|
||||
runCheckoutPageTest();
|
||||
runMyAccountPageTest();
|
||||
runSingleProductPageTest();
|
||||
};
|
||||
|
||||
const runMerchantTests = () => {
|
||||
runCreateCouponTest();
|
||||
runCreateOrderTest();
|
||||
runAddSimpleProductTest();
|
||||
runAddVariableProductTest();
|
||||
runUpdateGeneralSettingsTest();
|
||||
runProductSettingsTest();
|
||||
runTaxSettingsTest();
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
runActivationTest,
|
||||
runOnboardingFlowTest,
|
||||
|
@ -34,5 +50,13 @@ module.exports = {
|
|||
runCheckoutPageTest,
|
||||
runMyAccountPageTest,
|
||||
runSingleProductPageTest,
|
||||
runFrontEndTests,
|
||||
runShopperTests,
|
||||
runCreateCouponTest,
|
||||
runCreateOrderTest,
|
||||
runAddSimpleProductTest,
|
||||
runAddVariableProductTest,
|
||||
runUpdateGeneralSettingsTest,
|
||||
runProductSettingsTest,
|
||||
runTaxSettingsTest,
|
||||
runMerchantTests,
|
||||
};
|
||||
|
|
|
@ -0,0 +1,54 @@
|
|||
/* eslint-disable jest/no-export, jest/no-disabled-tests */
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
const {
|
||||
StoreOwnerFlow,
|
||||
clickTab,
|
||||
verifyPublishAndTrash
|
||||
} = require( '@woocommerce/e2e-utils' );
|
||||
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
const {
|
||||
it,
|
||||
describe,
|
||||
beforeAll,
|
||||
} = require( '@jest/globals' );
|
||||
|
||||
const runCreateCouponTest = () => {
|
||||
describe('Add New Coupon Page', () => {
|
||||
beforeAll(async () => {
|
||||
await StoreOwnerFlow.login();
|
||||
});
|
||||
|
||||
it('can create new coupon', async () => {
|
||||
// Go to "add coupon" page
|
||||
await StoreOwnerFlow.openNewCoupon();
|
||||
|
||||
// Make sure we're on the add coupon page
|
||||
await expect(page.title()).resolves.toMatch('Add new coupon');
|
||||
|
||||
// Fill in coupon code and description
|
||||
await expect(page).toFill('#title', 'code-' + new Date().getTime().toString());
|
||||
await expect(page).toFill('#woocommerce-coupon-description', 'test coupon');
|
||||
|
||||
// Set general coupon data
|
||||
await clickTab('General');
|
||||
await expect(page).toSelect('#discount_type', 'Fixed cart discount');
|
||||
await expect(page).toFill('#coupon_amount', '100');
|
||||
|
||||
// Publish coupon, verify that it was published. Trash coupon, verify that it was trashed.
|
||||
await verifyPublishAndTrash(
|
||||
'#publish',
|
||||
'#message',
|
||||
'Coupon updated.',
|
||||
'1 coupon moved to the Trash.'
|
||||
);
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = runCreateCouponTest;
|
|
@ -0,0 +1,40 @@
|
|||
/* eslint-disable jest/no-export, jest/no-disabled-tests */
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
const {
|
||||
StoreOwnerFlow,
|
||||
verifyPublishAndTrash
|
||||
} = require( '@woocommerce/e2e-utils' );
|
||||
|
||||
const runCreateOrderTest = () => {
|
||||
describe('Add New Order Page', () => {
|
||||
beforeAll(async () => {
|
||||
await StoreOwnerFlow.login();
|
||||
});
|
||||
|
||||
it('can create new order', async () => {
|
||||
// Go to "add order" page
|
||||
await StoreOwnerFlow.openNewOrder();
|
||||
|
||||
// Make sure we're on the add order page
|
||||
await expect(page.title()).resolves.toMatch('Add new order');
|
||||
|
||||
// Set order data
|
||||
await expect(page).toSelect('#order_status', 'Processing');
|
||||
await expect(page).toFill('input[name=order_date]', '2018-12-13');
|
||||
await expect(page).toFill('input[name=order_date_hour]', '18');
|
||||
await expect(page).toFill('input[name=order_date_minute]', '55');
|
||||
|
||||
// Create order, verify that it was created. Trash order, verify that it was trashed.
|
||||
await verifyPublishAndTrash(
|
||||
'.order_actions li .save_order',
|
||||
'#message',
|
||||
'Order updated.',
|
||||
'1 order moved to the Trash.'
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = runCreateOrderTest;
|
|
@ -0,0 +1,211 @@
|
|||
/* eslint-disable jest/no-export, jest/no-disabled-tests */
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
const {
|
||||
StoreOwnerFlow,
|
||||
clickTab,
|
||||
uiUnblocked
|
||||
} = require( '@woocommerce/e2e-utils' );
|
||||
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
const {
|
||||
it,
|
||||
describe,
|
||||
beforeAll,
|
||||
} = require( '@jest/globals' );
|
||||
const config = require( 'config' );
|
||||
|
||||
const simpleProductName = config.get( 'products.simple.name' );
|
||||
|
||||
const verifyPublishAndTrash = async () => {
|
||||
// Wait for auto save
|
||||
await page.waitFor( 2000 );
|
||||
|
||||
// Publish product
|
||||
await expect( page ).toClick( '#publish' );
|
||||
await page.waitForSelector( '.updated.notice', { text: 'Product published.' } );
|
||||
|
||||
// Verify
|
||||
await expect( page ).toMatchElement( '.updated.notice', { text: 'Product published.' } );
|
||||
await page.waitForSelector( 'a', { text: 'Move to Trash' } );
|
||||
|
||||
// Trash product
|
||||
await expect( page ).toClick( 'a', { text: 'Move to Trash' } );
|
||||
await page.waitForSelector( '.updated.notice', { text: '1 product moved to the Trash.' } );
|
||||
|
||||
// Verify
|
||||
await expect( page ).toMatchElement( '.updated.notice', { text: '1 product moved to the Trash.' } );
|
||||
};
|
||||
|
||||
const runAddSimpleProductTest = () => {
|
||||
describe('Add New Simple Product Page', () => {
|
||||
beforeAll(async () => {
|
||||
await StoreOwnerFlow.login();
|
||||
});
|
||||
|
||||
it('can create simple virtual product titled "Simple Product" with regular price $9.99', async () => {
|
||||
// Go to "add product" page
|
||||
await StoreOwnerFlow.openNewProduct();
|
||||
|
||||
// Make sure we're on the add order page
|
||||
await expect(page.title()).resolves.toMatch('Add new product');
|
||||
|
||||
// Set product data
|
||||
await expect(page).toFill('#title', simpleProductName);
|
||||
await expect(page).toClick('#_virtual');
|
||||
await clickTab('General');
|
||||
await expect(page).toFill('#_regular_price', '9.99');
|
||||
|
||||
// Publish product, verify that it was published. Trash product, verify that it was trashed.
|
||||
await verifyPublishAndTrash(
|
||||
'#publish',
|
||||
'.updated.notice',
|
||||
'Product published.',
|
||||
'Move to Trash',
|
||||
'1 product moved to the Trash.'
|
||||
);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const runAddVariableProductTest = () => {
|
||||
describe.skip('Add New Variable Product Page', () => {
|
||||
it('can create product with variations', async () => {
|
||||
// Go to "add product" page
|
||||
await StoreOwnerFlow.openNewProduct();
|
||||
|
||||
// Make sure we're on the add order page
|
||||
await expect(page.title()).resolves.toMatch('Add new product');
|
||||
|
||||
// Set product data
|
||||
await expect(page).toFill('#title', 'Variable Product with Three Variations');
|
||||
await expect(page).toSelect('#product-type', 'Variable product');
|
||||
|
||||
// Create attributes for variations
|
||||
await clickTab('Attributes');
|
||||
await expect(page).toSelect('select[name="attribute_taxonomy"]', 'Custom product attribute');
|
||||
|
||||
for (let i = 0; i < 3; i++) {
|
||||
await expect(page).toClick('button.add_attribute', {text: 'Add'});
|
||||
// Wait for attribute form to load
|
||||
await uiUnblocked();
|
||||
|
||||
await page.focus(`input[name="attribute_names[${i}]"]`);
|
||||
await expect(page).toFill(`input[name="attribute_names[${i}]"]`, 'attr #' + (i + 1));
|
||||
await expect(page).toFill(`textarea[name="attribute_values[${i}]"]`, 'val1 | val2');
|
||||
await expect(page).toClick(`input[name="attribute_variation[${i}]"]`);
|
||||
}
|
||||
|
||||
await expect(page).toClick('button', {text: 'Save attributes'});
|
||||
|
||||
// Wait for attribute form to save (triggers 2 UI blocks)
|
||||
await uiUnblocked();
|
||||
await page.waitFor(1000);
|
||||
await uiUnblocked();
|
||||
|
||||
// Create variations from attributes
|
||||
await clickTab('Variations');
|
||||
await page.waitForSelector('select.variation_actions:not([disabled])');
|
||||
await page.focus('select.variation_actions');
|
||||
await expect(page).toSelect('select.variation_actions', 'Create variations from all attributes');
|
||||
|
||||
const firstDialog = await expect(page).toDisplayDialog(async () => {
|
||||
// Using this technique since toClick() isn't working.
|
||||
// See: https://github.com/GoogleChrome/puppeteer/issues/1805#issuecomment-464802876
|
||||
page.$eval('a.do_variation_action', elem => elem.click());
|
||||
});
|
||||
|
||||
expect(firstDialog.message()).toMatch('Are you sure you want to link all variations?');
|
||||
|
||||
const secondDialog = await expect(page).toDisplayDialog(async () => {
|
||||
await firstDialog.accept();
|
||||
});
|
||||
|
||||
expect(secondDialog.message()).toMatch('8 variations added');
|
||||
await secondDialog.dismiss();
|
||||
|
||||
// Set some variation data
|
||||
await uiUnblocked();
|
||||
await uiUnblocked();
|
||||
|
||||
await page.waitForSelector('.woocommerce_variation .handlediv');
|
||||
|
||||
// Verify that variations were created
|
||||
await Promise.all([
|
||||
expect(page).toMatchElement('select[name="attribute_attr-1[0]"]', {text: 'val1'}),
|
||||
expect(page).toMatchElement('select[name="attribute_attr-2[0]"]', {text: 'val1'}),
|
||||
expect(page).toMatchElement('select[name="attribute_attr-3[0]"]', {text: 'val1'}),
|
||||
|
||||
expect(page).toMatchElement('select[name="attribute_attr-1[1]"]', {text: 'val1'}),
|
||||
expect(page).toMatchElement('select[name="attribute_attr-2[1]"]', {text: 'val1'}),
|
||||
expect(page).toMatchElement('select[name="attribute_attr-3[1]"]', {text: 'val2'}),
|
||||
|
||||
expect(page).toMatchElement('select[name="attribute_attr-1[2]"]', {text: 'val1'}),
|
||||
expect(page).toMatchElement('select[name="attribute_attr-2[2]"]', {text: 'val2'}),
|
||||
expect(page).toMatchElement('select[name="attribute_attr-3[2]"]', {text: 'val1'}),
|
||||
|
||||
expect(page).toMatchElement('select[name="attribute_attr-1[3]"]', {text: 'val1'}),
|
||||
expect(page).toMatchElement('select[name="attribute_attr-2[3]"]', {text: 'val2'}),
|
||||
expect(page).toMatchElement('select[name="attribute_attr-3[3]"]', {text: 'val2'}),
|
||||
|
||||
expect(page).toMatchElement('select[name="attribute_attr-1[4]"]', {text: 'val2'}),
|
||||
expect(page).toMatchElement('select[name="attribute_attr-2[4]"]', {text: 'val1'}),
|
||||
expect(page).toMatchElement('select[name="attribute_attr-3[4]"]', {text: 'val1'}),
|
||||
|
||||
expect(page).toMatchElement('select[name="attribute_attr-1[5]"]', {text: 'val2'}),
|
||||
expect(page).toMatchElement('select[name="attribute_attr-2[5]"]', {text: 'val1'}),
|
||||
expect(page).toMatchElement('select[name="attribute_attr-3[5]"]', {text: 'val2'}),
|
||||
|
||||
expect(page).toMatchElement('select[name="attribute_attr-1[6]"]', {text: 'val2'}),
|
||||
expect(page).toMatchElement('select[name="attribute_attr-2[6]"]', {text: 'val2'}),
|
||||
expect(page).toMatchElement('select[name="attribute_attr-3[6]"]', {text: 'val1'}),
|
||||
|
||||
expect(page).toMatchElement('select[name="attribute_attr-1[7]"]', {text: 'val2'}),
|
||||
expect(page).toMatchElement('select[name="attribute_attr-2[7]"]', {text: 'val2'}),
|
||||
expect(page).toMatchElement('select[name="attribute_attr-3[7]"]', {text: 'val2'}),
|
||||
]);
|
||||
|
||||
await expect(page).toClick('.woocommerce_variation:nth-of-type(2) .handlediv');
|
||||
await page.waitFor(2000);
|
||||
await page.focus('input[name="variable_is_virtual[0]"]');
|
||||
await expect(page).toClick('input[name="variable_is_virtual[0]"]');
|
||||
await expect(page).toFill('input[name="variable_regular_price[0]"]', '9.99');
|
||||
|
||||
await expect(page).toClick('.woocommerce_variation:nth-of-type(3) .handlediv');
|
||||
await page.waitFor(2000);
|
||||
await page.focus('input[name="variable_is_virtual[1]"]');
|
||||
await expect(page).toClick('input[name="variable_is_virtual[1]"]');
|
||||
await expect(page).toFill('input[name="variable_regular_price[1]"]', '11.99');
|
||||
|
||||
await expect(page).toClick('.woocommerce_variation:nth-of-type(4) .handlediv');
|
||||
await page.waitFor(2000);
|
||||
await page.focus('input[name="variable_manage_stock[2]"]');
|
||||
await expect(page).toClick('input[name="variable_manage_stock[2]"]');
|
||||
await expect(page).toFill('input[name="variable_regular_price[2]"]', '20');
|
||||
await expect(page).toFill('input[name="variable_weight[2]"]', '200');
|
||||
await expect(page).toFill('input[name="variable_length[2]"]', '10');
|
||||
await expect(page).toFill('input[name="variable_width[2]"]', '20');
|
||||
await expect(page).toFill('input[name="variable_height[2]"]', '15');
|
||||
|
||||
await page.focus('button.save-variation-changes');
|
||||
await expect(page).toClick('button.save-variation-changes', {text: 'Save changes'});
|
||||
|
||||
// Publish product, verify that it was published. Trash product, verify that it was trashed.
|
||||
await verifyPublishAndTrash(
|
||||
'#publish',
|
||||
'.updated.notice',
|
||||
'Product published.',
|
||||
'Move to Trash',
|
||||
'1 product moved to the Trash.'
|
||||
);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
runAddSimpleProductTest,
|
||||
runAddVariableProductTest,
|
||||
};
|
|
@ -0,0 +1,84 @@
|
|||
/* eslint-disable jest/no-export, jest/no-disabled-tests */
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
const {
|
||||
StoreOwnerFlow,
|
||||
settingsPageSaveChanges,
|
||||
verifyValueOfInputField
|
||||
} = require( '@woocommerce/e2e-utils' );
|
||||
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
const {
|
||||
it,
|
||||
describe,
|
||||
beforeAll,
|
||||
} = require( '@jest/globals' );
|
||||
|
||||
const runUpdateGeneralSettingsTest = () => {
|
||||
describe('WooCommerce General Settings', () => {
|
||||
beforeAll(async () => {
|
||||
await StoreOwnerFlow.login();
|
||||
});
|
||||
|
||||
it('can update settings', async () => {
|
||||
// Go to general settings page
|
||||
await StoreOwnerFlow.openSettings('general');
|
||||
|
||||
// Make sure the general tab is active
|
||||
await expect(page).toMatchElement('a.nav-tab-active', {text: 'General'});
|
||||
|
||||
// Set selling location to all countries first,
|
||||
// so we can choose california as base location.
|
||||
await expect(page).toSelect('#woocommerce_allowed_countries', 'Sell to all countries');
|
||||
await settingsPageSaveChanges();
|
||||
|
||||
// Verify that settings have been saved
|
||||
await Promise.all([
|
||||
expect(page).toMatchElement('#message', {text: 'Your settings have been saved.'}),
|
||||
expect(page).toMatchElement('#woocommerce_allowed_countries', {text: 'Sell to all countries'}),
|
||||
]);
|
||||
|
||||
// Set base location with state CA.
|
||||
await expect(page).toSelect('select[name="woocommerce_default_country"]', 'United States (US) — California');
|
||||
await settingsPageSaveChanges();
|
||||
|
||||
// Verify that settings have been saved
|
||||
await Promise.all([
|
||||
expect(page).toMatchElement('#message', {text: 'Your settings have been saved.'}),
|
||||
expect(page).toMatchElement('select[name="woocommerce_default_country"]', {text: 'United States (US) — California'}),
|
||||
]);
|
||||
|
||||
// Set selling location to specific countries first, so we can choose U.S as base location (without state).
|
||||
// This will makes specific countries option appears.
|
||||
await expect(page).toSelect('#woocommerce_allowed_countries', 'Sell to specific countries');
|
||||
await expect(page).toSelect('select[name="woocommerce_specific_allowed_countries[]"]', 'United States (US)');
|
||||
await settingsPageSaveChanges();
|
||||
|
||||
// Verify that settings have been saved
|
||||
await Promise.all([
|
||||
expect(page).toMatchElement('#message', {text: 'Your settings have been saved.'}),
|
||||
expect(page).toMatchElement('#woocommerce_allowed_countries', {text: 'Sell to specific countries'}),
|
||||
expect(page).toMatchElement('select[name="woocommerce_specific_allowed_countries[]"]', {text: 'United States (US)'}),
|
||||
]);
|
||||
|
||||
// Set currency options.
|
||||
await expect(page).toFill('#woocommerce_price_thousand_sep', ',');
|
||||
await expect(page).toFill('#woocommerce_price_decimal_sep', '.');
|
||||
await expect(page).toFill('#woocommerce_price_num_decimals', '2');
|
||||
await settingsPageSaveChanges();
|
||||
|
||||
// Verify that settings have been saved
|
||||
await Promise.all([
|
||||
expect(page).toMatchElement('#message', {text: 'Your settings have been saved.'}),
|
||||
verifyValueOfInputField('#woocommerce_price_thousand_sep', ','),
|
||||
verifyValueOfInputField('#woocommerce_price_decimal_sep', '.'),
|
||||
verifyValueOfInputField('#woocommerce_price_num_decimals', '2'),
|
||||
]);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = runUpdateGeneralSettingsTest;
|
|
@ -0,0 +1,57 @@
|
|||
/* eslint-disable jest/no-export, jest/no-disabled-tests */
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
const {
|
||||
StoreOwnerFlow,
|
||||
setCheckbox,
|
||||
settingsPageSaveChanges,
|
||||
unsetCheckbox,
|
||||
verifyCheckboxIsSet,
|
||||
verifyCheckboxIsUnset
|
||||
} = require( '@woocommerce/e2e-utils' );
|
||||
|
||||
const runProductSettingsTest = () => {
|
||||
describe('WooCommerce Products > Downloadable Products Settings', () => {
|
||||
beforeAll(async () => {
|
||||
await StoreOwnerFlow.login();
|
||||
});
|
||||
|
||||
it('can update settings', async () => {
|
||||
// Go to downloadable products settings page
|
||||
await StoreOwnerFlow.openSettings('products', 'downloadable');
|
||||
|
||||
// Make sure the product tab is active
|
||||
await expect(page).toMatchElement('a.nav-tab-active', {text: 'Products'});
|
||||
await expect(page).toMatchElement('ul.subsubsub > li > a.current', {text: 'Downloadable products'});
|
||||
|
||||
await expect(page).toSelect('#woocommerce_file_download_method', 'Redirect only (Insecure)');
|
||||
await setCheckbox('#woocommerce_downloads_require_login');
|
||||
await setCheckbox('#woocommerce_downloads_grant_access_after_payment');
|
||||
await settingsPageSaveChanges();
|
||||
|
||||
// Verify that settings have been saved
|
||||
await Promise.all([
|
||||
expect(page).toMatchElement('#message', {text: 'Your settings have been saved.'}),
|
||||
expect(page).toMatchElement('#woocommerce_file_download_method', {text: 'Redirect only (Insecure)'}),
|
||||
verifyCheckboxIsSet('#woocommerce_downloads_require_login'),
|
||||
verifyCheckboxIsSet('#woocommerce_downloads_grant_access_after_payment'),
|
||||
]);
|
||||
|
||||
await expect(page).toSelect('#woocommerce_file_download_method', 'Force downloads');
|
||||
await unsetCheckbox('#woocommerce_downloads_require_login');
|
||||
await unsetCheckbox('#woocommerce_downloads_grant_access_after_payment');
|
||||
await settingsPageSaveChanges();
|
||||
|
||||
// Verify that settings have been saved
|
||||
await Promise.all([
|
||||
expect(page).toMatchElement('#message', {text: 'Your settings have been saved.'}),
|
||||
expect(page).toMatchElement('#woocommerce_file_download_method', {text: 'Force downloads'}),
|
||||
verifyCheckboxIsUnset('#woocommerce_downloads_require_login'),
|
||||
verifyCheckboxIsUnset('#woocommerce_downloads_grant_access_after_payment'),
|
||||
]);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = runProductSettingsTest;
|
|
@ -0,0 +1,180 @@
|
|||
/* eslint-disable jest/no-export, jest/no-disabled-tests */
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
const {
|
||||
StoreOwnerFlow,
|
||||
clearAndFillInput,
|
||||
setCheckbox,
|
||||
settingsPageSaveChanges,
|
||||
uiUnblocked,
|
||||
verifyCheckboxIsSet,
|
||||
verifyValueOfInputField
|
||||
} = require( '@woocommerce/e2e-utils' );
|
||||
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
const {
|
||||
it,
|
||||
describe,
|
||||
beforeAll,
|
||||
} = require( '@jest/globals' );
|
||||
|
||||
const runTaxSettingsTest = () => {
|
||||
describe('WooCommerce Tax Settings', () => {
|
||||
beforeAll(async () => {
|
||||
await StoreOwnerFlow.login();
|
||||
});
|
||||
|
||||
it('can enable tax calculation', async () => {
|
||||
// Go to general settings page
|
||||
await StoreOwnerFlow.openSettings('general');
|
||||
|
||||
// Make sure the general tab is active
|
||||
await expect(page).toMatchElement('a.nav-tab-active', {text: 'General'});
|
||||
|
||||
// Enable tax calculation
|
||||
await setCheckbox('input[name="woocommerce_calc_taxes"]');
|
||||
await settingsPageSaveChanges();
|
||||
|
||||
// Verify that settings have been saved
|
||||
await Promise.all([
|
||||
expect(page).toMatchElement('#message', {text: 'Your settings have been saved.'}),
|
||||
verifyCheckboxIsSet('#woocommerce_calc_taxes'),
|
||||
]);
|
||||
|
||||
// Verify that tax settings are now present
|
||||
await expect(page).toMatchElement('a.nav-tab', {text: 'Tax'});
|
||||
});
|
||||
|
||||
it('can set tax options', async () => {
|
||||
// Go to tax settings page
|
||||
await StoreOwnerFlow.openSettings('tax');
|
||||
|
||||
// Make sure the tax tab is active
|
||||
await expect(page).toMatchElement('a.nav-tab-active', {text: 'Tax'});
|
||||
|
||||
// Prices exclusive of tax
|
||||
await expect(page).toClick('input[name="woocommerce_prices_include_tax"][value="no"]');
|
||||
// Tax based on customer shipping address
|
||||
await expect(page).toSelect('#woocommerce_tax_based_on', 'Customer shipping address');
|
||||
// Standard tax class for shipping
|
||||
await expect(page).toSelect('#woocommerce_shipping_tax_class', 'Standard');
|
||||
// Leave rounding unchecked (no-op)
|
||||
// Display prices excluding tax
|
||||
await expect(page).toSelect('#woocommerce_tax_display_shop', 'Excluding tax');
|
||||
// Display prices including tax in cart and at checkout
|
||||
await expect(page).toSelect('#woocommerce_tax_display_cart', 'Including tax');
|
||||
// Display a single tax total
|
||||
await expect(page).toSelect('#woocommerce_tax_total_display', 'As a single total');
|
||||
|
||||
await settingsPageSaveChanges();
|
||||
|
||||
// Verify that settings have been saved
|
||||
await Promise.all([
|
||||
expect(page).toMatchElement('#message', {text: 'Your settings have been saved.'}),
|
||||
verifyValueOfInputField('input[name="woocommerce_prices_include_tax"][value="no"]', 'no'),
|
||||
expect(page).toMatchElement('#woocommerce_tax_based_on', {text: 'Customer shipping address'}),
|
||||
expect(page).toMatchElement('#woocommerce_shipping_tax_class', {text: 'Standard'}),
|
||||
expect(page).toMatchElement('#woocommerce_tax_display_shop', {text: 'Excluding tax'}),
|
||||
expect(page).toMatchElement('#woocommerce_tax_display_cart', {text: 'Including tax'}),
|
||||
expect(page).toMatchElement('#woocommerce_tax_total_display', {text: 'As a single total'}),
|
||||
]);
|
||||
});
|
||||
|
||||
it('can add tax classes', async () => {
|
||||
// Go to tax settings page
|
||||
await StoreOwnerFlow.openSettings('tax');
|
||||
|
||||
// Make sure the tax tab is active
|
||||
await expect(page).toMatchElement('a.nav-tab-active', {text: 'Tax'});
|
||||
|
||||
// Remove additional tax classes
|
||||
await clearAndFillInput('#woocommerce_tax_classes', '');
|
||||
await settingsPageSaveChanges();
|
||||
|
||||
// Verify that settings have been saved
|
||||
await Promise.all([
|
||||
expect(page).toMatchElement('#message', {text: 'Your settings have been saved.'}),
|
||||
expect(page).toMatchElement('#woocommerce_tax_classes', {text: ''}),
|
||||
]);
|
||||
|
||||
// Add a "fancy" tax class
|
||||
await clearAndFillInput('#woocommerce_tax_classes', 'Fancy');
|
||||
await settingsPageSaveChanges();
|
||||
|
||||
// Verify that settings have been saved
|
||||
await Promise.all([
|
||||
expect(page).toMatchElement('#message', {text: 'Your settings have been saved.'}),
|
||||
expect(page).toMatchElement('ul.subsubsub > li > a', {text: 'Fancy rates'}),
|
||||
]);
|
||||
});
|
||||
|
||||
it('can set rate settings', async () => {
|
||||
// Go to "fancy" rates tax settings page
|
||||
await StoreOwnerFlow.openSettings('tax', 'fancy');
|
||||
|
||||
// Make sure the tax tab is active, with the "fancy" subsection
|
||||
await expect(page).toMatchElement('a.nav-tab-active', {text: 'Tax'});
|
||||
await expect(page).toMatchElement('ul.subsubsub > li > a.current', {text: 'Fancy rates'});
|
||||
|
||||
// Create a state tax
|
||||
await expect(page).toClick('.wc_tax_rates a.insert');
|
||||
await expect(page).toFill('input[name^="tax_rate_country[new-0"]', 'US');
|
||||
await expect(page).toFill('input[name^="tax_rate_state[new-0"]', 'CA');
|
||||
await expect(page).toFill('input[name^="tax_rate[new-0"]', '7.5');
|
||||
await expect(page).toFill('input[name^="tax_rate_name[new-0"]', 'CA State Tax');
|
||||
|
||||
// Create a federal tax
|
||||
await expect(page).toClick('.wc_tax_rates a.insert');
|
||||
await expect(page).toFill('input[name^="tax_rate_country[new-1"]', 'US');
|
||||
await expect(page).toFill('input[name^="tax_rate[new-1"]', '1.5');
|
||||
await expect(page).toFill('input[name^="tax_rate_priority[new-1"]', '2');
|
||||
await expect(page).toFill('input[name^="tax_rate_name[new-1"]', 'Federal Tax');
|
||||
await expect(page).toClick('input[name^="tax_rate_shipping[new-1"]');
|
||||
|
||||
// Save changes (AJAX here)
|
||||
await expect(page).toClick('button.woocommerce-save-button');
|
||||
await uiUnblocked();
|
||||
|
||||
// Verify 2 tax rates
|
||||
expect(await page.$$('#rates tr')).toHaveLength(2);
|
||||
|
||||
// Delete federal rate
|
||||
await expect(page).toClick('#rates tr:nth-child(2) input');
|
||||
await expect(page).toClick('.wc_tax_rates a.remove_tax_rates');
|
||||
|
||||
// Save changes (AJAX here)
|
||||
await expect(page).toClick('button.woocommerce-save-button');
|
||||
await uiUnblocked();
|
||||
|
||||
// Verify 1 rate
|
||||
expect(await page.$$('#rates tr')).toHaveLength(1);
|
||||
await expect(page).toMatchElement(
|
||||
'#rates tr:first-of-type input[name^="tax_rate_state"][value="CA"]'
|
||||
);
|
||||
});
|
||||
|
||||
it('can remove tax classes', async () => {
|
||||
// Go to tax settings page
|
||||
await StoreOwnerFlow.openSettings('tax');
|
||||
|
||||
// Make sure the tax tab is active
|
||||
await expect(page).toMatchElement('a.nav-tab-active', {text: 'Tax'});
|
||||
|
||||
// Remove "fancy" tax class
|
||||
await clearAndFillInput('#woocommerce_tax_classes', ' ');
|
||||
await settingsPageSaveChanges();
|
||||
|
||||
// Verify that settings have been saved
|
||||
await Promise.all([
|
||||
expect(page).toMatchElement('#message', {text: 'Your settings have been saved.'}),
|
||||
expect(page).not.toMatchElement('ul.subsubsub > li > a', {text: 'Fancy rates'}),
|
||||
]);
|
||||
await page.waitFor(10000);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = runTaxSettingsTest;
|
|
@ -1,6 +0,0 @@
|
|||
/*
|
||||
* Internal dependencies
|
||||
*/
|
||||
const { runFrontEndTests } = require( '@woocommerce/e2e-core-tests' );
|
||||
|
||||
runFrontEndTests();
|
|
@ -0,0 +1,6 @@
|
|||
/*
|
||||
* Internal dependencies
|
||||
*/
|
||||
const { runShopperTests } = require( '@woocommerce/e2e-core-tests' );
|
||||
|
||||
runShopperTests();
|
|
@ -1,44 +0,0 @@
|
|||
/**
|
||||
* @format
|
||||
*/
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
import {
|
||||
StoreOwnerFlow,
|
||||
clickTab,
|
||||
verifyPublishAndTrash
|
||||
} from '@woocommerce/e2e-utils';
|
||||
|
||||
describe( 'Add New Coupon Page', () => {
|
||||
beforeAll( async () => {
|
||||
await StoreOwnerFlow.login();
|
||||
} );
|
||||
|
||||
it( 'can create new coupon', async () => {
|
||||
// Go to "add coupon" page
|
||||
await StoreOwnerFlow.openNewCoupon();
|
||||
|
||||
// Make sure we're on the add coupon page
|
||||
await expect( page.title() ).resolves.toMatch( 'Add new coupon' );
|
||||
|
||||
// Fill in coupon code and description
|
||||
await expect( page ).toFill( '#title', 'code-' + new Date().getTime().toString() );
|
||||
await expect( page ).toFill( '#woocommerce-coupon-description', 'test coupon' );
|
||||
|
||||
// Set general coupon data
|
||||
await clickTab( 'General' );
|
||||
await expect( page ).toSelect( '#discount_type', 'Fixed cart discount' );
|
||||
await expect( page ).toFill( '#coupon_amount', '100' );
|
||||
|
||||
// Publish coupon, verify that it was published. Trash coupon, verify that it was trashed.
|
||||
await verifyPublishAndTrash(
|
||||
'#publish',
|
||||
'#message',
|
||||
'Coupon updated.',
|
||||
'1 coupon moved to the Trash.'
|
||||
);
|
||||
|
||||
} );
|
||||
} );
|
|
@ -1,39 +0,0 @@
|
|||
/**
|
||||
* @format
|
||||
*/
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
import {
|
||||
StoreOwnerFlow,
|
||||
verifyPublishAndTrash
|
||||
} from '@woocommerce/e2e-utils';
|
||||
|
||||
describe( 'Add New Order Page', () => {
|
||||
beforeAll( async () => {
|
||||
await StoreOwnerFlow.login();
|
||||
} );
|
||||
|
||||
it( 'can create new order', async () => {
|
||||
// Go to "add order" page
|
||||
await StoreOwnerFlow.openNewOrder();
|
||||
|
||||
// Make sure we're on the add order page
|
||||
await expect( page.title() ).resolves.toMatch( 'Add new order' );
|
||||
|
||||
// Set order data
|
||||
await expect( page ).toSelect( '#order_status', 'Processing' );
|
||||
await expect( page ).toFill( 'input[name=order_date]', '2018-12-13' );
|
||||
await expect( page ).toFill( 'input[name=order_date_hour]', '18' );
|
||||
await expect( page ).toFill( 'input[name=order_date_minute]', '55' );
|
||||
|
||||
// Create order, verify that it was created. Trash order, verify that it was trashed.
|
||||
await verifyPublishAndTrash(
|
||||
'.order_actions li .save_order',
|
||||
'#message',
|
||||
'Order updated.',
|
||||
'1 order moved to the Trash.'
|
||||
);
|
||||
} );
|
||||
} );
|
|
@ -1,196 +0,0 @@
|
|||
/**
|
||||
* @format
|
||||
*/
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
import {
|
||||
StoreOwnerFlow,
|
||||
clickTab,
|
||||
uiUnblocked
|
||||
} from '@woocommerce/e2e-utils';
|
||||
|
||||
const config = require( 'config' );
|
||||
const simpleProductName = config.get( 'products.simple.name' );
|
||||
|
||||
const verifyPublishAndTrash = async () => {
|
||||
// Wait for auto save
|
||||
await page.waitFor( 2000 );
|
||||
|
||||
// Publish product
|
||||
await expect( page ).toClick( '#publish' );
|
||||
await page.waitForSelector( '.updated.notice', { text: 'Product published.' } );
|
||||
|
||||
// Verify
|
||||
await expect( page ).toMatchElement( '.updated.notice', { text: 'Product published.' } );
|
||||
await page.waitForSelector( 'a', { text: 'Move to Trash' } );
|
||||
|
||||
// Trash product
|
||||
await expect( page ).toClick( 'a', { text: 'Move to Trash' } );
|
||||
await page.waitForSelector( '.updated.notice', { text: '1 product moved to the Trash.' } );
|
||||
|
||||
// Verify
|
||||
await expect( page ).toMatchElement( '.updated.notice', { text: '1 product moved to the Trash.' } );
|
||||
};
|
||||
|
||||
describe( 'Add New Simple Product Page', () => {
|
||||
beforeAll( async () => {
|
||||
await StoreOwnerFlow.login();
|
||||
} );
|
||||
|
||||
it( 'can create simple virtual product titled "Simple Product" with regular price $9.99', async () => {
|
||||
// Go to "add product" page
|
||||
await StoreOwnerFlow.openNewProduct();
|
||||
|
||||
// Make sure we're on the add order page
|
||||
await expect( page.title() ).resolves.toMatch( 'Add new product' );
|
||||
|
||||
// Set product data
|
||||
await expect( page ).toFill( '#title', simpleProductName );
|
||||
await expect( page ).toClick( '#_virtual' );
|
||||
await clickTab( 'General' );
|
||||
await expect( page ).toFill( '#_regular_price', '9.99' );
|
||||
|
||||
// Publish product, verify that it was published. Trash product, verify that it was trashed.
|
||||
await verifyPublishAndTrash(
|
||||
'#publish',
|
||||
'.updated.notice',
|
||||
'Product published.',
|
||||
'Move to Trash',
|
||||
'1 product moved to the Trash.'
|
||||
);
|
||||
} );
|
||||
} );
|
||||
|
||||
describe.skip( 'Add New Variable Product Page', () => {
|
||||
it( 'can create product with variations', async () => {
|
||||
// Go to "add product" page
|
||||
await StoreOwnerFlow.openNewProduct();
|
||||
|
||||
// Make sure we're on the add order page
|
||||
await expect( page.title() ).resolves.toMatch( 'Add new product' );
|
||||
|
||||
// Set product data
|
||||
await expect( page ).toFill( '#title', 'Variable Product with Three Variations' );
|
||||
await expect( page ).toSelect( '#product-type', 'Variable product' );
|
||||
|
||||
// Create attributes for variations
|
||||
await clickTab( 'Attributes' );
|
||||
await expect( page ).toSelect( 'select[name="attribute_taxonomy"]', 'Custom product attribute' );
|
||||
|
||||
for ( let i = 0; i < 3; i++ ) {
|
||||
await expect( page ).toClick( 'button.add_attribute', { text: 'Add' } );
|
||||
// Wait for attribute form to load
|
||||
await uiUnblocked();
|
||||
|
||||
await page.focus( `input[name="attribute_names[${ i }]"]` );
|
||||
await expect( page ).toFill( `input[name="attribute_names[${ i }]"]`, 'attr #' + ( i + 1 ) );
|
||||
await expect( page ).toFill( `textarea[name="attribute_values[${ i }]"]`, 'val1 | val2' );
|
||||
await expect( page ).toClick( `input[name="attribute_variation[${ i }]"]` );
|
||||
}
|
||||
|
||||
await expect( page ).toClick( 'button', { text: 'Save attributes' } );
|
||||
|
||||
// Wait for attribute form to save (triggers 2 UI blocks)
|
||||
await uiUnblocked();
|
||||
await page.waitFor( 1000 );
|
||||
await uiUnblocked();
|
||||
|
||||
// Create variations from attributes
|
||||
await clickTab( 'Variations' );
|
||||
await page.waitForSelector( 'select.variation_actions:not([disabled])' );
|
||||
await page.focus( 'select.variation_actions' );
|
||||
await expect( page ).toSelect( 'select.variation_actions', 'Create variations from all attributes' );
|
||||
|
||||
const firstDialog = await expect( page ).toDisplayDialog( async () => {
|
||||
// Using this technique since toClick() isn't working.
|
||||
// See: https://github.com/GoogleChrome/puppeteer/issues/1805#issuecomment-464802876
|
||||
page.$eval( 'a.do_variation_action', elem => elem.click() );
|
||||
} );
|
||||
|
||||
expect( firstDialog.message() ).toMatch( 'Are you sure you want to link all variations?' );
|
||||
|
||||
const secondDialog = await expect( page ).toDisplayDialog( async () => {
|
||||
await firstDialog.accept();
|
||||
} );
|
||||
|
||||
expect( secondDialog.message() ).toMatch( '8 variations added' );
|
||||
await secondDialog.dismiss();
|
||||
|
||||
// Set some variation data
|
||||
await uiUnblocked();
|
||||
await uiUnblocked();
|
||||
|
||||
await page.waitForSelector( '.woocommerce_variation .handlediv' );
|
||||
|
||||
// Verify that variations were created
|
||||
await Promise.all( [
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-1[0]"]', { text: 'val1' } ),
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-2[0]"]', { text: 'val1' } ),
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-3[0]"]', { text: 'val1' } ),
|
||||
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-1[1]"]', { text: 'val1' } ),
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-2[1]"]', { text: 'val1' } ),
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-3[1]"]', { text: 'val2' } ),
|
||||
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-1[2]"]', { text: 'val1' } ),
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-2[2]"]', { text: 'val2' } ),
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-3[2]"]', { text: 'val1' } ),
|
||||
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-1[3]"]', { text: 'val1' } ),
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-2[3]"]', { text: 'val2' } ),
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-3[3]"]', { text: 'val2' } ),
|
||||
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-1[4]"]', { text: 'val2' } ),
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-2[4]"]', { text: 'val1' } ),
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-3[4]"]', { text: 'val1' } ),
|
||||
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-1[5]"]', { text: 'val2' } ),
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-2[5]"]', { text: 'val1' } ),
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-3[5]"]', { text: 'val2' } ),
|
||||
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-1[6]"]', { text: 'val2' } ),
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-2[6]"]', { text: 'val2' } ),
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-3[6]"]', { text: 'val1' } ),
|
||||
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-1[7]"]', { text: 'val2' } ),
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-2[7]"]', { text: 'val2' } ),
|
||||
expect( page ).toMatchElement( 'select[name="attribute_attr-3[7]"]', { text: 'val2' } ),
|
||||
] );
|
||||
|
||||
await expect( page ).toClick( '.woocommerce_variation:nth-of-type(2) .handlediv' );
|
||||
await page.waitFor( 2000 );
|
||||
await page.focus( 'input[name="variable_is_virtual[0]"]' );
|
||||
await expect( page ).toClick( 'input[name="variable_is_virtual[0]"]' );
|
||||
await expect( page ).toFill( 'input[name="variable_regular_price[0]"]', '9.99' );
|
||||
|
||||
await expect( page ).toClick( '.woocommerce_variation:nth-of-type(3) .handlediv' );
|
||||
await page.waitFor( 2000 );
|
||||
await page.focus( 'input[name="variable_is_virtual[1]"]' );
|
||||
await expect( page ).toClick( 'input[name="variable_is_virtual[1]"]' );
|
||||
await expect( page ).toFill( 'input[name="variable_regular_price[1]"]', '11.99' );
|
||||
|
||||
await expect( page ).toClick( '.woocommerce_variation:nth-of-type(4) .handlediv' );
|
||||
await page.waitFor( 2000 );
|
||||
await page.focus( 'input[name="variable_manage_stock[2]"]' );
|
||||
await expect( page ).toClick( 'input[name="variable_manage_stock[2]"]' );
|
||||
await expect( page ).toFill( 'input[name="variable_regular_price[2]"]', '20' );
|
||||
await expect( page ).toFill( 'input[name="variable_weight[2]"]', '200' );
|
||||
await expect( page ).toFill( 'input[name="variable_length[2]"]', '10' );
|
||||
await expect( page ).toFill( 'input[name="variable_width[2]"]', '20' );
|
||||
await expect( page ).toFill( 'input[name="variable_height[2]"]', '15' );
|
||||
|
||||
await page.focus( 'button.save-variation-changes' );
|
||||
await expect( page ).toClick( 'button.save-variation-changes', { text: 'Save changes' } );
|
||||
|
||||
// Publish product, verify that it was published. Trash product, verify that it was trashed.
|
||||
await verifyPublishAndTrash(
|
||||
'#publish',
|
||||
'.updated.notice',
|
||||
'Product published.',
|
||||
'Move to Trash',
|
||||
'1 product moved to the Trash.'
|
||||
);
|
||||
} );
|
||||
} );
|
|
@ -1,74 +0,0 @@
|
|||
/**
|
||||
* @format
|
||||
*/
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
import {
|
||||
StoreOwnerFlow,
|
||||
settingsPageSaveChanges,
|
||||
verifyValueOfInputField
|
||||
} from '@woocommerce/e2e-utils';
|
||||
|
||||
describe( 'WooCommerce General Settings', () => {
|
||||
beforeAll( async () => {
|
||||
await StoreOwnerFlow.login();
|
||||
} );
|
||||
|
||||
it( 'can update settings', async () => {
|
||||
// Go to general settings page
|
||||
await StoreOwnerFlow.openSettings( 'general' );
|
||||
|
||||
// Make sure the general tab is active
|
||||
await expect( page ).toMatchElement( 'a.nav-tab-active', { text: 'General' } );
|
||||
|
||||
// Set selling location to all countries first,
|
||||
// so we can choose california as base location.
|
||||
await expect( page ).toSelect( '#woocommerce_allowed_countries', 'Sell to all countries' );
|
||||
await settingsPageSaveChanges();
|
||||
|
||||
// Verify that settings have been saved
|
||||
await Promise.all( [
|
||||
expect( page ).toMatchElement( '#message', { text: 'Your settings have been saved.' } ),
|
||||
expect( page ).toMatchElement( '#woocommerce_allowed_countries', { text: 'Sell to all countries' } ),
|
||||
] );
|
||||
|
||||
// Set base location with state CA.
|
||||
await expect( page ).toSelect( 'select[name="woocommerce_default_country"]', 'United States (US) — California' );
|
||||
await settingsPageSaveChanges();
|
||||
|
||||
// Verify that settings have been saved
|
||||
await Promise.all( [
|
||||
expect( page ).toMatchElement( '#message', { text: 'Your settings have been saved.' } ),
|
||||
expect( page ).toMatchElement( 'select[name="woocommerce_default_country"]', { text: 'United States (US) — California' } ),
|
||||
] );
|
||||
|
||||
// Set selling location to specific countries first, so we can choose U.S as base location (without state).
|
||||
// This will makes specific countries option appears.
|
||||
await expect( page ).toSelect( '#woocommerce_allowed_countries', 'Sell to specific countries' );
|
||||
await expect( page ).toSelect( 'select[name="woocommerce_specific_allowed_countries[]"]', 'United States (US)' );
|
||||
await settingsPageSaveChanges();
|
||||
|
||||
// Verify that settings have been saved
|
||||
await Promise.all( [
|
||||
expect( page ).toMatchElement( '#message', { text: 'Your settings have been saved.' } ),
|
||||
expect( page ).toMatchElement( '#woocommerce_allowed_countries', { text: 'Sell to specific countries' } ),
|
||||
expect( page ).toMatchElement( 'select[name="woocommerce_specific_allowed_countries[]"]', { text: 'United States (US)' } ),
|
||||
] );
|
||||
|
||||
// Set currency options.
|
||||
await expect( page ).toFill( '#woocommerce_price_thousand_sep', ',' );
|
||||
await expect( page ).toFill( '#woocommerce_price_decimal_sep', '.' );
|
||||
await expect( page ).toFill( '#woocommerce_price_num_decimals', '2' );
|
||||
await settingsPageSaveChanges();
|
||||
|
||||
// Verify that settings have been saved
|
||||
await Promise.all( [
|
||||
expect( page ).toMatchElement( '#message', { text: 'Your settings have been saved.' } ),
|
||||
verifyValueOfInputField( '#woocommerce_price_thousand_sep', ',' ),
|
||||
verifyValueOfInputField( '#woocommerce_price_decimal_sep', '.' ),
|
||||
verifyValueOfInputField( '#woocommerce_price_num_decimals', '2' ),
|
||||
] );
|
||||
} );
|
||||
} );
|
|
@ -1,56 +0,0 @@
|
|||
/**
|
||||
* @format
|
||||
*/
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
import {
|
||||
StoreOwnerFlow,
|
||||
setCheckbox,
|
||||
settingsPageSaveChanges,
|
||||
unsetCheckbox,
|
||||
verifyCheckboxIsSet,
|
||||
verifyCheckboxIsUnset
|
||||
} from '@woocommerce/e2e-utils';
|
||||
|
||||
describe( 'WooCommerce Products > Downloadable Products Settings', () => {
|
||||
beforeAll( async () => {
|
||||
await StoreOwnerFlow.login();
|
||||
} );
|
||||
|
||||
it( 'can update settings', async () => {
|
||||
// Go to downloadable products settings page
|
||||
await StoreOwnerFlow.openSettings( 'products', 'downloadable' );
|
||||
|
||||
// Make sure the product tab is active
|
||||
await expect( page ).toMatchElement( 'a.nav-tab-active', { text: 'Products' } );
|
||||
await expect( page ).toMatchElement( 'ul.subsubsub > li > a.current', { text: 'Downloadable products' } );
|
||||
|
||||
await expect( page ).toSelect( '#woocommerce_file_download_method', 'Redirect only (Insecure)' );
|
||||
await setCheckbox( '#woocommerce_downloads_require_login' );
|
||||
await setCheckbox( '#woocommerce_downloads_grant_access_after_payment' );
|
||||
await settingsPageSaveChanges();
|
||||
|
||||
// Verify that settings have been saved
|
||||
await Promise.all( [
|
||||
expect( page ).toMatchElement( '#message', { text: 'Your settings have been saved.' } ),
|
||||
expect( page ).toMatchElement( '#woocommerce_file_download_method', { text: 'Redirect only (Insecure)' } ),
|
||||
verifyCheckboxIsSet( '#woocommerce_downloads_require_login' ),
|
||||
verifyCheckboxIsSet( '#woocommerce_downloads_grant_access_after_payment' ),
|
||||
] );
|
||||
|
||||
await expect( page ).toSelect( '#woocommerce_file_download_method', 'Force downloads' );
|
||||
await unsetCheckbox( '#woocommerce_downloads_require_login' );
|
||||
await unsetCheckbox( '#woocommerce_downloads_grant_access_after_payment' );
|
||||
await settingsPageSaveChanges();
|
||||
|
||||
// Verify that settings have been saved
|
||||
await Promise.all( [
|
||||
expect( page ).toMatchElement( '#message', { text: 'Your settings have been saved.' } ),
|
||||
expect( page ).toMatchElement( '#woocommerce_file_download_method', { text: 'Force downloads' } ),
|
||||
verifyCheckboxIsUnset( '#woocommerce_downloads_require_login' ),
|
||||
verifyCheckboxIsUnset( '#woocommerce_downloads_grant_access_after_payment' ),
|
||||
] );
|
||||
} );
|
||||
} );
|
|
@ -1,170 +0,0 @@
|
|||
/**
|
||||
* @format
|
||||
*/
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
import {
|
||||
StoreOwnerFlow,
|
||||
clearAndFillInput,
|
||||
setCheckbox,
|
||||
settingsPageSaveChanges,
|
||||
uiUnblocked,
|
||||
verifyCheckboxIsSet,
|
||||
verifyValueOfInputField
|
||||
} from '@woocommerce/e2e-utils';
|
||||
|
||||
describe( 'WooCommerce Tax Settings', () => {
|
||||
beforeAll( async () => {
|
||||
await StoreOwnerFlow.login();
|
||||
} );
|
||||
|
||||
it( 'can enable tax calculation', async() => {
|
||||
// Go to general settings page
|
||||
await StoreOwnerFlow.openSettings( 'general' );
|
||||
|
||||
// Make sure the general tab is active
|
||||
await expect( page ).toMatchElement( 'a.nav-tab-active', { text: 'General' } );
|
||||
|
||||
// Enable tax calculation
|
||||
await setCheckbox( 'input[name="woocommerce_calc_taxes"]' );
|
||||
await settingsPageSaveChanges();
|
||||
|
||||
// Verify that settings have been saved
|
||||
await Promise.all( [
|
||||
expect( page ).toMatchElement( '#message', { text: 'Your settings have been saved.' } ),
|
||||
verifyCheckboxIsSet( '#woocommerce_calc_taxes' ),
|
||||
] );
|
||||
|
||||
// Verify that tax settings are now present
|
||||
await expect( page ).toMatchElement( 'a.nav-tab', { text: 'Tax' } );
|
||||
} );
|
||||
|
||||
it( 'can set tax options', async () => {
|
||||
// Go to tax settings page
|
||||
await StoreOwnerFlow.openSettings( 'tax' );
|
||||
|
||||
// Make sure the tax tab is active
|
||||
await expect( page ).toMatchElement( 'a.nav-tab-active', { text: 'Tax' } );
|
||||
|
||||
// Prices exclusive of tax
|
||||
await expect( page ).toClick( 'input[name="woocommerce_prices_include_tax"][value="no"]' );
|
||||
// Tax based on customer shipping address
|
||||
await expect( page ).toSelect( '#woocommerce_tax_based_on', 'Customer shipping address' );
|
||||
// Standard tax class for shipping
|
||||
await expect( page ).toSelect( '#woocommerce_shipping_tax_class', 'Standard' );
|
||||
// Leave rounding unchecked (no-op)
|
||||
// Display prices excluding tax
|
||||
await expect( page ).toSelect( '#woocommerce_tax_display_shop', 'Excluding tax' );
|
||||
// Display prices including tax in cart and at checkout
|
||||
await expect( page ).toSelect( '#woocommerce_tax_display_cart', 'Including tax' );
|
||||
// Display a single tax total
|
||||
await expect( page ).toSelect( '#woocommerce_tax_total_display', 'As a single total' );
|
||||
|
||||
await settingsPageSaveChanges();
|
||||
|
||||
// Verify that settings have been saved
|
||||
await Promise.all( [
|
||||
expect( page ).toMatchElement( '#message', { text: 'Your settings have been saved.' } ),
|
||||
verifyValueOfInputField( 'input[name="woocommerce_prices_include_tax"][value="no"]', 'no' ),
|
||||
expect( page ).toMatchElement( '#woocommerce_tax_based_on', { text: 'Customer shipping address' } ),
|
||||
expect( page ).toMatchElement( '#woocommerce_shipping_tax_class', { text: 'Standard' } ),
|
||||
expect( page ).toMatchElement( '#woocommerce_tax_display_shop', { text: 'Excluding tax' } ),
|
||||
expect( page ).toMatchElement( '#woocommerce_tax_display_cart', { text: 'Including tax' } ),
|
||||
expect( page ).toMatchElement( '#woocommerce_tax_total_display', { text: 'As a single total' } ),
|
||||
] );
|
||||
} );
|
||||
|
||||
it( 'can add tax classes', async () => {
|
||||
// Go to tax settings page
|
||||
await StoreOwnerFlow.openSettings( 'tax' );
|
||||
|
||||
// Make sure the tax tab is active
|
||||
await expect( page ).toMatchElement( 'a.nav-tab-active', { text: 'Tax' } );
|
||||
|
||||
// Remove additional tax classes
|
||||
await clearAndFillInput( '#woocommerce_tax_classes', '' );
|
||||
await settingsPageSaveChanges();
|
||||
|
||||
// Verify that settings have been saved
|
||||
await Promise.all( [
|
||||
expect( page ).toMatchElement( '#message', { text: 'Your settings have been saved.' } ),
|
||||
expect( page ).toMatchElement( '#woocommerce_tax_classes', { text: '' } ),
|
||||
] );
|
||||
|
||||
// Add a "fancy" tax class
|
||||
await clearAndFillInput( '#woocommerce_tax_classes', 'Fancy' );
|
||||
await settingsPageSaveChanges();
|
||||
|
||||
// Verify that settings have been saved
|
||||
await Promise.all( [
|
||||
expect( page ).toMatchElement( '#message', { text: 'Your settings have been saved.' } ),
|
||||
expect( page ).toMatchElement( 'ul.subsubsub > li > a', { text: 'Fancy rates' } ),
|
||||
] );
|
||||
} );
|
||||
|
||||
it( 'can set rate settings', async () => {
|
||||
// Go to "fancy" rates tax settings page
|
||||
await StoreOwnerFlow.openSettings( 'tax', 'fancy' );
|
||||
|
||||
// Make sure the tax tab is active, with the "fancy" subsection
|
||||
await expect( page ).toMatchElement( 'a.nav-tab-active', { text: 'Tax' } );
|
||||
await expect( page ).toMatchElement( 'ul.subsubsub > li > a.current', { text: 'Fancy rates' } );
|
||||
|
||||
// Create a state tax
|
||||
await expect( page ).toClick( '.wc_tax_rates a.insert' );
|
||||
await expect( page ).toFill( 'input[name^="tax_rate_country[new-0"]', 'US' );
|
||||
await expect( page ).toFill( 'input[name^="tax_rate_state[new-0"]', 'CA' );
|
||||
await expect( page ).toFill( 'input[name^="tax_rate[new-0"]', '7.5' );
|
||||
await expect( page ).toFill( 'input[name^="tax_rate_name[new-0"]', 'CA State Tax' );
|
||||
|
||||
// Create a federal tax
|
||||
await expect( page ).toClick( '.wc_tax_rates a.insert' );
|
||||
await expect( page ).toFill( 'input[name^="tax_rate_country[new-1"]', 'US' );
|
||||
await expect( page ).toFill( 'input[name^="tax_rate[new-1"]', '1.5' );
|
||||
await expect( page ).toFill( 'input[name^="tax_rate_priority[new-1"]', '2' );
|
||||
await expect( page ).toFill( 'input[name^="tax_rate_name[new-1"]', 'Federal Tax' );
|
||||
await expect( page ).toClick( 'input[name^="tax_rate_shipping[new-1"]' );
|
||||
|
||||
// Save changes (AJAX here)
|
||||
await expect( page ).toClick( 'button.woocommerce-save-button' );
|
||||
await uiUnblocked();
|
||||
|
||||
// Verify 2 tax rates
|
||||
expect( await page.$$( '#rates tr' ) ).toHaveLength( 2 );
|
||||
|
||||
// Delete federal rate
|
||||
await expect( page ).toClick( '#rates tr:nth-child(2) input' );
|
||||
await expect( page ).toClick( '.wc_tax_rates a.remove_tax_rates' );
|
||||
|
||||
// Save changes (AJAX here)
|
||||
await expect( page ).toClick( 'button.woocommerce-save-button' );
|
||||
await uiUnblocked();
|
||||
|
||||
// Verify 1 rate
|
||||
expect( await page.$$( '#rates tr' ) ).toHaveLength( 1 );
|
||||
await expect( page ).toMatchElement(
|
||||
'#rates tr:first-of-type input[name^="tax_rate_state"][value="CA"]'
|
||||
);
|
||||
} );
|
||||
|
||||
it( 'can remove tax classes', async () => {
|
||||
// Go to tax settings page
|
||||
await StoreOwnerFlow.openSettings( 'tax' );
|
||||
|
||||
// Make sure the tax tab is active
|
||||
await expect( page ).toMatchElement( 'a.nav-tab-active', { text: 'Tax' } );
|
||||
|
||||
// Remove "fancy" tax class
|
||||
await clearAndFillInput( '#woocommerce_tax_classes', ' ' );
|
||||
await settingsPageSaveChanges();
|
||||
|
||||
// Verify that settings have been saved
|
||||
await Promise.all( [
|
||||
expect( page ).toMatchElement( '#message', { text: 'Your settings have been saved.' } ),
|
||||
expect( page ).not.toMatchElement( 'ul.subsubsub > li > a', { text: 'Fancy rates' } ),
|
||||
] );
|
||||
await page.waitFor( 10000 );
|
||||
} );
|
||||
} );
|
Loading…
Reference in New Issue