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() {
|
|
|
|
await waitForElementByText( 'h1', 'Choose payment methods' );
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|