woocommerce-paypal-payments/tests/qa/utils/frontend/oxxo-voucher-popup.ts
2026-05-28 10:33:00 +02:00

42 lines
902 B
TypeScript

/**
* External dependencies
*/
import { expect, Page } from '@playwright/test';
export class OxxoVoucherPopup {
page: Page;
constructor( page: Page ) {
this.page = page;
}
// Locators
testSuccessfulPaymentButton = () =>
this.page.getByRole( 'button', { name: 'Test Successful Payment' } );
// Actions
simulate = async () => {
await this.page.waitForLoadState();
await this.page.evaluate( () => {
window.opener = null;
} );
await expect(
this.testSuccessfulPaymentButton(),
'Assert OXXO voucher popup loaded with test payment button'
).toBeVisible();
await this.testSuccessfulPaymentButton().click();
await this.page
.waitForEvent( 'close', { timeout: 15_000 } )
.catch( async () => {
console.warn(
'OXXO voucher popup did not auto-close — payment simulation may not have fired the webhook'
);
await this.page.close();
} );
};
}