add the billing address to the customer account
This commit is contained in:
parent
b63a166dbb
commit
70ff64d427
|
@ -10,18 +10,57 @@ const {
|
||||||
createSimpleProduct,
|
createSimpleProduct,
|
||||||
addProductToOrder,
|
addProductToOrder,
|
||||||
clickUpdateOrder,
|
clickUpdateOrder,
|
||||||
|
factories,
|
||||||
|
selectOptionInSelect2,
|
||||||
} = require( '@woocommerce/e2e-utils' );
|
} = require( '@woocommerce/e2e-utils' );
|
||||||
|
|
||||||
const searchString = 'Jane Smith';
|
const searchString = 'Jane Smith';
|
||||||
|
const customerBilling = {
|
||||||
|
firstname: 'Jane',
|
||||||
|
lastname: 'Smith',
|
||||||
|
company: 'Automattic',
|
||||||
|
country: 'US',
|
||||||
|
address_1: 'address1',
|
||||||
|
address_2: 'address2',
|
||||||
|
city: 'San Francisco',
|
||||||
|
state: 'CA',
|
||||||
|
postcode: '94107',
|
||||||
|
phone: '123456789',
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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,
|
||||||
|
};
|
||||||
|
await client.put( customerEndpoint + customerId, customerData );
|
||||||
|
};
|
||||||
|
|
||||||
const runOrderSearchingTest = () => {
|
const runOrderSearchingTest = () => {
|
||||||
describe('WooCommerce Orders > Search orders', () => {
|
describe('WooCommerce Orders > Search orders', () => {
|
||||||
let orderId;
|
let orderId;
|
||||||
beforeAll(async () => {
|
beforeAll( async () => {
|
||||||
await merchant.login();
|
|
||||||
await createSimpleProduct('Wanted Product');
|
await createSimpleProduct('Wanted Product');
|
||||||
|
await updateCustomerBilling();
|
||||||
|
|
||||||
// Create new order for testing
|
// Create new order for testing
|
||||||
|
await merchant.login();
|
||||||
await merchant.openNewOrder();
|
await merchant.openNewOrder();
|
||||||
await page.waitForSelector('#order_status');
|
await page.waitForSelector('#order_status');
|
||||||
await page.click('#customer_user');
|
await page.click('#customer_user');
|
||||||
|
@ -41,6 +80,7 @@ const runOrderSearchingTest = () => {
|
||||||
await clearAndFillInput('#_shipping_address_2', 'Linwood Ave');
|
await clearAndFillInput('#_shipping_address_2', 'Linwood Ave');
|
||||||
await clearAndFillInput('#_shipping_city', 'Buffalo');
|
await clearAndFillInput('#_shipping_city', 'Buffalo');
|
||||||
await clearAndFillInput('#_shipping_postcode', '14201');
|
await clearAndFillInput('#_shipping_postcode', '14201');
|
||||||
|
await selectOptionInSelect2('New York', '._shipping_state_field .select2');
|
||||||
|
|
||||||
// Get the post id
|
// Get the post id
|
||||||
const variablePostId = await page.$('#post_ID');
|
const variablePostId = await page.$('#post_ID');
|
||||||
|
@ -59,43 +99,43 @@ const runOrderSearchingTest = () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can search for order by billing first name', async () => {
|
it('can search for order by billing first name', async () => {
|
||||||
await searchForOrder('John', orderId, searchString);
|
await searchForOrder('Jane', orderId, searchString);
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can search for order by billing last name', async () => {
|
it('can search for order by billing last name', async () => {
|
||||||
await searchForOrder('Doe', orderId, searchString);
|
await searchForOrder('Smith', orderId, searchString);
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can search for order by billing company name', async () => {
|
it('can search for order by billing company name', async () => {
|
||||||
await searchForOrder('Automattic', orderId, searchString);
|
await searchForOrder(customerBilling.company, orderId, searchString);
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can search for order by billing first address', async () => {
|
it('can search for order by billing first address', async () => {
|
||||||
await searchForOrder('addr 1', orderId, searchString);
|
await searchForOrder(customerBilling.address_1, orderId, searchString);
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can search for order by billing second address', async () => {
|
it('can search for order by billing second address', async () => {
|
||||||
await searchForOrder('addr 2', orderId, searchString);
|
await searchForOrder(customerBilling.address_2, orderId, searchString);
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can search for order by billing city name', async () => {
|
it('can search for order by billing city name', async () => {
|
||||||
await searchForOrder('San Francisco', orderId, searchString);
|
await searchForOrder(customerBilling.city, orderId, searchString);
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can search for order by billing post code', async () => {
|
it('can search for order by billing post code', async () => {
|
||||||
await searchForOrder('94107', orderId, searchString);
|
await searchForOrder(customerBilling.postcode, orderId, searchString);
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can search for order by billing email', async () => {
|
it('can search for order by billing email', async () => {
|
||||||
await searchForOrder('john.doe@example.com', orderId, searchString);
|
await searchForOrder('customer@woocommercecoree2etestsuite.com', orderId, searchString);
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can search for order by billing phone', async () => {
|
it('can search for order by billing phone', async () => {
|
||||||
await searchForOrder('123456789', orderId, searchString);
|
await searchForOrder(customerBilling.phone, orderId, searchString);
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can search for order by billing state', async () => {
|
it('can search for order by billing state', async () => {
|
||||||
await searchForOrder('CA', orderId, searchString);
|
await searchForOrder(customerBilling.state, orderId, searchString);
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can search for order by shipping first name', async () => {
|
it('can search for order by shipping first name', async () => {
|
||||||
|
@ -123,7 +163,7 @@ const runOrderSearchingTest = () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can search for order by shipping state name', async () => {
|
it('can search for order by shipping state name', async () => {
|
||||||
await searchForOrder('CA', orderId, searchString);
|
await searchForOrder('New York', orderId, searchString);
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can search for order by item name', async () => {
|
it('can search for order by item name', async () => {
|
||||||
|
|
Loading…
Reference in New Issue