Skip to content

Commit

Permalink
ECP-9532 write test for recurring SEPA payment (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
peterojo authored Oct 23, 2024
1 parent e50bd56 commit 862ce00
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 5 deletions.
9 changes: 8 additions & 1 deletion projects/magento/pageObjects/plugin/PaymentDetails.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,21 @@ export class PaymentDetailsPage {
await this.paymentMethodSaveCheckBox.click();
}

async selectVault(lastFourDigits) {
async selectVaultCC(lastFourDigits) {
// Not ideal way of selecting saved card due to vault UI structure
lastFourDigits != undefined ?
await this.page.locator(`text=Ending ${lastFourDigits} ( expires: 3/2030 )`).click()
: await page.locator("input#adyen_cc_vault_1").first().click();
await this.waitForPaymentMethodReady();
}

async selectVaultSepaDirectDebit() {
const d = new Date();
const formattedDate = d.toISOString().split('T')[0];
await this.page.locator(`text=SEPA Direct Debit token created on ${formattedDate}`).first().click();
await this.waitForPaymentMethodReady();
}

async selectCreditCard() {
await this.creditCardRadioButton.click();
await this.waitForPaymentMethodReady();
Expand Down
45 changes: 41 additions & 4 deletions projects/magento/tests/loggedIn/StoredCardPayment.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { ThreeDS2PaymentPage } from "../../../common/redirect/ThreeDS2PaymentPag
const paymentResources = new PaymentResources();
const magentoSampleUser = paymentResources.sampleRegisteredUser;
const users = paymentResources.guestUser;
const ibanDetails = paymentResources.sepaDirectDebit.nl;

/* No parallelism due to usage of same user account
since it will cause the cart to reset */
Expand Down Expand Up @@ -43,7 +44,7 @@ test.describe("Payment via stored credit card", () => {
await goToShippingWithFullCart(page);
await proceedToPaymentAs(page, undefined, false);

await makeVaultPayment(page, paymentResources.masterCard3DS2, paymentResources.cvc);
await makeCCVaultPayment(page, paymentResources.masterCard3DS2, paymentResources.cvc);
await new ThreeDS2PaymentPage(page).validate3DS2(
paymentResources.threeDSCorrectPassword
);
Expand Down Expand Up @@ -80,12 +81,28 @@ test.describe("Payment via stored credit card", () => {
await goToShippingWithFullCart(page);
await proceedToPaymentAs(page, undefined, false);

await makeVaultPayment(page, paymentResources.masterCardWithout3D, paymentResources.cvc);
await makeCCVaultPayment(page, paymentResources.masterCardWithout3D, paymentResources.cvc);
await verifySuccessfulPayment(page);
});

});

test.describe('Payment via stored SEPA token', () => {
test.beforeEach(async ({ page }) => {
await loginAs(page, magentoSampleUser);
});

test('should succeed', async ({ page }) => {
await goToShippingWithFullCart(page);
await proceedToPaymentAs(page, undefined, false);
await makeSepaDirectDebitPayment(page, ibanDetails);

await goToShippingWithFullCart(page);
await proceedToPaymentAs(page, undefined, false);
await makeSepaDirectDebitVaultPayment(page);
});
});

async function makeCreditCardPayment(
page,
user,
Expand All @@ -112,9 +129,29 @@ async function makeCreditCardPayment(
await placeOrder(page);
}

async function makeVaultPayment(page, creditCardNumber, cvc) {
await new PaymentDetailsPage(page).selectVault(creditCardNumber.slice(-4));
async function makeCCVaultPayment(page, creditCardNumber, cvc) {
await new PaymentDetailsPage(page).selectVaultCC(creditCardNumber.slice(-4));
await new CreditCardComponentsMagento(page.locator(".payment-method._active")).fillCVC(cvc);

await placeOrder(page);
}

async function makeSepaDirectDebitPayment(page, ibanDetails) {
const paymentDetailsPage = new PaymentDetailsPage(page);
const sepaPaymentSection = await paymentDetailsPage.selectSepaDirectDebit();
await sepaPaymentSection.fillSepaDirectDebitInfo(
ibanDetails.accountName,
ibanDetails.iban
);
await placeOrder(page);

await verifySuccessfulPayment(page);
}

async function makeSepaDirectDebitVaultPayment(page) {
await new PaymentDetailsPage(page).selectVaultSepaDirectDebit();

await placeOrder(page);

await verifySuccessfulPayment(page);
}

0 comments on commit 862ce00

Please sign in to comment.