Fix logic to cover Afterpay payment options
This commit is contained in:
parent
d23fa89fdd
commit
ae93c84fe5
1 changed files with 11 additions and 7 deletions
|
|
@ -34,15 +34,19 @@ export class AfterpayPage extends BasePage {
|
|||
}
|
||||
|
||||
async executeAfterpayPayment(paymentDetails: IPaymentDetails, claimDetails: IClaimDetails, servicePackage: ServicePackage) {
|
||||
|
||||
const confirmButtonOrPaymentOptions = this.confirmButton.or(this.selectAfterpayWithoutInterestButton);
|
||||
|
||||
await this.login(paymentDetails.password!);
|
||||
|
||||
try {await this.confirmButton.waitFor({ state: 'visible', timeout: 5000 });
|
||||
expect(this.confirmButton).toBeVisible();
|
||||
await this.confirmButton.click();
|
||||
} catch {
|
||||
// For some orders, user will have 2 options to choose from: monthly with interest or biweekly without interest
|
||||
await this.selectAfterpayWithoutInterestButton.waitFor({ state: 'visible' });
|
||||
await this.page.locator('div[data-testid=\'loading-icon-svg\']').filter({ visible: true}).first().waitFor({ state: 'hidden' });
|
||||
await confirmButtonOrPaymentOptions.waitFor({ state: 'visible' });
|
||||
|
||||
if (await this.confirmButton.isVisible()) {
|
||||
await this.confirmButton.waitFor({ state: 'attached' });
|
||||
await this.confirmButton.click();
|
||||
} else {
|
||||
// For some orders, user will have 2 options to choose from: monthly with interest or biweekly without interest
|
||||
if (await this.selectAfterpayWithoutInterestButton.isVisible()) {
|
||||
await this.selectAfterpayWithoutInterestButton.click();
|
||||
await this.continueAfterpayButton.click();
|
||||
|
|
@ -51,6 +55,6 @@ export class AfterpayPage extends BasePage {
|
|||
await this.continueAfterpayButton.click();
|
||||
}
|
||||
await this.confirmButton.click();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue