diff --git a/tests/UI/campaigns/functional/BO/03_catalog/07_discounts/01_cartRules/01_CRUDCartRule/01_information/02_enableDisablePartialUse.ts b/tests/UI/campaigns/functional/BO/03_catalog/07_discounts/01_cartRules/01_CRUDCartRule/01_information/02_enableDisablePartialUse.ts index 73b9994b85b2a..712f29d96463a 100644 --- a/tests/UI/campaigns/functional/BO/03_catalog/07_discounts/01_cartRules/01_CRUDCartRule/01_information/02_enableDisablePartialUse.ts +++ b/tests/UI/campaigns/functional/BO/03_catalog/07_discounts/01_cartRules/01_CRUDCartRule/01_information/02_enableDisablePartialUse.ts @@ -15,7 +15,7 @@ import {homePage} from '@pages/FO/classic/home'; import {orderConfirmationPage} from '@pages/FO/classic/checkout/orderConfirmation'; import {productPage as foProductPage} from '@pages/FO/classic/product'; import {myAccountPage} from '@pages/FO/classic/myAccount'; -import foVouchersPage from '@pages/FO/classic/myAccount/vouchers'; +import {vouchersPage as foVouchersPage} from '@pages/FO/classic/myAccount/vouchers'; import {checkoutPage} from '@pages/FO/classic/checkout'; // Import data diff --git a/tests/UI/campaigns/functional/BO/03_catalog/07_discounts/01_cartRules/01_CRUDCartRule/02_conditions/01_limitToSingleCustomer.ts b/tests/UI/campaigns/functional/BO/03_catalog/07_discounts/01_cartRules/01_CRUDCartRule/02_conditions/01_limitToSingleCustomer.ts index 80ba1f094afa7..4184642cdedec 100644 --- a/tests/UI/campaigns/functional/BO/03_catalog/07_discounts/01_cartRules/01_CRUDCartRule/02_conditions/01_limitToSingleCustomer.ts +++ b/tests/UI/campaigns/functional/BO/03_catalog/07_discounts/01_cartRules/01_CRUDCartRule/02_conditions/01_limitToSingleCustomer.ts @@ -16,7 +16,7 @@ import addCartRulePage from '@pages/BO/catalog/discounts/add'; import {homePage} from '@pages/FO/classic/home'; import {loginPage as foLoginPage} from '@pages/FO/classic/login'; import {myAccountPage} from '@pages/FO/classic/myAccount'; -import foVouchersPage from '@pages/FO/classic/myAccount/vouchers'; +import {vouchersPage as foVouchersPage} from '@pages/FO/classic/myAccount/vouchers'; import {cartPage} from '@pages/FO/classic/cart'; // Import data diff --git a/tests/UI/campaigns/functional/FO/classic/03_userAccount/03_viewVouchers.ts b/tests/UI/campaigns/functional/FO/classic/03_userAccount/03_viewVouchers.ts index 67f4d2dc0278b..4b172a6e15ba9 100644 --- a/tests/UI/campaigns/functional/FO/classic/03_userAccount/03_viewVouchers.ts +++ b/tests/UI/campaigns/functional/FO/classic/03_userAccount/03_viewVouchers.ts @@ -12,7 +12,7 @@ import {createAccountTest} from '@commonTests/FO/account'; import {homePage} from '@pages/FO/classic/home'; import {loginPage as foLoginPage} from '@pages/FO/classic/login'; import {myAccountPage} from '@pages/FO/classic/myAccount'; -import foVouchersPage from '@pages/FO/classic/myAccount/vouchers'; +import {vouchersPage as foVouchersPage} from '@pages/FO/classic/myAccount/vouchers'; // Import data import CartRuleData from '@data/faker/cartRule'; diff --git a/tests/UI/campaigns/functional/FO/hummingbird/03_userAccount/03_viewVoucher.ts b/tests/UI/campaigns/functional/FO/hummingbird/03_userAccount/03_viewVoucher.ts new file mode 100644 index 0000000000000..928e5e195afb0 --- /dev/null +++ b/tests/UI/campaigns/functional/FO/hummingbird/03_userAccount/03_viewVoucher.ts @@ -0,0 +1,159 @@ +// Import utils +import date from '@utils/date'; +import helper from '@utils/helpers'; +import testContext from '@utils/testContext'; +import files from '@utils/files'; + +// Import commonTests +import {createCartRuleTest} from '@commonTests/BO/catalog/cartRule'; +import {deleteCustomerTest} from '@commonTests/BO/customers/customer'; +import createAccountTest from '@commonTests/FO/hummingbird/account'; +import {installHummingbird, uninstallHummingbird} from '@commonTests/FO/hummingbird'; + +// Import FO pages +import homePage from '@pages/FO/hummingbird/home'; +import foLoginPage from '@pages/FO/hummingbird/login'; +import myAccountPage from '@pages/FO/hummingbird/myAccount'; +import foVouchersPage from '@pages/FO/hummingbird/myAccount/vouchers'; + +// Import data +import CartRuleData from '@data/faker/cartRule'; +import CustomerData from '@data/faker/customer'; + +import {expect} from 'chai'; +import type {BrowserContext, Page} from 'playwright'; + +const baseContext: string = 'functional_FO_hummingbird_userAccount_viewVouchers'; + +/* +Pre-condition: +- Create customer +- Create 2 cart rules for the customer +- Install hummingbird theme +Scenario: +- Go To FO and sign in +- Check vouchers in account page +Post-condition: +- Delete customer +- Uninstall hummingbird theme + */ +describe('FO - Account : View vouchers', async () => { + let browserContext: BrowserContext; + let page: Page; + + // Data to create a date format + const pastDate: string = date.getDateFormat('yyyy-mm-dd', 'past'); + const futureDate: string = date.getDateFormat('yyyy-mm-dd', 'future'); + const expirationDate: string = date.getDateFormat('mm/dd/yyyy', 'future'); + const customerData: CustomerData = new CustomerData({}); + const firstCartRule: CartRuleData = new CartRuleData({ + code: 'promo20', + customer: customerData, + discountType: 'Percent', + discountPercent: 20, + dateFrom: pastDate, + dateTo: futureDate, + }); + const secondCartRule: CartRuleData = new CartRuleData({ + code: 'freeShipping', + customer: customerData, + freeShipping: true, + dateFrom: pastDate, + dateTo: futureDate, + }); + + // Pre-condition : Install Hummingbird + installHummingbird(`${baseContext}_preTest_0`); + + // Pre-condition: Create new account on FO + createAccountTest(customerData, `${baseContext}_preTest_1`); + + // Pre-condition: Create 2 cart rules for the created customer + [firstCartRule, secondCartRule].forEach((cartRule: CartRuleData, index: number) => { + createCartRuleTest(cartRule, `${baseContext}_preTest_${index + 2}`); + }); + + // before and after functions + before(async function () { + browserContext = await helper.createBrowserContext(this.browser); + page = await helper.newTab(browserContext); + }); + + after(async () => { + await helper.closeBrowserContext(browserContext); + await files.deleteFile('../../admin-dev/hummingbird.zip'); + }); + + describe('View vouchers on FO', async () => { + it('should open the shop page', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'goToShopFO', baseContext); + + await homePage.goTo(page, global.FO.URL); + + const result = await homePage.isHomePage(page); + expect(result).to.eq(true); + }); + + it('should go to login page', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'goToLoginPageFO', baseContext); + + await homePage.goToLoginPage(page); + + const pageTitle = await foLoginPage.getPageTitle(page); + expect(pageTitle, 'Fail to open FO login page').to.contains(foLoginPage.pageTitle); + }); + + it('should sign in with created customer', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'sighInFO', baseContext); + + await foLoginPage.customerLogin(page, customerData); + + const isCustomerConnected = await foLoginPage.isCustomerConnected(page); + expect(isCustomerConnected, 'Customer is not connected').to.eq(true); + }); + + it('should go to vouchers page', async function () { + await testContext.addContextItem(this, 'testIdentifier', 'goToFOVouchersPage', baseContext); + + await homePage.goToMyAccountPage(page); + await myAccountPage.goToVouchersPage(page); + + const pageHeaderTitle = await foVouchersPage.getPageTitle(page); + expect(pageHeaderTitle).to.equal(foVouchersPage.pageTitle); + }); + + [ + {args: {column: 'code', row: 1, value: firstCartRule.code}}, + {args: {column: 'description', row: 1, value: firstCartRule.name}}, + {args: {column: 'quantity', row: 1, value: '1'}}, + {args: {column: 'value', row: 1, value: '20%'}}, + {args: {column: 'minimum', row: 1, value: 'None'}}, + {args: {column: 'cumulative', row: 1, value: 'Yes'}}, + {args: {column: 'expiration_date', row: 1, value: expirationDate}}, + {args: {column: 'code', row: 2, value: secondCartRule.code}}, + {args: {column: 'description', row: 2, value: secondCartRule.name}}, + {args: {column: 'quantity', row: 2, value: '1'}}, + {args: {column: 'value', row: 2, value: 'Free shipping'}}, + {args: {column: 'minimum', row: 2, value: 'None'}}, + {args: {column: 'cumulative', row: 2, value: 'Yes'}}, + {args: {column: 'expiration_date', row: 2, value: expirationDate}}, + ].forEach((cartRule, index: number) => { + it(`should check the voucher ${cartRule.args.column} n°${cartRule.args.row}`, async function () { + await testContext.addContextItem(this, 'testIdentifier', `checkVoucher${index}`, baseContext); + + const cartRuleTextColumn = await foVouchersPage.getTextColumnFromTableVouchers( + page, + cartRule.args.row, + cartRule.args.column, + ); + expect(cartRuleTextColumn).to.equal(cartRule.args.value); + }); + }); + }); + + // Post-condition: Delete created customer + deleteCustomerTest(customerData, `${baseContext}_postTest_0`); + + // Post-condition : Uninstall Hummingbird + uninstallHummingbird(`${baseContext}_postTest_1`); +}); diff --git a/tests/UI/pages/FO/classic/myAccount/vouchers.ts b/tests/UI/pages/FO/classic/myAccount/vouchers.ts index 4604e27ce84cc..f31e598249480 100644 --- a/tests/UI/pages/FO/classic/myAccount/vouchers.ts +++ b/tests/UI/pages/FO/classic/myAccount/vouchers.ts @@ -7,7 +7,7 @@ import type {Page} from 'playwright'; * @class * @extends FOBasePage */ -class Vouchers extends FOBasePage { +class VouchersPage extends FOBasePage { public readonly pageTitle: string; private readonly vouchersTable: string; @@ -36,8 +36,8 @@ class Vouchers extends FOBasePage { * @constructs * Setting up texts and selectors to use on vouchers page */ - constructor() { - super(); + constructor(theme: string = 'classic') { + super(theme); this.pageTitle = 'Discount'; @@ -115,4 +115,5 @@ class Vouchers extends FOBasePage { } } -export default new Vouchers(); +const vouchersPage = new VouchersPage(); +export {vouchersPage, VouchersPage}; diff --git a/tests/UI/pages/FO/hummingbird/myAccount/vouchers.ts b/tests/UI/pages/FO/hummingbird/myAccount/vouchers.ts new file mode 100644 index 0000000000000..cc0ea50fa3cd8 --- /dev/null +++ b/tests/UI/pages/FO/hummingbird/myAccount/vouchers.ts @@ -0,0 +1,18 @@ +// Import FO pages +import {VouchersPage} from '@pages/FO/classic/myAccount/vouchers'; + +/** + * @class + * @extends FOBasePage + */ +class Vouchers extends VouchersPage { + /** + * @constructs + * Setting up texts and selectors to use + */ + constructor() { + super('hummingbird'); + } +} + +export default new Vouchers();