|
| 1 | +// Import utils |
| 2 | +import testContext from '@utils/testContext'; |
| 3 | + |
| 4 | +// Import commonTests |
| 5 | +import loginCommon from '@commonTests/BO/loginBO'; |
| 6 | +import {resetModule} from '@commonTests/BO/modules/moduleManager'; |
| 7 | + |
| 8 | +// Import pages |
| 9 | +// Import BO pages |
| 10 | +import boPaymentMethodsPage from '@pages/BO/payment/paymentMethods'; |
| 11 | +import psCheckPayment from '@pages/BO/modules/psCheckPayment'; |
| 12 | +import psWirePayment from '@pages/BO/modules/psWirePayment'; |
| 13 | + |
| 14 | +import { |
| 15 | + boDashboardPage, |
| 16 | + dataModules, |
| 17 | + dataPaymentMethods, |
| 18 | + utilsPlaywright, |
| 19 | +} from '@prestashop-core/ui-testing'; |
| 20 | + |
| 21 | +import {expect} from 'chai'; |
| 22 | +import type {BrowserContext, Page} from 'playwright'; |
| 23 | + |
| 24 | +const baseContext: string = 'functional_BO_payment_paymentMethods_configureModuleLink'; |
| 25 | + |
| 26 | +describe('BO - Payments - Payment methods: Configure module link', async () => { |
| 27 | + let browserContext: BrowserContext; |
| 28 | + let page: Page; |
| 29 | + |
| 30 | + describe('Configure module link', async () => { |
| 31 | + before(async function () { |
| 32 | + browserContext = await utilsPlaywright.createBrowserContext(this.browser); |
| 33 | + page = await utilsPlaywright.newTab(browserContext); |
| 34 | + }); |
| 35 | + |
| 36 | + after(async () => { |
| 37 | + await utilsPlaywright.closeBrowserContext(browserContext); |
| 38 | + }); |
| 39 | + |
| 40 | + it('should login in BO', async function () { |
| 41 | + await loginCommon.loginBO(this, page); |
| 42 | + }); |
| 43 | + |
| 44 | + it('should go to \'Payment > Payment Methods\' page', async function () { |
| 45 | + await testContext.addContextItem(this, 'testIdentifier', 'goToPaymentMethodsPage', baseContext); |
| 46 | + |
| 47 | + await boDashboardPage.goToSubMenu( |
| 48 | + page, |
| 49 | + boDashboardPage.paymentParentLink, |
| 50 | + boDashboardPage.paymentMethodsLink, |
| 51 | + ); |
| 52 | + await boPaymentMethodsPage.closeSfToolBar(page); |
| 53 | + |
| 54 | + const pageTitle = await boPaymentMethodsPage.getPageTitle(page); |
| 55 | + expect(pageTitle).to.contains(boPaymentMethodsPage.pageTitle); |
| 56 | + |
| 57 | + const numActivePayments = await boPaymentMethodsPage.getCountActivePayments(page); |
| 58 | + expect(numActivePayments).to.equal(Object.keys(dataPaymentMethods).length); |
| 59 | + }); |
| 60 | + |
| 61 | + it(`should click on the Configure button for "${dataPaymentMethods.wirePayment.displayName}"`, async function () { |
| 62 | + await testContext.addContextItem(this, 'testIdentifier', 'clickConfigureButtonWirePayment', baseContext); |
| 63 | + |
| 64 | + const hasConfigureButton = await boPaymentMethodsPage.hasConfigureButton(page, dataModules.psWirePayment); |
| 65 | + expect(hasConfigureButton).to.equal(true); |
| 66 | + |
| 67 | + await boPaymentMethodsPage.clickConfigureButton(page, dataModules.psWirePayment); |
| 68 | + |
| 69 | + const pageTitle = await psWirePayment.getPageSubTitle(page); |
| 70 | + expect(pageTitle).to.contains(psWirePayment.pageTitle); |
| 71 | + }); |
| 72 | + |
| 73 | + it(`should fill required fields for "${dataPaymentMethods.wirePayment.displayName}"`, async function () { |
| 74 | + await testContext.addContextItem(this, 'testIdentifier', 'fillRequiredFieldsWirePayment', baseContext); |
| 75 | + |
| 76 | + await psWirePayment.setAccountOwner(page, 'Account Owner'); |
| 77 | + await psWirePayment.setAccountDetails(page, 'Account Details'); |
| 78 | + await psWirePayment.setBankAddress(page, 'Bank Address'); |
| 79 | + |
| 80 | + const result = await psWirePayment.saveFormContactDetails(page); |
| 81 | + expect(result).to.contains(psWirePayment.successfulUpdateMessage); |
| 82 | + }); |
| 83 | + |
| 84 | + it('should return to \'Payment > Payment Methods\' page', async function () { |
| 85 | + await testContext.addContextItem(this, 'testIdentifier', 'returnToPaymentMethodsPage', baseContext); |
| 86 | + |
| 87 | + await boDashboardPage.goToSubMenu( |
| 88 | + page, |
| 89 | + boDashboardPage.paymentParentLink, |
| 90 | + boDashboardPage.paymentMethodsLink, |
| 91 | + ); |
| 92 | + await boPaymentMethodsPage.closeSfToolBar(page); |
| 93 | + |
| 94 | + const pageTitle = await boPaymentMethodsPage.getPageTitle(page); |
| 95 | + expect(pageTitle).to.equal(boPaymentMethodsPage.pageTitle); |
| 96 | + |
| 97 | + const numActivePayments = await boPaymentMethodsPage.getCountActivePayments(page); |
| 98 | + expect(numActivePayments).to.equal(Object.keys(dataPaymentMethods).length); |
| 99 | + }); |
| 100 | + |
| 101 | + it(`should click on the Configure button for "${dataPaymentMethods.checkPayment.displayName}"`, async function () { |
| 102 | + await testContext.addContextItem(this, 'testIdentifier', 'clickConfigureButtonCheckPayment', baseContext); |
| 103 | + |
| 104 | + const hasConfigureButton = await boPaymentMethodsPage.hasConfigureButton(page, dataModules.psCheckPayment); |
| 105 | + expect(hasConfigureButton).to.equal(true); |
| 106 | + |
| 107 | + await boPaymentMethodsPage.clickConfigureButton(page, dataModules.psCheckPayment); |
| 108 | + |
| 109 | + const pageTitle = await psCheckPayment.getPageSubTitle(page); |
| 110 | + expect(pageTitle).to.equal(psCheckPayment.pageTitle); |
| 111 | + }); |
| 112 | + |
| 113 | + it(`should fill required fields for "${dataPaymentMethods.checkPayment.displayName}"`, async function () { |
| 114 | + await testContext.addContextItem(this, 'testIdentifier', 'fillRequiredFieldsCheckPayment', baseContext); |
| 115 | + |
| 116 | + await psCheckPayment.setPayee(page, 'Payee'); |
| 117 | + await psCheckPayment.setAddress(page, 'Address'); |
| 118 | + |
| 119 | + const result = await psCheckPayment.saveFormContactDetails(page); |
| 120 | + expect(result).to.contains(psCheckPayment.successfulUpdateMessage); |
| 121 | + }); |
| 122 | + |
| 123 | + it('should return to \'Payment > Payment Methods\' page', async function () { |
| 124 | + await testContext.addContextItem(this, 'testIdentifier', 'returnFinalPaymentMethodsPage', baseContext); |
| 125 | + |
| 126 | + await boDashboardPage.goToSubMenu( |
| 127 | + page, |
| 128 | + boDashboardPage.paymentParentLink, |
| 129 | + boDashboardPage.paymentMethodsLink, |
| 130 | + ); |
| 131 | + await boPaymentMethodsPage.closeSfToolBar(page); |
| 132 | + |
| 133 | + const pageTitle = await boPaymentMethodsPage.getPageTitle(page); |
| 134 | + expect(pageTitle).to.equal(boPaymentMethodsPage.pageTitle); |
| 135 | + |
| 136 | + const numActivePayments = await boPaymentMethodsPage.getCountActivePayments(page); |
| 137 | + expect(numActivePayments).to.equal(Object.keys(dataPaymentMethods).length); |
| 138 | + |
| 139 | + const hasConfigureButton = await boPaymentMethodsPage.hasConfigureButton(page, dataModules.psCashOnDelivery); |
| 140 | + expect(hasConfigureButton).to.equal(false); |
| 141 | + }); |
| 142 | + }); |
| 143 | + |
| 144 | + resetModule(dataModules.psWirePayment, `${baseContext}_postTest_0`); |
| 145 | + |
| 146 | + resetModule(dataModules.psCheckPayment, `${baseContext}_postTest_1`); |
| 147 | +}); |
0 commit comments