Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Functional tests - Add new test 'FO > Personal information > Order as a guest' #34456

Merged
merged 1 commit into from
Nov 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
// Import utils
import testContext from '@utils/testContext';
import helper from '@utils/helpers';

// Import pages
import {homePage} from '@pages/FO/home';
import productPage from '@pages/FO/product';
import {cartPage} from '@pages/FO/cart';
import checkoutPage from '@pages/FO/checkout';
import orderConfirmationPage from '@pages/FO/checkout/orderConfirmation';

// Import data
import PaymentMethods from '@data/demo/paymentMethods';
import AddressData from '@data/faker/address';
import CustomerData from '@data/faker/customer';

import {expect} from 'chai';
import type {BrowserContext, Page} from 'playwright';

const baseContext: string = 'functional_FO_classic_checkout_personalInformation_orderAsAGuest';

/*
Scenario:
- Open FO page
- Add first product to the cart
- Proceed to checkout and validate the cart
- Fill guest personal information
- Complete the order
*/

describe('FO - Checkout - Personal information : Order as a guest', async () => {
let browserContext: BrowserContext;
let page: Page;
const guestData: CustomerData = new CustomerData({password: ''});
const secondGuestData: CustomerData = new CustomerData({password: ''});
const addressData: AddressData = new AddressData({country: 'France'});

// before and after functions
before(async function () {
browserContext = await helper.createBrowserContext(this.browser);
page = await helper.newTab(browserContext);
});

after(async () => {
await helper.closeBrowserContext(browserContext);
});

it('should open FO page', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'openFO', baseContext);

// Go to FO and change language
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 product to cart', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'addProductToCart', baseContext);

await homePage.goToProductPage(page, 1);
await productPage.addProductToTheCart(page, 1);

const pageTitle = await cartPage.getPageTitle(page);
expect(pageTitle).to.equal(cartPage.pageTitle);
});

it('should proceed to checkout validate the cart', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'validateCart', baseContext);

await cartPage.clickOnProceedToCheckout(page);

const isCheckoutPage = await checkoutPage.isCheckoutPage(page);
expect(isCheckoutPage).to.equal(true);
});

it('should fill guest personal information', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'setPersonalInformation', baseContext);

const isStepPersonalInfoCompleted = await checkoutPage.setGuestPersonalInformation(page, guestData);
expect(isStepPersonalInfoCompleted, 'Step personal information is not completed').to.equal(true);
});

it('should click on edit Personal information and edit the guest information', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'checkCustomerIdentity', baseContext);

await checkoutPage.clickOnEditPersonalInformationStep(page);

const isStepPersonalInfoCompleted = await checkoutPage.setGuestPersonalInformation(page, secondGuestData);
expect(isStepPersonalInfoCompleted, 'Step personal information is not completed').to.equal(true);
});

it('should fill address form and go to delivery step', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'setAddressStep', baseContext);

const isStepAddressComplete = await checkoutPage.setAddress(page, addressData);
expect(isStepAddressComplete, 'Step Address is not complete').to.equal(true);
});

it('should validate the order', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'validateOrder', baseContext);

// Delivery step - Go to payment step
const isStepDeliveryComplete = await checkoutPage.goToPaymentStep(page);
expect(isStepDeliveryComplete, 'Step Address is not complete').to.equal(true);

// Payment step - Choose payment step
await checkoutPage.choosePaymentAndOrder(page, PaymentMethods.wirePayment.moduleName);
const cardTitle = await orderConfirmationPage.getOrderConfirmationCardTitle(page);

// Check the confirmation message
expect(cardTitle).to.contains(orderConfirmationPage.orderConfirmationCardTitle);
});
});