2021-04-05 00:09:36 +00:00
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import { waitForElementByText } from '../utils/actions';
|
|
|
|
import { BasePage } from './BasePage';
|
2021-04-14 19:26:50 +00:00
|
|
|
import { getElementByText } from '../utils/actions';
|
2021-04-05 00:09:36 +00:00
|
|
|
|
|
|
|
type PaymentMethodWithSetupButton =
|
|
|
|
| 'wcpay'
|
|
|
|
| 'stripe'
|
|
|
|
| 'paypal'
|
|
|
|
| 'klarna_payments'
|
|
|
|
| 'mollie'
|
|
|
|
| 'bacs';
|
|
|
|
|
|
|
|
type PaymentMethod = PaymentMethodWithSetupButton | 'cod';
|
|
|
|
|
|
|
|
export class PaymentsSetup extends BasePage {
|
|
|
|
url = 'wp-admin/admin.php?page=wc-admin&task=payments';
|
|
|
|
|
|
|
|
async isDisplayed() {
|
2021-05-21 01:13:40 +00:00
|
|
|
await waitForElementByText( 'h1', 'Set up payments' );
|
2021-04-05 00:09:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async closeHelpModal() {
|
|
|
|
await this.clickButtonWithText( 'Got it' );
|
|
|
|
}
|
|
|
|
|
|
|
|
async goToPaymentMethodSetup( method: PaymentMethodWithSetupButton ) {
|
|
|
|
const selector = `.woocommerce-task-payment-${ method } button`;
|
|
|
|
const button = await this.page.$( selector );
|
|
|
|
|
|
|
|
if ( ! button ) {
|
|
|
|
throw new Error(
|
|
|
|
`Could not find button with selector: ${ selector }`
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
await button.click();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async methodHasBeenSetup( method: PaymentMethod ) {
|
2021-04-14 19:26:50 +00:00
|
|
|
await getElementByText( 'button', 'Manage', `.woocommerce-task-payment-${ method }` )
|
2021-04-05 00:09:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async enableCashOnDelivery() {
|
2021-04-14 19:26:50 +00:00
|
|
|
await this.clickButtonWithText( 'Enable' );
|
2021-04-05 00:09:36 +00:00
|
|
|
}
|
|
|
|
}
|