Skip to content

Commit 4f69f34

Browse files
committed
Functional Tests : BO - Payments - Payment methods: Configure module link
1 parent 5380725 commit 4f69f34

File tree

6 files changed

+382
-1
lines changed

6 files changed

+382
-1
lines changed

package-lock.json

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/PrestaShopBundle/Resources/views/Admin/Improve/Payment/PaymentMethods/Blocks/payment_modules_list.html.twig

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
{% if paymentModules|length > 0 %}
2929
<div class="module-item-list">
3030
{% for module in paymentModules %}
31-
<div class="row module-item-wrapper-list border-bottom mb-sm-3">
31+
<div class="row module-item-wrapper-list border-bottom mb-sm-3" data-name="{{ module.attributes.name }}">
3232
<div class="col-sm-2 col-md-1 col-lg-1">
3333
<div class="module-logo-thumb-list text-center">
3434
<img src="{{ module.attributes.img }}" alt="{{ module.attributes.displayName }}"/>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
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+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import {ModuleConfiguration} from '@pages/BO/modules/moduleConfiguration';
2+
3+
import {type Page} from 'playwright';
4+
5+
/**
6+
* Module configuration page for module : ps_checkpayment, contains selectors and functions for the page
7+
* @class
8+
* @extends ModuleConfiguration
9+
*/
10+
class PsCheckPaymentPage extends ModuleConfiguration {
11+
public readonly pageTitle: string;
12+
13+
private readonly configurationForm: string;
14+
15+
private readonly payeeInput: string;
16+
17+
private readonly addressInput: string;
18+
19+
private readonly submitContactDetails: string;
20+
21+
/**
22+
* @constructs
23+
* Setting up titles and selectors to use on page
24+
*/
25+
constructor() {
26+
super();
27+
this.pageTitle = 'Payments by check';
28+
this.successfulUpdateMessage = 'Settings updated';
29+
30+
// Selectors
31+
// Customer Notifications
32+
this.configurationForm = '#configuration_form';
33+
this.payeeInput = `${this.configurationForm} #CHEQUE_NAME`;
34+
this.addressInput = `${this.configurationForm} #CHEQUE_ADDRESS`;
35+
this.submitContactDetails = `${this.configurationForm} button[name="btnSubmit"]`;
36+
}
37+
38+
/* Methods */
39+
40+
/**
41+
* Define the field "Payee"
42+
* @param page {Page} Browser tab
43+
* @param payee {string}
44+
* @returns {Promise<void>}
45+
*/
46+
async setPayee(page: Page, payee: string): Promise<void> {
47+
return this.setInputValue(page, this.payeeInput, payee);
48+
}
49+
50+
/**
51+
* Define the field "Address"
52+
* @param page {Page} Browser tab
53+
* @param address {string}
54+
* @returns {Promise<void>}
55+
*/
56+
async setAddress(page: Page, address: string): Promise<void> {
57+
return this.setInputValue(page, this.addressInput, address);
58+
}
59+
60+
/**
61+
* Save the "Contact details" form
62+
* @param page {Page} Browser tab
63+
* @returns {Promise<string>}
64+
*/
65+
async saveFormContactDetails(page: Page): Promise<string> {
66+
await page.locator(this.submitContactDetails).click();
67+
68+
return this.getAlertSuccessBlockContent(page);
69+
}
70+
}
71+
72+
export default new PsCheckPaymentPage();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
import {ModuleConfiguration} from '@pages/BO/modules/moduleConfiguration';
2+
3+
import {type Page} from 'playwright';
4+
5+
/**
6+
* Module configuration page for module : ps_wirepayment, contains selectors and functions for the page
7+
* @class
8+
* @extends ModuleConfiguration
9+
*/
10+
class PsWirePaymentPage extends ModuleConfiguration {
11+
public readonly pageTitle: string;
12+
13+
private readonly accountDetailsForm: string;
14+
15+
private readonly accountOwnerInput: string;
16+
17+
private readonly accountDetailsInput: string;
18+
19+
private readonly bankAddresInput: string;
20+
21+
private readonly submitAccountDetails: string;
22+
23+
/**
24+
* @constructs
25+
* Setting up titles and selectors to use on page
26+
*/
27+
constructor() {
28+
super();
29+
this.pageTitle = 'Bank transfer';
30+
this.successfulUpdateMessage = 'Settings updated';
31+
32+
// Selectors
33+
// Customer Notifications
34+
this.accountDetailsForm = '#module_form';
35+
this.accountOwnerInput = `${this.accountDetailsForm} #BANK_WIRE_OWNER`;
36+
this.accountDetailsInput = `${this.accountDetailsForm} #BANK_WIRE_DETAILS`;
37+
this.bankAddresInput = `${this.accountDetailsForm} #BANK_WIRE_ADDRESS`;
38+
this.submitAccountDetails = `${this.accountDetailsForm} button#module_form_submit_btn`;
39+
}
40+
41+
/* Methods */
42+
43+
/**
44+
* Define the field "Account Owner"
45+
* @param page {Page} Browser tab
46+
* @param accountOwner {string}
47+
* @returns {Promise<void>}
48+
*/
49+
async setAccountOwner(page: Page, accountOwner: string): Promise<void> {
50+
return this.setInputValue(page, this.accountOwnerInput, accountOwner);
51+
}
52+
53+
/**
54+
* Define the field "Account Details"
55+
* @param page {Page} Browser tab
56+
* @param accountDetails {string}
57+
* @returns {Promise<void>}
58+
*/
59+
async setAccountDetails(page: Page, accountDetails: string): Promise<void> {
60+
return this.setInputValue(page, this.accountDetailsInput, accountDetails);
61+
}
62+
63+
/**
64+
* Define the field "Bank Address"
65+
* @param page {Page} Browser tab
66+
* @param bankAddress {string}
67+
* @returns {Promise<void>}
68+
*/
69+
async setBankAddress(page: Page, bankAddress: string): Promise<void> {
70+
return this.setInputValue(page, this.bankAddresInput, bankAddress);
71+
}
72+
73+
/**
74+
* Save the "Contact details" form
75+
* @param page {Page} Browser tab
76+
* @returns {Promise<string>}
77+
*/
78+
async saveFormContactDetails(page: Page): Promise<string> {
79+
await page.locator(this.submitAccountDetails).click();
80+
81+
return this.getAlertSuccessBlockContent(page);
82+
}
83+
}
84+
85+
export default new PsWirePaymentPage();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import BOBasePage from '@pages/BO/BObasePage';
2+
import {
3+
type FakerModule,
4+
} from '@prestashop-core/ui-testing';
5+
6+
import type {Page} from 'playwright';
7+
8+
/**
9+
* BO Payment preferences page, contains texts, selectors and functions to use on the page.
10+
* @class
11+
* @extends BOBasePage
12+
*/
13+
class PaymentMethodsPage extends BOBasePage {
14+
public readonly pageTitle: string;
15+
16+
private readonly tablePayments: string;
17+
18+
private readonly tablePaymentsRow: string;
19+
20+
private readonly tablePaymentsRowName: (name: string) => string;
21+
22+
private readonly tablePaymentsBtnConfigure: (name: string) => string;
23+
24+
/**
25+
* @constructs
26+
* Setting up texts and selectors to use
27+
*/
28+
constructor() {
29+
super();
30+
31+
this.pageTitle = `Payment methods • ${global.INSTALL.SHOP_NAME}`;
32+
this.tablePayments = '.card-body .module-item-list';
33+
this.tablePaymentsRow = `${this.tablePayments} div.row`;
34+
this.tablePaymentsRowName = (name: string) => `${this.tablePaymentsRow}[data-name="${name}"]`;
35+
this.tablePaymentsBtnConfigure = (name: string) => `${this.tablePaymentsRowName(name)} div:nth-child(3) a.btn`;
36+
}
37+
38+
/*
39+
Methods
40+
*/
41+
/**
42+
* Returns the number of active payments
43+
* @param page {Page} Browser tab
44+
* @returns {Promise<number>}
45+
*/
46+
async getCountActivePayments(page: Page): Promise<number> {
47+
return page.locator(this.tablePaymentsRow).count();
48+
}
49+
50+
/**
51+
* Returns if the active payment has a "Configure" button
52+
* @param page {Page} Browser tab
53+
* @param module {FakerModule} Module
54+
* @returns {Promise<boolean>}
55+
*/
56+
async hasConfigureButton(page: Page, module: FakerModule): Promise<boolean> {
57+
return (await page.locator(this.tablePaymentsBtnConfigure(module.tag)).count()) === 1;
58+
}
59+
60+
/**
61+
* Click on the "Configure" button
62+
* @param page {Page} Browser tab
63+
* @param module {FakerModule} Module
64+
* @returns {Promise<void>}
65+
*/
66+
async clickConfigureButton(page: Page, module: FakerModule): Promise<void> {
67+
await page.locator(this.tablePaymentsBtnConfigure(module.tag)).click();
68+
}
69+
}
70+
71+
export default new PaymentMethodsPage();

0 commit comments

Comments
 (0)