forked from PrestaShop/PrestaShop
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request PrestaShop#36488 from Progi1984/test980
Functional Tests : BO - Payments - Payment methods: Configure module link
- Loading branch information
Showing
6 changed files
with
313 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
147 changes: 147 additions & 0 deletions
147
tests/UI/campaigns/functional/BO/10_payment/01_paymentMethods/01_configureModuleLink.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,147 @@ | ||
// Import utils | ||
import testContext from '@utils/testContext'; | ||
|
||
// Import commonTests | ||
import loginCommon from '@commonTests/BO/loginBO'; | ||
import {resetModule} from '@commonTests/BO/modules/moduleManager'; | ||
|
||
// Import pages | ||
// Import BO pages | ||
import psCheckPayment from '@pages/BO/modules/psCheckPayment'; | ||
import psWirePayment from '@pages/BO/modules/psWirePayment'; | ||
|
||
import { | ||
boDashboardPage, | ||
boPaymentMethodsPage, | ||
dataModules, | ||
dataPaymentMethods, | ||
utilsPlaywright, | ||
} from '@prestashop-core/ui-testing'; | ||
|
||
import {expect} from 'chai'; | ||
import type {BrowserContext, Page} from 'playwright'; | ||
|
||
const baseContext: string = 'functional_BO_payment_paymentMethods_configureModuleLink'; | ||
|
||
describe('BO - Payments - Payment methods: Configure module link', async () => { | ||
let browserContext: BrowserContext; | ||
let page: Page; | ||
|
||
describe('Configure module link', async () => { | ||
before(async function () { | ||
browserContext = await utilsPlaywright.createBrowserContext(this.browser); | ||
page = await utilsPlaywright.newTab(browserContext); | ||
}); | ||
|
||
after(async () => { | ||
await utilsPlaywright.closeBrowserContext(browserContext); | ||
}); | ||
|
||
it('should login in BO', async function () { | ||
await loginCommon.loginBO(this, page); | ||
}); | ||
|
||
it('should go to \'Payment > Payment Methods\' page', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'goToPaymentMethodsPage', baseContext); | ||
|
||
await boDashboardPage.goToSubMenu( | ||
page, | ||
boDashboardPage.paymentParentLink, | ||
boDashboardPage.paymentMethodsLink, | ||
); | ||
await boPaymentMethodsPage.closeSfToolBar(page); | ||
|
||
const pageTitle = await boPaymentMethodsPage.getPageTitle(page); | ||
expect(pageTitle).to.contains(boPaymentMethodsPage.pageTitle); | ||
|
||
const numActivePayments = await boPaymentMethodsPage.getCountActivePayments(page); | ||
expect(numActivePayments).to.equal(Object.keys(dataPaymentMethods).length); | ||
}); | ||
|
||
it(`should click on the Configure button for "${dataPaymentMethods.wirePayment.displayName}"`, async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'clickConfigureButtonWirePayment', baseContext); | ||
|
||
const hasConfigureButton = await boPaymentMethodsPage.hasConfigureButton(page, dataModules.psWirePayment); | ||
expect(hasConfigureButton).to.equal(true); | ||
|
||
await boPaymentMethodsPage.clickConfigureButton(page, dataModules.psWirePayment); | ||
|
||
const pageTitle = await psWirePayment.getPageSubTitle(page); | ||
expect(pageTitle).to.contains(psWirePayment.pageTitle); | ||
}); | ||
|
||
it(`should fill required fields for "${dataPaymentMethods.wirePayment.displayName}"`, async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'fillRequiredFieldsWirePayment', baseContext); | ||
|
||
await psWirePayment.setAccountOwner(page, 'Account Owner'); | ||
await psWirePayment.setAccountDetails(page, 'Account Details'); | ||
await psWirePayment.setBankAddress(page, 'Bank Address'); | ||
|
||
const result = await psWirePayment.saveFormContactDetails(page); | ||
expect(result).to.contains(psWirePayment.successfulUpdateMessage); | ||
}); | ||
|
||
it('should return to \'Payment > Payment Methods\' page', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'returnToPaymentMethodsPage', baseContext); | ||
|
||
await boDashboardPage.goToSubMenu( | ||
page, | ||
boDashboardPage.paymentParentLink, | ||
boDashboardPage.paymentMethodsLink, | ||
); | ||
await boPaymentMethodsPage.closeSfToolBar(page); | ||
|
||
const pageTitle = await boPaymentMethodsPage.getPageTitle(page); | ||
expect(pageTitle).to.equal(boPaymentMethodsPage.pageTitle); | ||
|
||
const numActivePayments = await boPaymentMethodsPage.getCountActivePayments(page); | ||
expect(numActivePayments).to.equal(Object.keys(dataPaymentMethods).length); | ||
}); | ||
|
||
it(`should click on the Configure button for "${dataPaymentMethods.checkPayment.displayName}"`, async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'clickConfigureButtonCheckPayment', baseContext); | ||
|
||
const hasConfigureButton = await boPaymentMethodsPage.hasConfigureButton(page, dataModules.psCheckPayment); | ||
expect(hasConfigureButton).to.equal(true); | ||
|
||
await boPaymentMethodsPage.clickConfigureButton(page, dataModules.psCheckPayment); | ||
|
||
const pageTitle = await psCheckPayment.getPageSubTitle(page); | ||
expect(pageTitle).to.equal(psCheckPayment.pageTitle); | ||
}); | ||
|
||
it(`should fill required fields for "${dataPaymentMethods.checkPayment.displayName}"`, async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'fillRequiredFieldsCheckPayment', baseContext); | ||
|
||
await psCheckPayment.setPayee(page, 'Payee'); | ||
await psCheckPayment.setAddress(page, 'Address'); | ||
|
||
const result = await psCheckPayment.saveFormContactDetails(page); | ||
expect(result).to.contains(psCheckPayment.successfulUpdateMessage); | ||
}); | ||
|
||
it('should return to \'Payment > Payment Methods\' page', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'returnFinalPaymentMethodsPage', baseContext); | ||
|
||
await boDashboardPage.goToSubMenu( | ||
page, | ||
boDashboardPage.paymentParentLink, | ||
boDashboardPage.paymentMethodsLink, | ||
); | ||
await boPaymentMethodsPage.closeSfToolBar(page); | ||
|
||
const pageTitle = await boPaymentMethodsPage.getPageTitle(page); | ||
expect(pageTitle).to.equal(boPaymentMethodsPage.pageTitle); | ||
|
||
const numActivePayments = await boPaymentMethodsPage.getCountActivePayments(page); | ||
expect(numActivePayments).to.equal(Object.keys(dataPaymentMethods).length); | ||
|
||
const hasConfigureButton = await boPaymentMethodsPage.hasConfigureButton(page, dataModules.psCashOnDelivery); | ||
expect(hasConfigureButton).to.equal(false); | ||
}); | ||
}); | ||
|
||
resetModule(dataModules.psWirePayment, `${baseContext}_postTest_0`); | ||
|
||
resetModule(dataModules.psCheckPayment, `${baseContext}_postTest_1`); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,72 @@ | ||
import {ModuleConfiguration} from '@pages/BO/modules/moduleConfiguration'; | ||
|
||
import {type Page} from 'playwright'; | ||
|
||
/** | ||
* Module configuration page for module : ps_checkpayment, contains selectors and functions for the page | ||
* @class | ||
* @extends ModuleConfiguration | ||
*/ | ||
class PsCheckPaymentPage extends ModuleConfiguration { | ||
public readonly pageTitle: string; | ||
|
||
private readonly configurationForm: string; | ||
|
||
private readonly payeeInput: string; | ||
|
||
private readonly addressInput: string; | ||
|
||
private readonly submitContactDetails: string; | ||
|
||
/** | ||
* @constructs | ||
* Setting up titles and selectors to use on page | ||
*/ | ||
constructor() { | ||
super(); | ||
this.pageTitle = 'Payments by check'; | ||
this.successfulUpdateMessage = 'Settings updated'; | ||
|
||
// Selectors | ||
// Customer Notifications | ||
this.configurationForm = '#configuration_form'; | ||
this.payeeInput = `${this.configurationForm} #CHEQUE_NAME`; | ||
this.addressInput = `${this.configurationForm} #CHEQUE_ADDRESS`; | ||
this.submitContactDetails = `${this.configurationForm} button[name="btnSubmit"]`; | ||
} | ||
|
||
/* Methods */ | ||
|
||
/** | ||
* Define the field "Payee" | ||
* @param page {Page} Browser tab | ||
* @param payee {string} | ||
* @returns {Promise<void>} | ||
*/ | ||
async setPayee(page: Page, payee: string): Promise<void> { | ||
return this.setInputValue(page, this.payeeInput, payee); | ||
} | ||
|
||
/** | ||
* Define the field "Address" | ||
* @param page {Page} Browser tab | ||
* @param address {string} | ||
* @returns {Promise<void>} | ||
*/ | ||
async setAddress(page: Page, address: string): Promise<void> { | ||
return this.setInputValue(page, this.addressInput, address); | ||
} | ||
|
||
/** | ||
* Save the "Contact details" form | ||
* @param page {Page} Browser tab | ||
* @returns {Promise<string>} | ||
*/ | ||
async saveFormContactDetails(page: Page): Promise<string> { | ||
await page.locator(this.submitContactDetails).click(); | ||
|
||
return this.getAlertSuccessBlockContent(page); | ||
} | ||
} | ||
|
||
export default new PsCheckPaymentPage(); |
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,85 @@ | ||
import {ModuleConfiguration} from '@pages/BO/modules/moduleConfiguration'; | ||
|
||
import {type Page} from 'playwright'; | ||
|
||
/** | ||
* Module configuration page for module : ps_wirepayment, contains selectors and functions for the page | ||
* @class | ||
* @extends ModuleConfiguration | ||
*/ | ||
class PsWirePaymentPage extends ModuleConfiguration { | ||
public readonly pageTitle: string; | ||
|
||
private readonly accountDetailsForm: string; | ||
|
||
private readonly accountOwnerInput: string; | ||
|
||
private readonly accountDetailsInput: string; | ||
|
||
private readonly bankAddresInput: string; | ||
|
||
private readonly submitAccountDetails: string; | ||
|
||
/** | ||
* @constructs | ||
* Setting up titles and selectors to use on page | ||
*/ | ||
constructor() { | ||
super(); | ||
this.pageTitle = 'Bank transfer'; | ||
this.successfulUpdateMessage = 'Settings updated'; | ||
|
||
// Selectors | ||
// Customer Notifications | ||
this.accountDetailsForm = '#module_form'; | ||
this.accountOwnerInput = `${this.accountDetailsForm} #BANK_WIRE_OWNER`; | ||
this.accountDetailsInput = `${this.accountDetailsForm} #BANK_WIRE_DETAILS`; | ||
this.bankAddresInput = `${this.accountDetailsForm} #BANK_WIRE_ADDRESS`; | ||
this.submitAccountDetails = `${this.accountDetailsForm} button#module_form_submit_btn`; | ||
} | ||
|
||
/* Methods */ | ||
|
||
/** | ||
* Define the field "Account Owner" | ||
* @param page {Page} Browser tab | ||
* @param accountOwner {string} | ||
* @returns {Promise<void>} | ||
*/ | ||
async setAccountOwner(page: Page, accountOwner: string): Promise<void> { | ||
return this.setInputValue(page, this.accountOwnerInput, accountOwner); | ||
} | ||
|
||
/** | ||
* Define the field "Account Details" | ||
* @param page {Page} Browser tab | ||
* @param accountDetails {string} | ||
* @returns {Promise<void>} | ||
*/ | ||
async setAccountDetails(page: Page, accountDetails: string): Promise<void> { | ||
return this.setInputValue(page, this.accountDetailsInput, accountDetails); | ||
} | ||
|
||
/** | ||
* Define the field "Bank Address" | ||
* @param page {Page} Browser tab | ||
* @param bankAddress {string} | ||
* @returns {Promise<void>} | ||
*/ | ||
async setBankAddress(page: Page, bankAddress: string): Promise<void> { | ||
return this.setInputValue(page, this.bankAddresInput, bankAddress); | ||
} | ||
|
||
/** | ||
* Save the "Contact details" form | ||
* @param page {Page} Browser tab | ||
* @returns {Promise<string>} | ||
*/ | ||
async saveFormContactDetails(page: Page): Promise<string> { | ||
await page.locator(this.submitAccountDetails).click(); | ||
|
||
return this.getAlertSuccessBlockContent(page); | ||
} | ||
} | ||
|
||
export default new PsWirePaymentPage(); |