2021-04-14 14:50:27 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { shopper as wcShopper } from '@woocommerce/e2e-utils';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import { getBlockPagePermalink } from './get-block-page-permalink';
|
|
|
|
|
|
|
|
export const shopper = {
|
|
|
|
...wcShopper,
|
|
|
|
|
|
|
|
goToCheckoutBlock: async () => {
|
|
|
|
const checkoutBlockPermalink = await getBlockPagePermalink(
|
|
|
|
`Checkout Block`
|
|
|
|
);
|
|
|
|
|
|
|
|
await page.goto( checkoutBlockPermalink, {
|
|
|
|
waitUntil: 'networkidle0',
|
|
|
|
} );
|
2021-05-18 13:09:30 +00:00
|
|
|
await page.waitForSelector( 'h1', { text: 'Checkout' } );
|
2021-04-14 14:50:27 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
productIsInCheckoutBlock: async ( productTitle, quantity, total ) => {
|
2021-05-18 13:09:30 +00:00
|
|
|
// Make sure Order summary is expanded
|
|
|
|
const [ button ] = await page.$x(
|
|
|
|
`//button[contains(@aria-expanded, 'false')]//span[contains(text(), 'Order summary')]`
|
2021-04-14 14:50:27 +00:00
|
|
|
);
|
2021-05-18 13:09:30 +00:00
|
|
|
if ( button ) {
|
|
|
|
await button.click();
|
|
|
|
}
|
|
|
|
await page.waitForSelector( 'span', {
|
|
|
|
text: productTitle,
|
|
|
|
} );
|
|
|
|
await page.waitForSelector(
|
|
|
|
'div.wc-block-components-order-summary-item__quantity',
|
2021-04-14 14:50:27 +00:00
|
|
|
{
|
|
|
|
text: quantity,
|
|
|
|
}
|
|
|
|
);
|
2021-05-18 13:09:30 +00:00
|
|
|
await page.waitForSelector(
|
|
|
|
'span.wc-block-components-product-price__value',
|
2021-04-14 14:50:27 +00:00
|
|
|
{
|
|
|
|
text: total,
|
|
|
|
}
|
|
|
|
);
|
|
|
|
},
|
|
|
|
};
|