Skip to content

Commit

Permalink
Implement test for Make a successful payment using any shopper name
Browse files Browse the repository at this point in the history
  • Loading branch information
mescalantea committed Feb 4, 2025
1 parent 4361582 commit 24146c5
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 39 additions & 1 deletion tests-e2e/fixtures/pages/CheckoutPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default class CheckoutPage extends BaseCheckoutPage {
phone: () => this.page.locator('[name=telephone]'),
flatRateShipping: () => this.page.locator('[value="flatrate_flatrate"]'),
continueButton: () => this.page.locator('.action.continue'),
submitCheckout: () => this.page.locator('.payment-method._active .action.checkout'),
};
}

Expand Down Expand Up @@ -97,7 +98,7 @@ export default class CheckoutPage extends BaseCheckoutPage {
async selectShippingMethod(options) {
await this.page.waitForURL(/#shipping/);
await this.#waitForFinishLoading();
this.locators.flatRateShipping().click();
await this.locators.flatRateShipping().click();
}

/**
Expand Down Expand Up @@ -131,4 +132,41 @@ export default class CheckoutPage extends BaseCheckoutPage {
paymentMethodTitleLocator(options) {
return this.page.locator(`#sequra_${options.product} + label`).getByText(options.title);
}

/**
* Select the payment method and place the order
* @param {Object} options
* @param {string} options.product seQura product (i1, pp3, etc)
* @param {string} options.dateOfBirth Date of birth
* @param {string} options.dni National identification number
* @param {string[]} options.otp Digits of the OTP
*/
async placeOrder(options) {
await this.locators.paymentMethodInput({ ...options, checked: false }).click();
await this.#waitForFinishLoading();
await this.locators.submitCheckout().click();
await this.#waitForFinishLoading();
// Fill checkout form.
switch (options.product) {
case 'i1':
await this.fillI1CheckoutForm(options);
break;
case 'pp3':
await this.fillPp3CheckoutForm(options);
break;
case 'sp1':
await this.fillSp1CheckoutForm(options);
break;
default:
throw new Error(`Unknown product ${options.product}`);
}
}

/**
* Define the expected behavior after placing an order
* @param {Object} options
*/
async waitForOrderSuccess(options) {
await this.page.waitForURL(/checkout\/onepage\/success\//, { timeout: 30000, waitUntil: 'commit' });
}
}
21 changes: 12 additions & 9 deletions tests-e2e/specs/001-checkout-product.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,19 @@ test.describe('Product checkout', () => {
}
});

// test('Make a successful payment using any shopper name', async ({ productPage, checkoutPage }) => {
// await checkoutPage.setupForPhysicalProducts();
// await productPage.addToCart({ slug: 'sunglasses', quantity: 1 });
test('Make a successful payment using any shopper name', async ({ helper, dataProvider, productPage, checkoutPage }) => {
// Setup
const { dummy_config } = helper.webhooks;
await helper.executeWebhook({ webhook: dummy_config }); // Setup for physical products.
const shopper = dataProvider.shopper();

// await checkoutPage.goto();
// await checkoutPage.fillWithNonSpecialShopperName({});
// await checkoutPage.expectPaymentMethodsBeingReloaded();
// await checkoutPage.placeOrderUsingI1({ shopper: 'nonSpecial' });
// await checkoutPage.waitForOrderSuccess();
// });
// Execution
await productPage.addToCart({ slug: 'push-it-messenger-bag', quantity: 1 });
await checkoutPage.goto();
await checkoutPage.fillForm(shopper);
await checkoutPage.placeOrder({ ...shopper, product: 'i1' });
await checkoutPage.waitForOrderSuccess();
});

// test('Make a 🍊 payment with "Review test approve" names', async ({ productPage, checkoutPage }) => {
// await checkoutPage.setupForPhysicalProducts();
Expand Down

0 comments on commit 24146c5

Please sign in to comment.