-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Functional Tests : Hummingbird : FO - Checkout - Payment - Choose a p…
…ayment method
- Loading branch information
Showing
9 changed files
with
252 additions
and
21 deletions.
There are no files selected for viewing
161 changes: 161 additions & 0 deletions
161
...s/UI/campaigns/functional/FO/hummingbird/11_checkout/04_payment/01_choosePaymentMethod.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
// Import utils | ||
import helper from '@utils/helpers'; | ||
import testContext from '@utils/testContext'; | ||
import mailHelper from '@utils/mailHelper'; | ||
|
||
// Import common tests | ||
import {resetSmtpConfigTest, setupSmtpConfigTest} from '@commonTests/BO/advancedParameters/smtp'; | ||
import {installHummingbird, uninstallHummingbird} from '@commonTests/FO/hummingbird'; | ||
|
||
// Import FO pages | ||
import cartPage from '@pages/FO/hummingbird/cart'; | ||
import orderConfirmationPage from '@pages/FO/hummingbird/checkout/orderConfirmation'; | ||
import homePage from '@pages/FO/hummingbird/home'; | ||
import checkoutPage from '@pages/FO/hummingbird/checkout'; | ||
|
||
// Import data | ||
import Customers from '@data/demo/customers'; | ||
import PaymentMethods from '@data/demo/paymentMethods'; | ||
import PaymentMethodData from '@data/faker/paymentMethod'; | ||
|
||
import {expect} from 'chai'; | ||
import type {BrowserContext, Page} from 'playwright'; | ||
import MailDevEmail from '@data/types/maildevEmail'; | ||
import MailDev from 'maildev'; | ||
|
||
const baseContext: string = 'functional_FO_hummingbird_checkout_payment_choosePaymentMethod'; | ||
|
||
describe('FO - Checkout - Payment : Choose a payment method', async () => { | ||
let browserContext: BrowserContext; | ||
let page: Page; | ||
let allEmails: MailDevEmail[]; | ||
let numberOfEmails: number; | ||
let mailListener: MailDev; | ||
|
||
// Pre-Condition : Setup config SMTP | ||
setupSmtpConfigTest(`${baseContext}_preTest_0`); | ||
|
||
// Pre-condition : Install Hummingbird | ||
installHummingbird(`${baseContext}_preTest_1`); | ||
|
||
before(async function () { | ||
browserContext = await helper.createBrowserContext(this.browser); | ||
page = await helper.newTab(browserContext); | ||
|
||
mailListener = mailHelper.createMailListener(); | ||
mailHelper.startListener(mailListener); | ||
|
||
// get all emails | ||
// @ts-ignore | ||
mailListener.getAllEmail((err: Error, emails: MailDevEmail[]) => { | ||
allEmails = emails; | ||
}); | ||
}); | ||
|
||
after(async () => { | ||
await helper.closeBrowserContext(browserContext); | ||
|
||
mailHelper.stopListener(mailListener); | ||
}); | ||
|
||
describe('Choose a payment method', async () => { | ||
[ | ||
PaymentMethods.wirePayment, | ||
PaymentMethods.checkPayment, | ||
PaymentMethods.cashOnDelivery, | ||
].forEach((test: PaymentMethodData, index: number) => { | ||
it('should go to FO', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', `goToFo${index}`, baseContext); | ||
|
||
await homePage.goToFo(page); | ||
await homePage.changeLanguage(page, 'en'); | ||
|
||
const isHomePage = await homePage.isHomePage(page); | ||
expect(isHomePage, 'Fail to open FO home page').to.eq(true); | ||
}); | ||
|
||
it('should add the first product to cart', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', `addProductToCart${index}`, baseContext); | ||
|
||
await homePage.addProductToCartByQuickView(page, 1, 1); | ||
await homePage.proceedToCheckout(page); | ||
|
||
const pageTitle = await cartPage.getPageTitle(page); | ||
expect(pageTitle).to.eq(cartPage.pageTitle); | ||
}); | ||
|
||
it('should proceed to checkout and go to checkout page', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', `proceedToCheckout${index}`, baseContext); | ||
|
||
await cartPage.clickOnProceedToCheckout(page); | ||
|
||
const isCheckoutPage = await checkoutPage.isCheckoutPage(page); | ||
expect(isCheckoutPage).to.eq(true); | ||
}); | ||
|
||
if (index === 0) { | ||
it('should signin', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', `signin${index}`, baseContext); | ||
|
||
await checkoutPage.clickOnSignIn(page); | ||
|
||
const isCustomerConnected = await checkoutPage.customerLogin(page, Customers.johnDoe); | ||
expect(isCustomerConnected, 'Customer is connected').to.eq(true); | ||
}); | ||
} | ||
|
||
it('should go to delivery step', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', `goToDeliveryStep${index}`, baseContext); | ||
|
||
// Address step - Go to delivery step | ||
const isStepAddressComplete = await checkoutPage.goToDeliveryStep(page); | ||
expect(isStepAddressComplete, 'Step Address is not complete').to.eq(true); | ||
}); | ||
|
||
it('should go to payment step', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', `goToPaymentStep${index}`, baseContext); | ||
|
||
// Delivery step - Go to payment step | ||
const isStepDeliveryComplete = await checkoutPage.goToPaymentStep(page); | ||
expect(isStepDeliveryComplete, 'Step Address is not complete').to.eq(true); | ||
}); | ||
|
||
it('should choose payment method and confirm the order', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', `confirmOrder${index}`, baseContext); | ||
|
||
// Payment step - Choose payment step | ||
await checkoutPage.choosePaymentAndOrder(page, test.moduleName); | ||
|
||
// Check the confirmation message | ||
const cardTitle = await orderConfirmationPage.getOrderConfirmationCardTitle(page); | ||
expect(cardTitle).to.contains(orderConfirmationPage.orderConfirmationCardTitle); | ||
}); | ||
|
||
it(`should check the payment method is ${test.displayName}`, async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', `checkPaymentMethod${index}`, baseContext); | ||
|
||
const paymentMethod = await orderConfirmationPage.getPaymentMethod(page); | ||
expect(paymentMethod).to.be.equal(test.displayName); | ||
}); | ||
|
||
it('should check if order and payment confirmation mails are in mailbox', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', `checkPaymentMail${index}`, baseContext); | ||
|
||
numberOfEmails = allEmails.length; | ||
expect(allEmails[numberOfEmails - 1].subject).to.equal(`[${global.INSTALL.SHOP_NAME}] Order confirmation`); | ||
|
||
if (index === 0) { | ||
expect(allEmails[numberOfEmails - 2].subject).to.equal(`[${global.INSTALL.SHOP_NAME}] Awaiting bank wire payment`); | ||
} else if (index === 1) { | ||
expect(allEmails[numberOfEmails - 2].subject).to.equal(`[${global.INSTALL.SHOP_NAME}] Awaiting check payment`); | ||
} | ||
}); | ||
}); | ||
}); | ||
|
||
// Post-condition : Reset SMTP config | ||
resetSmtpConfigTest(`${baseContext}_postTest_0`); | ||
|
||
// Post-condition : Uninstall Hummingbird | ||
uninstallHummingbird(`${baseContext}_postTest_1`); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Import FO pages | ||
import {CheckoutPage} from '@pages/FO/classic/checkout'; | ||
|
||
/** | ||
* Cart page, contains functions that can be used on the page | ||
* @class | ||
* @extends FOBasePage | ||
*/ | ||
class Checkout extends CheckoutPage { | ||
/** | ||
* @constructs | ||
*/ | ||
constructor() { | ||
super('hummingbird'); | ||
|
||
// Selectors | ||
this.stepFormSuccess = '.checkout__steps--success'; | ||
|
||
// Personal information form | ||
this.personalInformationStepForm = 'li[data-step="checkout-personal-information-step"]'; | ||
|
||
// Sign in selectors | ||
this.signInHyperLink = '#checkout-personal-information-step div.step__content ' | ||
+ '#contact-tab[data-bs-target="#checkout-login-form"]'; | ||
this.personalInformationContinueButton = '#login-form button[data-link-action="sign-in"]'; | ||
|
||
// Addresses step selectors | ||
this.addressStepSection = 'li[data-step="checkout-addresses-step"]'; | ||
|
||
// Shipping method selectors | ||
this.deliveryStepSection = 'li[data-step="checkout-delivery-step"]'; | ||
} | ||
} | ||
|
||
export default new Checkout(); |
Oops, something went wrong.