2024-01-31 09:23:09 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { FrontendUtils } from '@woocommerce/e2e-utils';
|
|
|
|
import { Page } from '@playwright/test';
|
|
|
|
|
|
|
|
export class MiniCartUtils {
|
|
|
|
private page: Page;
|
|
|
|
private frontendUtils: FrontendUtils;
|
|
|
|
|
|
|
|
constructor( page: Page, frontendUtils: FrontendUtils ) {
|
|
|
|
this.page = page;
|
|
|
|
this.frontendUtils = frontendUtils;
|
|
|
|
}
|
|
|
|
|
|
|
|
async openMiniCart() {
|
2024-06-11 18:52:48 +00:00
|
|
|
const miniCartButton = this.page.locator(
|
|
|
|
'.wc-block-mini-cart__button'
|
2024-01-31 09:23:09 +00:00
|
|
|
);
|
2024-06-11 18:52:48 +00:00
|
|
|
// The mini cart button scripts are loaded when the button is either
|
|
|
|
// hovered or focused. The click event alone does not trigger neither of
|
|
|
|
// those actions so we need to perform one explicitly.
|
|
|
|
await miniCartButton.hover();
|
|
|
|
await miniCartButton.click();
|
2024-01-31 09:23:09 +00:00
|
|
|
}
|
|
|
|
}
|