Fix e2e tests
This commit is contained in:
parent
29e27fff35
commit
859ab8884b
|
@ -25,8 +25,13 @@ export class PaymentsSetup extends BasePage {
|
|||
await this.clickButtonWithText( 'Got it' );
|
||||
}
|
||||
|
||||
async toggleOtherPaymentMethods(): Promise< void > {
|
||||
await this.clickButtonWithText( 'Other payment methods' );
|
||||
async showOtherPaymentMethods(): Promise< void > {
|
||||
const selector = '.woocommerce-task-payments button.toggle-button';
|
||||
await this.page.waitForSelector( selector );
|
||||
const toggleButton = await this.page.$(
|
||||
`${ selector }[aria-expanded=false]`
|
||||
);
|
||||
await toggleButton?.click();
|
||||
}
|
||||
|
||||
async goToPaymentMethodSetup(
|
||||
|
@ -45,14 +50,6 @@ export class PaymentsSetup extends BasePage {
|
|||
}
|
||||
}
|
||||
|
||||
async methodHasBeenSetup( method: PaymentMethod ): Promise< void > {
|
||||
const selector = `.woocommerce-task-payment-${ method }`;
|
||||
await this.page.waitForSelector( selector );
|
||||
expect(
|
||||
await getElementByText( '*', 'Manage', selector )
|
||||
).toBeDefined();
|
||||
}
|
||||
|
||||
async enableCashOnDelivery(): Promise< void > {
|
||||
await this.page.waitForSelector( '.woocommerce-task-payment-cod' );
|
||||
await this.clickButtonWithText( 'Enable' );
|
||||
|
|
|
@ -42,8 +42,22 @@ export class WcSettings extends BasePage {
|
|||
);
|
||||
}
|
||||
|
||||
async paymentMethodIsEnabled( method = '' ): Promise< boolean > {
|
||||
await this.navigate( 'checkout' );
|
||||
await waitForElementByText( 'h2', 'Payment methods' );
|
||||
const className = await getAttribute(
|
||||
`tr[data-gateway_id=${ method }] .woocommerce-input-toggle`,
|
||||
'className'
|
||||
);
|
||||
return (
|
||||
( className as string ).indexOf(
|
||||
'woocommerce-input-toggle--disabled'
|
||||
) === -1
|
||||
);
|
||||
}
|
||||
|
||||
async cleanPaymentMethods(): Promise< void > {
|
||||
this.navigate( 'checkout' );
|
||||
await this.navigate( 'checkout' );
|
||||
await waitForElementByText( 'h2', 'Payment methods' );
|
||||
const paymentMethods = await page.$$( 'span.woocommerce-input-toggle' );
|
||||
for ( const method of paymentMethods ) {
|
||||
|
|
|
@ -53,6 +53,7 @@ const testAdminPaymentSetupTask = () => {
|
|||
} );
|
||||
|
||||
it( 'Saving valid bank account transfer details enables the payment method', async () => {
|
||||
await paymentsSetup.showOtherPaymentMethods();
|
||||
await paymentsSetup.goToPaymentMethodSetup( 'bacs' );
|
||||
await bankTransferSetup.saveAccountDetails( {
|
||||
accountNumber: '1234',
|
||||
|
@ -62,13 +63,11 @@ const testAdminPaymentSetupTask = () => {
|
|||
iban: '12 3456 7890',
|
||||
swiftCode: 'ABBA',
|
||||
} );
|
||||
|
||||
await homeScreen.isDisplayed();
|
||||
await waitForTimeout( 1000 );
|
||||
await homeScreen.clickOnTaskList( 'Set up payments' );
|
||||
await paymentsSetup.isDisplayed();
|
||||
await paymentsSetup.toggleOtherPaymentMethods();
|
||||
await paymentsSetup.methodHasBeenSetup( 'bacs' );
|
||||
expect( await settings.paymentMethodIsEnabled( 'bacs' ) ).toBe(
|
||||
true
|
||||
);
|
||||
await homeScreen.navigate();
|
||||
} );
|
||||
|
||||
it( 'Enabling cash on delivery enables the payment method', async () => {
|
||||
|
@ -78,14 +77,12 @@ const testAdminPaymentSetupTask = () => {
|
|||
await waitForTimeout( 1000 );
|
||||
await homeScreen.clickOnTaskList( 'Set up payments' );
|
||||
await paymentsSetup.isDisplayed();
|
||||
await paymentsSetup.toggleOtherPaymentMethods();
|
||||
await paymentsSetup.showOtherPaymentMethods();
|
||||
await paymentsSetup.enableCashOnDelivery();
|
||||
await homeScreen.navigate();
|
||||
await homeScreen.isDisplayed();
|
||||
await waitForTimeout( 1000 );
|
||||
await homeScreen.clickOnTaskList( 'Set up payments' );
|
||||
await paymentsSetup.isDisplayed();
|
||||
await paymentsSetup.methodHasBeenSetup( 'cod' );
|
||||
expect( await settings.paymentMethodIsEnabled( 'cod' ) ).toBe(
|
||||
true
|
||||
);
|
||||
} );
|
||||
} );
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue