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' );
|
await this.clickButtonWithText( 'Got it' );
|
||||||
}
|
}
|
||||||
|
|
||||||
async toggleOtherPaymentMethods(): Promise< void > {
|
async showOtherPaymentMethods(): Promise< void > {
|
||||||
await this.clickButtonWithText( 'Other payment methods' );
|
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(
|
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 > {
|
async enableCashOnDelivery(): Promise< void > {
|
||||||
await this.page.waitForSelector( '.woocommerce-task-payment-cod' );
|
await this.page.waitForSelector( '.woocommerce-task-payment-cod' );
|
||||||
await this.clickButtonWithText( 'Enable' );
|
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 > {
|
async cleanPaymentMethods(): Promise< void > {
|
||||||
this.navigate( 'checkout' );
|
await this.navigate( 'checkout' );
|
||||||
await waitForElementByText( 'h2', 'Payment methods' );
|
await waitForElementByText( 'h2', 'Payment methods' );
|
||||||
const paymentMethods = await page.$$( 'span.woocommerce-input-toggle' );
|
const paymentMethods = await page.$$( 'span.woocommerce-input-toggle' );
|
||||||
for ( const method of paymentMethods ) {
|
for ( const method of paymentMethods ) {
|
||||||
|
|
|
@ -53,6 +53,7 @@ const testAdminPaymentSetupTask = () => {
|
||||||
} );
|
} );
|
||||||
|
|
||||||
it( 'Saving valid bank account transfer details enables the payment method', async () => {
|
it( 'Saving valid bank account transfer details enables the payment method', async () => {
|
||||||
|
await paymentsSetup.showOtherPaymentMethods();
|
||||||
await paymentsSetup.goToPaymentMethodSetup( 'bacs' );
|
await paymentsSetup.goToPaymentMethodSetup( 'bacs' );
|
||||||
await bankTransferSetup.saveAccountDetails( {
|
await bankTransferSetup.saveAccountDetails( {
|
||||||
accountNumber: '1234',
|
accountNumber: '1234',
|
||||||
|
@ -62,13 +63,11 @@ const testAdminPaymentSetupTask = () => {
|
||||||
iban: '12 3456 7890',
|
iban: '12 3456 7890',
|
||||||
swiftCode: 'ABBA',
|
swiftCode: 'ABBA',
|
||||||
} );
|
} );
|
||||||
|
|
||||||
await homeScreen.isDisplayed();
|
|
||||||
await waitForTimeout( 1000 );
|
await waitForTimeout( 1000 );
|
||||||
await homeScreen.clickOnTaskList( 'Set up payments' );
|
expect( await settings.paymentMethodIsEnabled( 'bacs' ) ).toBe(
|
||||||
await paymentsSetup.isDisplayed();
|
true
|
||||||
await paymentsSetup.toggleOtherPaymentMethods();
|
);
|
||||||
await paymentsSetup.methodHasBeenSetup( 'bacs' );
|
await homeScreen.navigate();
|
||||||
} );
|
} );
|
||||||
|
|
||||||
it( 'Enabling cash on delivery enables the payment method', async () => {
|
it( 'Enabling cash on delivery enables the payment method', async () => {
|
||||||
|
@ -78,14 +77,12 @@ const testAdminPaymentSetupTask = () => {
|
||||||
await waitForTimeout( 1000 );
|
await waitForTimeout( 1000 );
|
||||||
await homeScreen.clickOnTaskList( 'Set up payments' );
|
await homeScreen.clickOnTaskList( 'Set up payments' );
|
||||||
await paymentsSetup.isDisplayed();
|
await paymentsSetup.isDisplayed();
|
||||||
await paymentsSetup.toggleOtherPaymentMethods();
|
await paymentsSetup.showOtherPaymentMethods();
|
||||||
await paymentsSetup.enableCashOnDelivery();
|
await paymentsSetup.enableCashOnDelivery();
|
||||||
await homeScreen.navigate();
|
|
||||||
await homeScreen.isDisplayed();
|
|
||||||
await waitForTimeout( 1000 );
|
await waitForTimeout( 1000 );
|
||||||
await homeScreen.clickOnTaskList( 'Set up payments' );
|
expect( await settings.paymentMethodIsEnabled( 'cod' ) ).toBe(
|
||||||
await paymentsSetup.isDisplayed();
|
true
|
||||||
await paymentsSetup.methodHasBeenSetup( 'cod' );
|
);
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue