Merge branch 'trunk' into e2e/e2e-shopper-login-checkout

This commit is contained in:
Veljko 2021-04-01 19:35:29 +02:00
commit daf41aadb9
3 changed files with 40 additions and 46 deletions

View File

@ -6,7 +6,6 @@
const {
merchant,
clearAndFillInput,
selectOptionInSelect2,
searchForOrder,
createSimpleProduct,
addProductToOrder,
@ -20,40 +19,36 @@ const runOrderSearchingTest = () => {
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'),
]);
// 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'),
]);
// Change the shipping data
await page.waitFor(1000); // to avoid flakiness
await page.click('.billing-same-as-shipping');
await page.keyboard.press('Enter');
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');
// Get the post id
const variablePostId = await page.$('#post_ID');
orderId = (await(await variablePostId.getProperty('value')).jsonValue());
// Save new order
// Save new order and add desired product to order
await clickUpdateOrder('Order updated.', true);
await addProductToOrder(orderId, 'Wanted Product');
// Open All Orders view
await merchant.openAllOrdersView();
});
@ -126,7 +121,7 @@ const runOrderSearchingTest = () => {
})
it('can search for order by shipping state name', async () => {
await searchForOrder('NY', orderId, 'John Doe');
await searchForOrder('CA', orderId, 'John Doe');
})
it('can search for order by item name', async () => {

View File

@ -17,7 +17,7 @@ const {
const config = require( 'config' );
const simpleProductPrice = config.has( 'products.simple.price' ) ? config.get( 'products.simple.price' ) : '9.99';
const simpleProductName = config.get( 'products.simple.name' );
const california = 'California, United States (US)';
const california = 'state:US:CA';
const sanFranciscoZIP = '94107';
const shippingZoneNameUS = 'US with Flat rate';
const shippingZoneNameFL = 'CA with Free shipping';
@ -90,10 +90,6 @@ const runAddNewShippingZoneTest = () => {
await selectOptionInSelect2('New York');
await expect(page).toClick('button[name="calc_shipping"]');
// Set shipping postcode to 10010
await clearAndFillInput('#calc_shipping_postcode', '10010');
await expect(page).toClick('button[name="calc_shipping"]');
// Verify shipping costs
await page.waitForSelector('.order-total');
await expect(page).toMatchElement('.shipping .amount', {text: '$10.00'});
@ -102,6 +98,7 @@ const runAddNewShippingZoneTest = () => {
it('allows customer to benefit from a Free shipping if in CA', async () => {
await page.reload();
// Set shipping state to California
await expect(page).toClick('a.shipping-calculator-button');
await expect(page).toClick('#select2-calc_shipping_state-container');
@ -119,6 +116,7 @@ const runAddNewShippingZoneTest = () => {
it('allows customer to benefit from a free Local pickup if in SF', async () => {
await page.reload();
// Set shipping postcode to 94107
await expect(page).toClick('a.shipping-calculator-button');
await clearAndFillInput('#calc_shipping_postcode', '94107');

View File

@ -6,7 +6,14 @@
* Internal dependencies
*/
import { merchant } from './flows';
import { clickTab, uiUnblocked, verifyCheckboxIsUnset, evalAndClick, selectOptionInSelect2, setCheckbox } from './page-utils';
import {
clickTab,
uiUnblocked,
verifyCheckboxIsUnset,
selectOptionInSelect2,
setCheckbox,
unsetCheckbox
} from './page-utils';
import factories from './factories';
const config = require( 'config' );
@ -143,7 +150,8 @@ const completeOnboardingWizard = async () => {
await waitAndClickPrimary( false );
// Skip installing extensions
await evalAndClick( '.components-checkbox-control__input' );
await unsetCheckbox( '.components-checkbox-control__input' );
await verifyCheckboxIsUnset( '.components-checkbox-control__input' );
await waitAndClickPrimary();
// Theme section
@ -464,11 +472,11 @@ const createCoupon = async ( couponAmount = '5', discountType = 'Fixed cart disc
* Adds a shipping zone along with a shipping method.
*
* @param zoneName Shipping zone name.
* @param zoneLocation Shiping zone location. Defaults to United States (US).
* @param zoneLocation Shiping zone location. Defaults to country:US. For states use: state:US:CA
* @param zipCode Shipping zone zip code. Defaults to empty one space.
* @param zoneMethod Shipping method type. Defaults to flat_rate (use also: free_shipping or local_pickup)
*/
const addShippingZoneAndMethod = async ( zoneName, zoneLocation = 'United States (US)', zipCode = ' ', zoneMethod = 'flat_rate' ) => {
const addShippingZoneAndMethod = async ( zoneName, zoneLocation = 'country:US', zipCode = ' ', zoneMethod = 'flat_rate' ) => {
await merchant.openNewShipping();
// Fill shipping zone name
@ -476,12 +484,7 @@ const addShippingZoneAndMethod = async ( zoneName, zoneLocation = 'United States
await expect(page).toFill('input#zone_name', zoneName);
// Select shipping zone location
// (.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 uiUnblocked();
await page.keyboard.press('Tab');
await uiUnblocked();
await page.keyboard.press('Enter');
await expect(page).toSelect('select[name="zone_locations"]', zoneLocation);
// Fill shipping zone postcode if needed otherwise just put empty space
await page.waitForSelector('a.wc-shipping-zone-postcodes-toggle');
@ -491,14 +494,12 @@ const addShippingZoneAndMethod = async ( zoneName, zoneLocation = 'United States
await expect(page).toClick('button#submit');
// Add shipping zone method
await uiUnblocked();
await page.waitFor(1000);
await expect(page).toClick('button.wc-shipping-zone-add-method', {text:'Add shipping method'});
await page.waitForSelector('.wc-shipping-zone-method-selector');
await expect(page).toSelect('select[name="add_method_id"]', zoneMethod);
await uiUnblocked();
await expect(page).toClick('button#btn-ok');
await page.waitForSelector('#zone_locations');
await uiUnblocked();
};
/**