Merge pull request #29770 from woocommerce/fix/29769
user customer user for order search
This commit is contained in:
commit
c51fce6bb4
|
@ -10,36 +10,80 @@ const {
|
|||
createSimpleProduct,
|
||||
addProductToOrder,
|
||||
clickUpdateOrder,
|
||||
factories,
|
||||
selectOptionInSelect2,
|
||||
} = require( '@woocommerce/e2e-utils' );
|
||||
|
||||
const searchString = 'John Doe';
|
||||
const customerBilling = {
|
||||
first_name: 'John',
|
||||
last_name: 'Doe',
|
||||
company: 'Automattic',
|
||||
country: 'US',
|
||||
address_1: 'address1',
|
||||
address_2: 'address2',
|
||||
city: 'San Francisco',
|
||||
state: 'CA',
|
||||
postcode: '94107',
|
||||
phone: '123456789',
|
||||
email: 'john.doe@example.com',
|
||||
};
|
||||
const customerShipping = {
|
||||
first_name: 'Tim',
|
||||
last_name: 'Clark',
|
||||
company: 'Automattic',
|
||||
country: 'US',
|
||||
address_1: 'Oxford Ave',
|
||||
address_2: 'Linwood Ave',
|
||||
city: 'Buffalo',
|
||||
state: 'NY',
|
||||
postcode: '14201',
|
||||
phone: '123456789',
|
||||
email: 'john.doe@example.com',
|
||||
};
|
||||
|
||||
/**
|
||||
* Set the billing fields for the customer account for this test suite.
|
||||
*
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
const updateCustomerBilling = async () => {
|
||||
const client = factories.api.withDefaultPermalinks;
|
||||
const customerEndpoint = 'wc/v3/customers/';
|
||||
const customers = await client.get( customerEndpoint, {
|
||||
search: 'Jane',
|
||||
role: 'all',
|
||||
} );
|
||||
if ( ! customers.data | ! customers.data.length ) {
|
||||
return;
|
||||
}
|
||||
|
||||
const customerId = customers.data[0].id;
|
||||
const customerData = {
|
||||
id: customerId,
|
||||
billing: customerBilling,
|
||||
shipping: customerShipping,
|
||||
};
|
||||
await client.put( customerEndpoint + customerId, customerData );
|
||||
};
|
||||
|
||||
const runOrderSearchingTest = () => {
|
||||
describe('WooCommerce Orders > Search orders', () => {
|
||||
let orderId;
|
||||
beforeAll(async () => {
|
||||
await merchant.login();
|
||||
beforeAll( async () => {
|
||||
await createSimpleProduct('Wanted Product');
|
||||
await updateCustomerBilling();
|
||||
|
||||
// Create new order for testing
|
||||
await merchant.login();
|
||||
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.type('span.select2-search > input.select2-search__field', 'Jane Smith');
|
||||
await page.waitFor(2000); // to avoid flakyness
|
||||
await page.keyboard.press('Enter');
|
||||
|
||||
// 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());
|
||||
|
@ -53,79 +97,82 @@ const runOrderSearchingTest = () => {
|
|||
});
|
||||
|
||||
it('can search for order by order id', async () => {
|
||||
await searchForOrder(orderId, orderId, 'John Doe');
|
||||
await searchForOrder(orderId, orderId, searchString);
|
||||
});
|
||||
|
||||
it('can search for order by billing first name', async () => {
|
||||
await searchForOrder('John', orderId, 'John Doe');
|
||||
await searchForOrder(customerBilling.first_name, orderId, searchString);
|
||||
})
|
||||
|
||||
it('can search for order by billing last name', async () => {
|
||||
await searchForOrder('Doe', orderId, 'John Doe');
|
||||
await searchForOrder(customerBilling.last_name, orderId, searchString);
|
||||
})
|
||||
|
||||
it('can search for order by billing company name', async () => {
|
||||
await searchForOrder('Automattic', orderId, 'John Doe');
|
||||
await searchForOrder(customerBilling.company, orderId, searchString);
|
||||
})
|
||||
|
||||
it('can search for order by billing first address', async () => {
|
||||
await searchForOrder('addr 1', orderId, 'John Doe');
|
||||
await searchForOrder(customerBilling.address_1, orderId, searchString);
|
||||
})
|
||||
|
||||
it('can search for order by billing second address', async () => {
|
||||
await searchForOrder('addr 2', orderId, 'John Doe');
|
||||
await searchForOrder(customerBilling.address_2, orderId, searchString);
|
||||
})
|
||||
|
||||
it('can search for order by billing city name', async () => {
|
||||
await searchForOrder('San Francisco', orderId, 'John Doe');
|
||||
await searchForOrder(customerBilling.city, orderId, searchString);
|
||||
})
|
||||
|
||||
it('can search for order by billing post code', async () => {
|
||||
await searchForOrder('94107', orderId, 'John Doe');
|
||||
await searchForOrder(customerBilling.postcode, orderId, searchString);
|
||||
})
|
||||
|
||||
it('can search for order by billing email', async () => {
|
||||
await searchForOrder('john.doe@example.com', orderId, 'John Doe');
|
||||
await searchForOrder(customerBilling.email, orderId, searchString);
|
||||
})
|
||||
|
||||
it('can search for order by billing phone', async () => {
|
||||
await searchForOrder('123456789', orderId, 'John Doe');
|
||||
await searchForOrder(customerBilling.phone, orderId, searchString);
|
||||
})
|
||||
|
||||
it('can search for order by billing state', async () => {
|
||||
await searchForOrder('CA', orderId, 'John Doe');
|
||||
await searchForOrder(customerBilling.state, orderId, searchString);
|
||||
})
|
||||
|
||||
it('can search for order by shipping first name', async () => {
|
||||
await searchForOrder('Tim', orderId, 'John Doe');
|
||||
await searchForOrder(customerShipping.first_name, orderId, searchString);
|
||||
})
|
||||
|
||||
it('can search for order by shipping last name', async () => {
|
||||
await searchForOrder('Clark', orderId, 'John Doe');
|
||||
await searchForOrder(customerShipping.last_name, orderId, searchString);
|
||||
})
|
||||
|
||||
it('can search for order by shipping first address', async () => {
|
||||
await searchForOrder('Oxford Ave', orderId, 'John Doe');
|
||||
await searchForOrder(customerShipping.address_1, orderId, searchString);
|
||||
})
|
||||
|
||||
it('can search for order by shipping second address', async () => {
|
||||
await searchForOrder('Linwood Ave', orderId, 'John Doe');
|
||||
await searchForOrder(customerShipping.address_2, orderId, searchString);
|
||||
})
|
||||
|
||||
it('can search for order by shipping city name', async () => {
|
||||
await searchForOrder('Buffalo', orderId, 'John Doe');
|
||||
await searchForOrder(customerShipping.city, orderId, searchString);
|
||||
})
|
||||
|
||||
it('can search for order by shipping postcode name', async () => {
|
||||
await searchForOrder('14201', orderId, 'John Doe');
|
||||
await searchForOrder(customerShipping.postcode, orderId, searchString);
|
||||
})
|
||||
|
||||
it('can search for order by shipping state name', async () => {
|
||||
await searchForOrder('CA', orderId, 'John Doe');
|
||||
/**
|
||||
* shipping state is abbreviated. This test passes if billing and shipping state are the same
|
||||
*/
|
||||
it.skip('can search for order by shipping state name', async () => {
|
||||
await searchForOrder('New York', orderId, searchString);
|
||||
})
|
||||
|
||||
it('can search for order by item name', async () => {
|
||||
await searchForOrder('Wanted Product', orderId, 'John Doe');
|
||||
await searchForOrder('Wanted Product', orderId, searchString);
|
||||
})
|
||||
});
|
||||
};
|
||||
|
|
|
@ -4,7 +4,12 @@ echo "Initializing WooCommerce E2E"
|
|||
|
||||
wp plugin activate woocommerce
|
||||
wp theme install twentynineteen --activate
|
||||
wp user create customer customer@woocommercecoree2etestsuite.com --user_pass=password --role=subscriber --path=/var/www/html
|
||||
wp user create customer customer@woocommercecoree2etestsuite.com \
|
||||
--user_pass=password \
|
||||
--role=subscriber \
|
||||
--first_name='Jane' \
|
||||
--last_name='Smith' \
|
||||
--path=/var/www/html
|
||||
|
||||
# we cannot create API keys for the API, so we using basic auth, this plugin allows that.
|
||||
wp plugin install https://github.com/WP-API/Basic-Auth/archive/master.zip --activate
|
||||
|
|
|
@ -43,7 +43,10 @@ if ( appPath ) {
|
|||
if ( ! fs.existsSync( customInitFile ) ) {
|
||||
customInitFile = '';
|
||||
}
|
||||
} else {
|
||||
customInitFile = '';
|
||||
}
|
||||
|
||||
const appInitFile = customInitFile ? customInitFile : path.resolve( appPath, 'tests/e2e/docker/initialize.sh' );
|
||||
// If found, copy it into the wp-cli Docker context so
|
||||
// it gets picked up by the entrypoint script.
|
||||
|
|
Loading…
Reference in New Issue