Added updateSettingOption and updatePaymentGateway to withRestAPI flows
This commit is contained in:
parent
77c7c386f0
commit
59c69e54dd
|
@ -6,11 +6,7 @@ const {
|
||||||
merchant,
|
merchant,
|
||||||
withRestApi,
|
withRestApi,
|
||||||
createSimpleProduct,
|
createSimpleProduct,
|
||||||
setCheckbox,
|
|
||||||
settingsPageSaveChanges,
|
|
||||||
uiUnblocked,
|
uiUnblocked,
|
||||||
verifyCheckboxIsSet,
|
|
||||||
addShippingZoneAndMethod,
|
|
||||||
} = require( '@woocommerce/e2e-utils' );
|
} = require( '@woocommerce/e2e-utils' );
|
||||||
|
|
||||||
const config = require( 'config' );
|
const config = require( 'config' );
|
||||||
|
@ -33,46 +29,23 @@ const runCheckoutPageTest = () => {
|
||||||
await withRestApi.resetSettingsGroupToDefault('tax');
|
await withRestApi.resetSettingsGroupToDefault('tax');
|
||||||
|
|
||||||
// Set free shipping within California
|
// Set free shipping within California
|
||||||
await merchant.login();
|
await withRestApi.addShippingZoneAndMethod('Free Shipping CA', 'state:US:CA', ' ', 'free_shipping');
|
||||||
await addShippingZoneAndMethod('Free Shipping CA', 'state:US:CA', ' ', 'free_shipping');
|
|
||||||
// Go to general settings page
|
|
||||||
await merchant.openSettings('general');
|
|
||||||
|
|
||||||
// Set base location with state CA.
|
// Set base location with state CA.
|
||||||
await expect(page).toSelect('select[name="woocommerce_default_country"]', 'United States (US) — California');
|
await withRestApi.updateSettingOption( 'general', 'woocommerce_default_country', { value: 'US:CA' } );
|
||||||
// Sell to all countries
|
|
||||||
await expect(page).toSelect('#woocommerce_allowed_countries', 'Sell to all countries');
|
|
||||||
// Set currency to USD
|
|
||||||
await expect(page).toSelect('#woocommerce_currency', 'United States (US) dollar ($)');
|
|
||||||
// Tax calculation should have been enabled by another test - no-op
|
|
||||||
// Save
|
|
||||||
await settingsPageSaveChanges();
|
|
||||||
|
|
||||||
// Verify that settings have been saved
|
// Sell to all countries
|
||||||
await Promise.all([
|
await withRestApi.updateSettingOption( 'general', 'woocommerce_allowed_countries', { value: '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 currency to USD
|
||||||
expect(page).toMatchElement('#woocommerce_allowed_countries', {text: 'Sell to all countries'}),
|
await withRestApi.updateSettingOption( 'general', 'woocommerce_currency', { value: 'USD' } );
|
||||||
expect(page).toMatchElement('#woocommerce_currency', {text: 'United States (US) dollar ($)'}),
|
// Tax calculation should have been enabled by another test - no-op
|
||||||
]);
|
|
||||||
|
|
||||||
// Enable BACS payment method
|
// Enable BACS payment method
|
||||||
await merchant.openSettings('checkout', 'bacs');
|
await withRestApi.updatePaymentGateway( 'bacs', { enabled: true } );
|
||||||
await setCheckbox('#woocommerce_bacs_enabled');
|
|
||||||
await settingsPageSaveChanges();
|
|
||||||
|
|
||||||
// Verify that settings have been saved
|
|
||||||
await verifyCheckboxIsSet('#woocommerce_bacs_enabled');
|
|
||||||
|
|
||||||
// Enable COD payment method
|
// Enable COD payment method
|
||||||
await merchant.openSettings('checkout', 'cod');
|
await withRestApi.updatePaymentGateway( 'cod', { enabled: true } );
|
||||||
await setCheckbox('#woocommerce_cod_enabled');
|
|
||||||
await settingsPageSaveChanges();
|
|
||||||
|
|
||||||
// Verify that settings have been saved
|
|
||||||
await verifyCheckboxIsSet('#woocommerce_cod_enabled');
|
|
||||||
|
|
||||||
await merchant.logout();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should display cart items in order review', async () => {
|
it('should display cart items in order review', async () => {
|
||||||
|
@ -160,7 +133,7 @@ const runCheckoutPageTest = () => {
|
||||||
customerOrderId = orderReceivedText.split(/(\s+)/)[6].toString();
|
customerOrderId = orderReceivedText.split(/(\s+)/)[6].toString();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('store owner can confirm the order was received', async () => {
|
it('merchant can confirm the order was received', async () => {
|
||||||
await merchant.login();
|
await merchant.login();
|
||||||
await merchant.verifyOrder(guestOrderId, simpleProductName, singleProductPrice, 5, fiveProductPrice);
|
await merchant.verifyOrder(guestOrderId, simpleProductName, singleProductPrice, 5, fiveProductPrice);
|
||||||
await merchant.verifyOrder(customerOrderId, simpleProductName, singleProductPrice, 1, singleProductPrice, true);
|
await merchant.verifyOrder(customerOrderId, simpleProductName, singleProductPrice, 1, singleProductPrice, true);
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
- Added `statuses` optional parameter to `deleteAllRepositoryObjects()` to delete on specific statuses
|
- Added `statuses` optional parameter to `deleteAllRepositoryObjects()` to delete on specific statuses
|
||||||
- Added `createOrder()` component util that creates an order using the API with the passed in details
|
- Added `createOrder()` component util that creates an order using the API with the passed in details
|
||||||
- Updated `addShippingZoneAndMethod` to use the API instead of UI to create shipping zones
|
- Updated `addShippingZoneAndMethod` to use the API instead of UI to create shipping zones
|
||||||
|
- Added `updateSettingOption` to use the API to update a setting option
|
||||||
|
- Added `updatePaymentGateway` to use the API to update a payment gateway
|
||||||
|
|
||||||
# 0.1.5
|
# 0.1.5
|
||||||
|
|
||||||
|
|
|
@ -149,6 +149,8 @@ This package provides support for enabling retries in tests:
|
||||||
| `resetSettingsGroupToDefault` | `settingsGroup` | Reset settings in settings group to default except `select` fields |
|
| `resetSettingsGroupToDefault` | `settingsGroup` | Reset settings in settings group to default except `select` fields |
|
||||||
| `batchCreateOrders` | `orders` | Create a batch of orders using the "Batch Create Order" API endpoint |
|
| `batchCreateOrders` | `orders` | Create a batch of orders using the "Batch Create Order" API endpoint |
|
||||||
| `deleteAllOrders` | | Permanently delete all orders |
|
| `deleteAllOrders` | | Permanently delete all orders |
|
||||||
|
| `updateSettingOption` | `settingsGroup`, `settingID`, `payload` | Update a settings group |
|
||||||
|
| `updatePaymentGateway`| `paymentGatewayId`, `payload` | Update a payment gateway |
|
||||||
|
|
||||||
### Page Utilities
|
### Page Utilities
|
||||||
|
|
||||||
|
|
|
@ -252,7 +252,27 @@ export const withRestApi = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* Update a setting to the supplied value.
|
||||||
|
*
|
||||||
|
* @param {string} settingsGroup The settings group to update.
|
||||||
|
* @param {string} settingId The setting ID to update
|
||||||
|
* @param {object} payload An object with a key/value pair to update.
|
||||||
|
*/
|
||||||
|
updateSettingOption: async ( settingsGroup, settingId, payload = {} ) => {
|
||||||
|
const settingsClient = Setting.restRepository( client );
|
||||||
|
await settingsClient.update( settingsGroup, settingId, payload );
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* Update a payment gateway.
|
||||||
|
*
|
||||||
|
* @param {string} paymentGatewayId The ID of the payment gateway to update.
|
||||||
|
* @param {object} payload An object with the key/value pair to update.
|
||||||
|
*/
|
||||||
|
updatePaymentGateway: async ( paymentGatewayId, payload = {} ) => {
|
||||||
|
const response = await client.put( `/wc/v3/payment_gateways/${paymentGatewayId}`, payload );
|
||||||
|
expect( response.statusCode ).toBe( 200 );
|
||||||
|
},
|
||||||
/**
|
/**
|
||||||
* Create a batch of orders using the "Batch Create Order" API endpoint.
|
* Create a batch of orders using the "Batch Create Order" API endpoint.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue