Merge branch 'trunk' into e2e/e2e-merchant-import-products

This commit is contained in:
Veljko V 2021-03-18 17:27:50 +01:00 committed by GitHub
commit 24747c1713
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 293 additions and 48 deletions

View File

@ -21,8 +21,8 @@
"pelago/emogrifier": "3.1.0", "pelago/emogrifier": "3.1.0",
"psr/container": "1.0.0", "psr/container": "1.0.0",
"woocommerce/action-scheduler": "3.1.6", "woocommerce/action-scheduler": "3.1.6",
"woocommerce/woocommerce-admin": "2.0.3", "woocommerce/woocommerce-admin": "2.1.3",
"woocommerce/woocommerce-blocks": "4.4.3" "woocommerce/woocommerce-blocks": "4.7.0"
}, },
"require-dev": { "require-dev": {
"bamarni/composer-bin-plugin": "^1.4" "bamarni/composer-bin-plugin": "^1.4"

65
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "d60ef90fa87857445878bb83ba4c592c", "content-hash": "dc5e21e29d4fb70bba776d20112c74f0",
"packages": [ "packages": [
{ {
"name": "automattic/jetpack-autoloader", "name": "automattic/jetpack-autoloader",
@ -44,6 +44,9 @@
"GPL-2.0-or-later" "GPL-2.0-or-later"
], ],
"description": "Creates a custom autoloader for a plugin or theme.", "description": "Creates a custom autoloader for a plugin or theme.",
"support": {
"source": "https://github.com/Automattic/jetpack-autoloader/tree/v2.9.1"
},
"time": "2021-02-05T19:07:06+00:00" "time": "2021-02-05T19:07:06+00:00"
}, },
{ {
@ -75,6 +78,9 @@
"GPL-2.0-or-later" "GPL-2.0-or-later"
], ],
"description": "A wrapper for defining constants in a more testable way.", "description": "A wrapper for defining constants in a more testable way.",
"support": {
"source": "https://github.com/Automattic/jetpack-constants/tree/v1.5.1"
},
"time": "2020-10-28T19:00:31+00:00" "time": "2020-10-28T19:00:31+00:00"
}, },
{ {
@ -205,6 +211,10 @@
"zend", "zend",
"zikula" "zikula"
], ],
"support": {
"issues": "https://github.com/composer/installers/issues",
"source": "https://github.com/composer/installers/tree/v1.10.0"
},
"funding": [ "funding": [
{ {
"url": "https://packagist.com", "url": "https://packagist.com",
@ -279,6 +289,10 @@
"geolocation", "geolocation",
"maxmind" "maxmind"
], ],
"support": {
"issues": "https://github.com/maxmind/MaxMind-DB-Reader-php/issues",
"source": "https://github.com/maxmind/MaxMind-DB-Reader-php/tree/v1.6.0"
},
"time": "2019-12-19T22:59:03+00:00" "time": "2019-12-19T22:59:03+00:00"
}, },
{ {
@ -353,6 +367,10 @@
"email", "email",
"pre-processing" "pre-processing"
], ],
"support": {
"issues": "https://github.com/MyIntervals/emogrifier/issues",
"source": "https://github.com/MyIntervals/emogrifier"
},
"time": "2019-12-26T19:37:31+00:00" "time": "2019-12-26T19:37:31+00:00"
}, },
{ {
@ -402,6 +420,10 @@
"container-interop", "container-interop",
"psr" "psr"
], ],
"support": {
"issues": "https://github.com/php-fig/container/issues",
"source": "https://github.com/php-fig/container/tree/master"
},
"time": "2017-02-14T16:28:37+00:00" "time": "2017-02-14T16:28:37+00:00"
}, },
{ {
@ -455,6 +477,9 @@
], ],
"description": "Symfony CssSelector Component", "description": "Symfony CssSelector Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/css-selector/tree/master"
},
"time": "2017-05-01T15:01:29+00:00" "time": "2017-05-01T15:01:29+00:00"
}, },
{ {
@ -490,20 +515,24 @@
], ],
"description": "Action Scheduler for WordPress and WooCommerce", "description": "Action Scheduler for WordPress and WooCommerce",
"homepage": "https://actionscheduler.org/", "homepage": "https://actionscheduler.org/",
"support": {
"issues": "https://github.com/woocommerce/action-scheduler/issues",
"source": "https://github.com/woocommerce/action-scheduler/tree/master"
},
"time": "2020-05-12T16:22:33+00:00" "time": "2020-05-12T16:22:33+00:00"
}, },
{ {
"name": "woocommerce/woocommerce-admin", "name": "woocommerce/woocommerce-admin",
"version": "2.0.3", "version": "2.1.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/woocommerce/woocommerce-admin.git", "url": "https://github.com/woocommerce/woocommerce-admin.git",
"reference": "15f43c9a1e81258c245ff50ba416a36a2cba7e0b" "reference": "60f4297838569341ae88738a4a8a8090889faaac"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/woocommerce/woocommerce-admin/zipball/15f43c9a1e81258c245ff50ba416a36a2cba7e0b", "url": "https://api.github.com/repos/woocommerce/woocommerce-admin/zipball/60f4297838569341ae88738a4a8a8090889faaac",
"reference": "15f43c9a1e81258c245ff50ba416a36a2cba7e0b", "reference": "60f4297838569341ae88738a4a8a8090889faaac",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -535,20 +564,24 @@
], ],
"description": "A modern, javascript-driven WooCommerce Admin experience.", "description": "A modern, javascript-driven WooCommerce Admin experience.",
"homepage": "https://github.com/woocommerce/woocommerce-admin", "homepage": "https://github.com/woocommerce/woocommerce-admin",
"time": "2021-03-10T02:58:43+00:00" "support": {
"issues": "https://github.com/woocommerce/woocommerce-admin/issues",
"source": "https://github.com/woocommerce/woocommerce-admin/tree/v2.1.3"
},
"time": "2021-03-15T04:42:40+00:00"
}, },
{ {
"name": "woocommerce/woocommerce-blocks", "name": "woocommerce/woocommerce-blocks",
"version": "v4.4.3", "version": "v4.7.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/woocommerce/woocommerce-gutenberg-products-block.git", "url": "https://github.com/woocommerce/woocommerce-gutenberg-products-block.git",
"reference": "1eade21846e81d5aaf9bf40cdd1be60778849244" "reference": "bf9f70607e718c5f83785cad29b33746db0282d3"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/woocommerce/woocommerce-gutenberg-products-block/zipball/1eade21846e81d5aaf9bf40cdd1be60778849244", "url": "https://api.github.com/repos/woocommerce/woocommerce-gutenberg-products-block/zipball/bf9f70607e718c5f83785cad29b33746db0282d3",
"reference": "1eade21846e81d5aaf9bf40cdd1be60778849244", "reference": "bf9f70607e718c5f83785cad29b33746db0282d3",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -582,7 +615,11 @@
"gutenberg", "gutenberg",
"woocommerce" "woocommerce"
], ],
"time": "2021-02-11T18:07:48+00:00" "support": {
"issues": "https://github.com/woocommerce/woocommerce-gutenberg-products-block/issues",
"source": "https://github.com/woocommerce/woocommerce-gutenberg-products-block/tree/v4.7.0"
},
"time": "2021-03-16T16:09:55+00:00"
} }
], ],
"packages-dev": [ "packages-dev": [
@ -630,6 +667,10 @@
"isolation", "isolation",
"tool" "tool"
], ],
"support": {
"issues": "https://github.com/bamarni/composer-bin-plugin/issues",
"source": "https://github.com/bamarni/composer-bin-plugin/tree/master"
},
"time": "2020-05-03T08:27:20+00:00" "time": "2020-05-03T08:27:20+00:00"
} }
], ],
@ -645,5 +686,5 @@
"platform-overrides": { "platform-overrides": {
"php": "7.0" "php": "7.0"
}, },
"plugin-api-version": "1.1.0" "plugin-api-version": "2.0.0"
} }

View File

@ -31,11 +31,11 @@ if ( ! defined( 'ABSPATH' ) ) {
$found_method = false; $found_method = false;
foreach ( $shipping_methods as $method ) { foreach ( $shipping_methods as $method ) {
$current_method = ( 0 === strpos( $item->get_method_id(), $method->id ) ) ? $item->get_method_id() : $method->id; $is_active = $item->get_method_id() === $method->id;
echo '<option value="' . esc_attr( $current_method ) . '" ' . selected( $item->get_method_id() === $current_method, true, false ) . '>' . esc_html( $method->get_method_title() ) . '</option>'; echo '<option value="' . esc_attr( $method->id ) . '" ' . selected( true, $is_active, false ) . '>' . esc_html( $method->get_method_title() ) . '</option>';
if ( $item->get_method_id() === $current_method ) { if ( $is_active ) {
$found_method = true; $found_method = true;
} }
} }

View File

@ -1801,10 +1801,26 @@ function wc_ascii_uasort_comparison( $a, $b ) {
function wc_asort_by_locale( &$data, $locale = '' ) { function wc_asort_by_locale( &$data, $locale = '' ) {
// Use Collator if PHP Internationalization Functions (php-intl) is available. // Use Collator if PHP Internationalization Functions (php-intl) is available.
if ( class_exists( 'Collator' ) ) { if ( class_exists( 'Collator' ) ) {
$locale = $locale ? $locale : get_locale(); try {
$collator = new Collator( $locale ); $locale = $locale ? $locale : get_locale();
$collator->asort( $data, Collator::SORT_STRING ); $collator = new Collator( $locale );
return $data; $collator->asort( $data, Collator::SORT_STRING );
return $data;
} catch ( IntlException $e ) {
/*
* Just skip if some error got caused.
* It may be caused in installations that doesn't include ICU TZData.
*/
if ( Constants::is_true( 'WP_DEBUG' ) ) {
error_log( // phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
sprintf(
'An unexpected error occurred while trying to use PHP Intl Collator class, it may be caused by an incorrect installation of PHP Intl and ICU, and could be fixed by reinstallaing PHP Intl, see more details about PHP Intl installation: %1$s. Error message: %2$s',
'https://www.php.net/manual/en/intl.installation.php',
$e->getMessage()
)
);
}
}
} }
$raw_data = $data; $raw_data = $data;

View File

@ -24,6 +24,7 @@
- Shopper Shop Browse Search Sort - Shopper Shop Browse Search Sort
- Merchant Orders Customer Checkout Page - Merchant Orders Customer Checkout Page
- Shopper Cart Apply Coupon - Shopper Cart Apply Coupon
- Merchant Order Searching
- Merchant Settings Shipping Zones - Merchant Settings Shipping Zones
- Shopper Variable product info updates on different variations - Shopper Variable product info updates on different variations
- Merchant order emails flow - Merchant order emails flow

View File

@ -58,6 +58,7 @@ The functions to access the core tests are:
- `runProductEditDetailsTest` - Merchant can edit an existing product - `runProductEditDetailsTest` - Merchant can edit an existing product
- `runProductSearchTest` - Merchant can search for a product and view it - `runProductSearchTest` - Merchant can search for a product and view it
- `runMerchantOrdersCustomerPaymentPage` - Merchant can visit the customer payment page - `runMerchantOrdersCustomerPaymentPage` - Merchant can visit the customer payment page
- `runOrderSearchingTest` - Merchant can search for order via different terms
- `runAddNewShippingZoneTest` - Merchant can create shipping zones and let shopper test them - `runAddNewShippingZoneTest` - Merchant can create shipping zones and let shopper test them
- `runMerchantOrderEmailsTest` - Merchant can receive order emails and resend emails by Order Actions - `runMerchantOrderEmailsTest` - Merchant can receive order emails and resend emails by Order Actions
- `runImportProductsTest` - Merchant can import products via CSV file - `runImportProductsTest` - Merchant can import products via CSV file

View File

@ -35,7 +35,8 @@ const runProductEditDetailsTest = require( './merchant/wp-admin-product-edit-det
const runProductSearchTest = require( './merchant/wp-admin-product-search.test' ); const runProductSearchTest = require( './merchant/wp-admin-product-search.test' );
const runMerchantOrdersCustomerPaymentPage = require( './merchant/wp-admin-order-customer-payment-page.test' ); const runMerchantOrdersCustomerPaymentPage = require( './merchant/wp-admin-order-customer-payment-page.test' );
const runMerchantOrderEmailsTest = require( './merchant/wp-admin-order-emails.test' ); const runMerchantOrderEmailsTest = require( './merchant/wp-admin-order-emails.test' );
const runImportProductsTest = require("./merchant/wp-admin-product-import-csv.test"); const runOrderSearchingTest = require( './merchant/wp-admin-order-searching.test' );
const runImportProductsTest = require( './merchant/wp-admin-product-import-csv.test' );
// REST API tests // REST API tests
const runExternalProductAPITest = require( './api/external-product.test' ); const runExternalProductAPITest = require( './api/external-product.test' );
@ -63,6 +64,7 @@ const runShopperTests = () => {
}; };
const runMerchantTests = () => { const runMerchantTests = () => {
runOrderSearchingTest();
runAddNewShippingZoneTest(); runAddNewShippingZoneTest();
runCreateCouponTest(); runCreateCouponTest();
runCreateOrderTest(); runCreateOrderTest();
@ -123,6 +125,7 @@ module.exports = {
runMerchantOrdersCustomerPaymentPage, runMerchantOrdersCustomerPaymentPage,
runMerchantOrderEmailsTest, runMerchantOrderEmailsTest,
runMerchantTests, runMerchantTests,
runOrderSearchingTest,
runAddNewShippingZoneTest, runAddNewShippingZoneTest,
runProductBrowseSearchSortTest, runProductBrowseSearchSortTest,
runApiTests, runApiTests,

View File

@ -0,0 +1,138 @@
/* eslint-disable jest/no-export, jest/no-disabled-tests, */
/**
* Internal dependencies
*/
const {
merchant,
clearAndFillInput,
selectOptionInSelect2,
searchForOrder,
createSimpleProduct,
addProductToOrder,
clickUpdateOrder,
} = require( '@woocommerce/e2e-utils' );
const runOrderSearchingTest = () => {
describe('WooCommerce Orders > Search orders', () => {
let orderId;
beforeAll(async () => {
await merchant.login();
await createSimpleProduct('Wanted Product');
await Promise.all([
// Create new order for testing
await merchant.openNewOrder(),
await page.waitForSelector('#order_status'),
await page.click('#customer_user'),
await page.click('span.select2-search > input.select2-search__field'),
await page.type('span.select2-search > input.select2-search__field', 'Customer'),
await page.waitFor(2000), // to avoid flakyness
await page.keyboard.press('Enter'),
]);
await Promise.all([
// Change the shipping data
await page.waitFor(1000), // to avoid flakiness
await page.waitForSelector('#_shipping_first_name'),
await clearAndFillInput('#_shipping_first_name', 'Tim'),
await clearAndFillInput('#_shipping_last_name', 'Clark'),
await clearAndFillInput('#_shipping_address_1', 'Oxford Ave'),
await clearAndFillInput('#_shipping_address_2', 'Linwood Ave'),
await clearAndFillInput('#_shipping_city', 'Buffalo'),
await clearAndFillInput('#_shipping_postcode', '14201'),
await page.keyboard.press('Tab'),
await page.keyboard.press('Tab'),
await page.keyboard.press('Enter'),
await page.select('select[name="_shipping_state"]', 'NY'),
]);
// Get the post id
const variablePostId = await page.$('#post_ID');
orderId = (await(await variablePostId.getProperty('value')).jsonValue());
// Save new order
await clickUpdateOrder('Order updated.', true);
await addProductToOrder(orderId, 'Wanted Product');
await merchant.openAllOrdersView();
});
it('can search for order by order id', async () => {
await searchForOrder(orderId, orderId, 'John Doe');
});
it('can search for order by billing first name', async () => {
await searchForOrder('John', orderId, 'John Doe');
})
it('can search for order by billing last name', async () => {
await searchForOrder('Doe', orderId, 'John Doe');
})
it('can search for order by billing company name', async () => {
await searchForOrder('Automattic', orderId, 'John Doe');
})
it('can search for order by billing first address', async () => {
await searchForOrder('addr 1', orderId, 'John Doe');
})
it('can search for order by billing second address', async () => {
await searchForOrder('addr 2', orderId, 'John Doe');
})
it('can search for order by billing city name', async () => {
await searchForOrder('San Francisco', orderId, 'John Doe');
})
it('can search for order by billing post code', async () => {
await searchForOrder('94107', orderId, 'John Doe');
})
it('can search for order by billing email', async () => {
await searchForOrder('john.doe@example.com', orderId, 'John Doe');
})
it('can search for order by billing phone', async () => {
await searchForOrder('123456789', orderId, 'John Doe');
})
it('can search for order by billing state', async () => {
await searchForOrder('CA', orderId, 'John Doe');
})
it('can search for order by shipping first name', async () => {
await searchForOrder('Tim', orderId, 'John Doe');
})
it('can search for order by shipping last name', async () => {
await searchForOrder('Clark', orderId, 'John Doe');
})
it('can search for order by shipping first address', async () => {
await searchForOrder('Oxford Ave', orderId, 'John Doe');
})
it('can search for order by shipping second address', async () => {
await searchForOrder('Linwood Ave', orderId, 'John Doe');
})
it('can search for order by shipping city name', async () => {
await searchForOrder('Buffalo', orderId, 'John Doe');
})
it('can search for order by shipping postcode name', async () => {
await searchForOrder('14201', orderId, 'John Doe');
})
it('can search for order by shipping state name', async () => {
await searchForOrder('NY', orderId, 'John Doe');
})
it('can search for order by item name', async () => {
await searchForOrder('Wanted Product', orderId, 'John Doe');
})
});
};
module.exports = runOrderSearchingTest;

View File

@ -11,6 +11,7 @@ const {
clearAndFillInput, clearAndFillInput,
selectOptionInSelect2, selectOptionInSelect2,
evalAndClick, evalAndClick,
uiUnblocked,
} = require( '@woocommerce/e2e-utils' ); } = require( '@woocommerce/e2e-utils' );
const config = require( 'config' ); const config = require( 'config' );
@ -29,14 +30,24 @@ const runAddNewShippingZoneTest = () => {
await createSimpleProduct(); await createSimpleProduct();
await merchant.openSettings('shipping'); await merchant.openSettings('shipping');
// Check if you can go via blank shipping zones, otherwise remove one existing zone // Delete existing shipping zones.
// This is a workaround to avoid flakyness and to give this test more confidence
try { try {
await page.click('.wc-shipping-zones-blank-state > a.wc-shipping-zone-add'); let zone = await page.$( '.wc-shipping-zone-delete' );
if ( zone ) {
// WP action links aren't clickable because they are hidden with a left=-9999 style.
await page.evaluate(() => {
document.querySelector('.wc-shipping-zone-name .row-actions')
.style
.left = '0';
});
while ( zone ) {
await evalAndClick( '.wc-shipping-zone-delete' );
await uiUnblocked();
zone = await page.$( '.wc-shipping-zone-delete' );
}
}
} catch (error) { } catch (error) {
await evalAndClick('.wc-shipping-zone-delete'); // Prevent an error here causing the test to fail.
await page.keyboard.press('Enter');
} }
}); });
@ -55,9 +66,9 @@ const runAddNewShippingZoneTest = () => {
await addShippingZoneAndMethod(shippingZoneNameUS); await addShippingZoneAndMethod(shippingZoneNameUS);
// Set Flat rate cost // Set Flat rate cost
await expect(page).toClick('a.wc-shipping-zone-method-settings', {text: 'Edit'}); await expect(page).toClick('a.wc-shipping-zone-method-settings', {text: 'Flat rate'});
await clearAndFillInput('#woocommerce_flat_rate_cost', '10'); await clearAndFillInput('#woocommerce_flat_rate_cost', '10');
await expect(page).toClick('button#btn-ok'); await expect(page).toClick('.wc-backbone-modal-main button#btn-ok');
await merchant.logout(); await merchant.logout();
}); });

View File

@ -66,6 +66,9 @@ const runCheckoutApplyCouponsTest = () => {
it('allows customer to apply fixed product coupon', async () => { it('allows customer to apply fixed product coupon', async () => {
await applyCoupon(couponFixedProduct); await applyCoupon(couponFixedProduct);
await expect(page).toMatchElement('.woocommerce-message', {text: 'Coupon code applied successfully.'}); await expect(page).toMatchElement('.woocommerce-message', {text: 'Coupon code applied successfully.'});
// Verify discount applied and order total
await page.waitForSelector('.order-total');
await expect(page).toMatchElement('.cart-discount .amount', {text: '$5.00'}); await expect(page).toMatchElement('.cart-discount .amount', {text: '$5.00'});
await expect(page).toMatchElement('.order-total .amount', {text: '$4.99'}); await expect(page).toMatchElement('.order-total .amount', {text: '$4.99'});
await removeCoupon(couponFixedProduct); await removeCoupon(couponFixedProduct);
@ -84,6 +87,9 @@ const runCheckoutApplyCouponsTest = () => {
it('allows customer to apply multiple coupons', async () => { it('allows customer to apply multiple coupons', async () => {
await applyCoupon(couponFixedProduct); await applyCoupon(couponFixedProduct);
await expect(page).toMatchElement('.woocommerce-message', {text: 'Coupon code applied successfully.'}); await expect(page).toMatchElement('.woocommerce-message', {text: 'Coupon code applied successfully.'});
// Verify discount applied and order total
await page.waitForSelector('.order-total');
await expect(page).toMatchElement('.order-total .amount', {text: '$0.00'}); await expect(page).toMatchElement('.order-total .amount', {text: '$0.00'});
}); });

View File

@ -0,0 +1,6 @@
/*
* Internal dependencies
*/
const { runOrderSearchingTest } = require( '@woocommerce/e2e-core-tests' );
runOrderSearchingTest();

View File

@ -17,6 +17,7 @@
- `createCoupon( couponAmount )` component which accepts a coupon amount string (it defaults to 5) and creates a basic coupon. Returns the generated coupon code. - `createCoupon( couponAmount )` component which accepts a coupon amount string (it defaults to 5) and creates a basic coupon. Returns the generated coupon code.
- `evalAndClick( selector )` use Puppeteer page.$eval to select and click and element. - `evalAndClick( selector )` use Puppeteer page.$eval to select and click and element.
- `selectOptionInSelect2( selector, value )` util helper method that search and select in any select2 type field - `selectOptionInSelect2( selector, value )` util helper method that search and select in any select2 type field
- `searchForOrder( value, orderId, customerName )` util helper method that search order with different terms
- `addShippingZoneAndMethod( zoneName, zoneLocation, zipCode, zoneMethod )` util helper method for adding shipping zones with shipping methods - `addShippingZoneAndMethod( zoneName, zoneLocation, zipCode, zoneMethod )` util helper method for adding shipping zones with shipping methods
- `createSimpleProductWithCategory` component which creates a simple product with categories, containing three parameters for title, price and category name. - `createSimpleProductWithCategory` component which creates a simple product with categories, containing three parameters for title, price and category name.
- `applyCoupon( couponName )` util helper method which applies previously created coupon to cart or checkout - `applyCoupon( couponName )` util helper method which applies previously created coupon to cart or checkout

View File

@ -104,10 +104,11 @@ describe( 'Cart page', () => {
| `clickFilter` | `selector` | Click on a list page filter | | `clickFilter` | `selector` | Click on a list page filter |
| `moveAllItemsToTrash` | | Moves all items in a list view to the Trash | | `moveAllItemsToTrash` | | Moves all items in a list view to the Trash |
| `verifyAndPublish` | `noticeText` | Verify that an item can be published | | `verifyAndPublish` | `noticeText` | Verify that an item can be published |
| `selectOptionInSelect2` | `selector, value` | helper method that searchs for select2 type fields and select plus insert value inside | `selectOptionInSelect2` | `selector, value` | helper method that searchs for select2 type fields and select plus insert value inside |
| `addShippingZoneAndMethod` | `zoneName, zoneLocation, zipCode, zoneMethod` | util helper method for adding shipping zones with shipping methods | `searchForOrder` | `value, orderId, customerName` | helper method that searchs for an order via many different terms |
| `applyCoupon` | `couponName` | helper method which applies a coupon in cart or checkout | `addShippingZoneAndMethod` | `zoneName, zoneLocation, zipCode, zoneMethod` | util helper method for adding shipping zones with shipping methods |
| `removeCoupon` | | helper method that removes a single coupon within cart or checkout | `applyCoupon` | `couponName` | helper method which applies a coupon in cart or checkout |
| `removeCoupon` | | helper method that removes a single coupon within cart or checkout |
| `selectOrderAction` | `action` | Helper method to select an order action in the `Order Actions` postbox | | `selectOrderAction` | `action` | Helper method to select an order action in the `Order Actions` postbox |
| `clickUpdateOrder` | `noticeText`, `waitForSave` | Helper method to click the Update button on the order details page | | `clickUpdateOrder` | `noticeText`, `waitForSave` | Helper method to click the Update button on the order details page |

View File

@ -175,11 +175,14 @@ const completeOnboardingWizard = async () => {
/** /**
* Create simple product. * Create simple product.
*
* @param productTitle - Defaults to Simple Product. Customizable title.
* @param productPrice - Defaults to $9.99. Customizable pricing.
*/ */
const createSimpleProduct = async () => { const createSimpleProduct = async ( productTitle = simpleProductName, productPrice = simpleProductPrice ) => {
const product = await factories.products.simple.create( { const product = await factories.products.simple.create( {
name: simpleProductName, name: productTitle,
regularPrice: simpleProductPrice regularPrice: productPrice
} ); } );
return product.id; return product.id;
} ; } ;
@ -467,7 +470,7 @@ const createCoupon = async ( couponAmount = '5', discountType = 'Fixed cart disc
*/ */
const addShippingZoneAndMethod = async ( zoneName, zoneLocation = 'United States (US)', zipCode = ' ', zoneMethod = 'flat_rate' ) => { const addShippingZoneAndMethod = async ( zoneName, zoneLocation = 'United States (US)', zipCode = ' ', zoneMethod = 'flat_rate' ) => {
await merchant.openNewShipping(); await merchant.openNewShipping();
// Fill shipping zone name // Fill shipping zone name
await page.waitForSelector('input#zone_name'); await page.waitForSelector('input#zone_name');
await expect(page).toFill('input#zone_name', zoneName); await expect(page).toFill('input#zone_name', zoneName);
@ -475,9 +478,9 @@ const addShippingZoneAndMethod = async ( zoneName, zoneLocation = 'United States
// Select shipping zone location // Select shipping zone location
// (.toSelect is not best option here because a lot of &nbsp are present in country/state names) // (.toSelect is not best option here because a lot of &nbsp are present in country/state names)
await expect(page).toFill('#zone_locations', zoneLocation); await expect(page).toFill('#zone_locations', zoneLocation);
await page.waitFor(1000); // avoiding flakiness await uiUnblocked();
await page.keyboard.press('Tab'); await page.keyboard.press('Tab');
await page.waitFor(1000); // avoiding flakiness await uiUnblocked();
await page.keyboard.press('Enter'); await page.keyboard.press('Enter');
// Fill shipping zone postcode if needed otherwise just put empty space // Fill shipping zone postcode if needed otherwise just put empty space
@ -488,15 +491,14 @@ const addShippingZoneAndMethod = async ( zoneName, zoneLocation = 'United States
await expect(page).toClick('button#submit'); await expect(page).toClick('button#submit');
// Add shipping zone method // Add shipping zone method
await page.waitFor(2000); // avoiding flakiness await uiUnblocked();
await expect(page).toClick('button.wc-shipping-zone-add-method', {text:'Add shipping method'}); await expect(page).toClick('button.wc-shipping-zone-add-method', {text:'Add shipping method'});
await page.waitFor(2000); // avoiding flakiness await page.waitForSelector('.wc-shipping-zone-method-selector');
await page.waitForSelector('.wc-shipping-zone-method-description');
await expect(page).toSelect('select[name="add_method_id"]', zoneMethod); await expect(page).toSelect('select[name="add_method_id"]', zoneMethod);
await page.waitFor(1000); // avoiding flakiness await uiUnblocked();
await expect(page).toClick('button#btn-ok'); await expect(page).toClick('button#btn-ok');
await page.waitForSelector('#zone_locations'); await page.waitForSelector('#zone_locations');
await page.waitFor(1000); // avoiding flakiness await uiUnblocked();
}; };
/** /**

View File

@ -198,18 +198,35 @@ const evalAndClick = async ( selector ) => {
}; };
/** /**
* Select a value from select2 input field. * Select a value from select2 search input field.
* *
* @param {string} value Value of what to be selected * @param {string} value Value of what to be selected
* @param {string} selector Selector of the select2 * @param {string} selector Selector of the select2 search field
*/ */
const selectOptionInSelect2 = async ( value, selector = 'input.select2-search__field' ) => { const selectOptionInSelect2 = async ( value, selector = 'input.select2-search__field' ) => {
await page.waitForSelector(selector); await page.waitForSelector(selector);
await page.click(selector);
await page.type(selector, value); await page.type(selector, value);
await page.waitFor(2000); // to avoid flakyness, must wait before pressing Enter await page.waitFor(2000); // to avoid flakyness, must wait before pressing Enter
await page.keyboard.press('Enter'); await page.keyboard.press('Enter');
}; };
/**
* Search by any term for an order
*
* @param {string} value Value to be entered into the search field
* @param {string} orderId Order ID
* @param {string} customerName Customer's full name attached to order ID.
*/
const searchForOrder = async (value, orderId, customerName) => {
await clearAndFillInput('#post-search-input', value);
await expect(page).toMatchElement('#post-search-input', value);
await expect(page).toClick('#search-submit');
await page.waitForSelector('#the-list');
await page.waitFor(1000);
await expect(page).toMatchElement('.order_number > a.order-view', {text: `#${orderId} ${customerName}`});
};
/** /**
* Apply a coupon code within cart or checkout. * Apply a coupon code within cart or checkout.
* Method will try to apply a coupon in the checkout, otherwise will try to apply in the cart. * Method will try to apply a coupon in the checkout, otherwise will try to apply in the cart.
@ -273,7 +290,8 @@ export {
moveAllItemsToTrash, moveAllItemsToTrash,
evalAndClick, evalAndClick,
selectOptionInSelect2, selectOptionInSelect2,
applyCoupon, searchForOrder,
applyCoupon,
removeCoupon, removeCoupon,
selectOrderAction, selectOrderAction,
}; };