Skip to content

Commit

Permalink
Merge pull request PrestaShop#36488 from Progi1984/test980
Browse files Browse the repository at this point in the history
Functional Tests : BO - Payments - Payment methods: Configure module link
  • Loading branch information
Progi1984 authored Jul 9, 2024
2 parents 587b01b + 029b492 commit 298fe2b
Show file tree
Hide file tree
Showing 6 changed files with 313 additions and 3 deletions.
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
{% if paymentModules|length > 0 %}
<div class="module-item-list">
{% for module in paymentModules %}
<div class="row module-item-wrapper-list border-bottom mb-sm-3">
<div class="row module-item-wrapper-list border-bottom mb-sm-3" data-name="{{ module.attributes.name }}">
<div class="col-sm-2 col-md-1 col-lg-1">
<div class="module-logo-thumb-list text-center">
<img src="{{ module.attributes.img }}" alt="{{ module.attributes.displayName }}"/>
Expand Down
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`);
});
4 changes: 2 additions & 2 deletions tests/UI/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

72 changes: 72 additions & 0 deletions tests/UI/pages/BO/modules/psCheckPayment/index.ts
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();
85 changes: 85 additions & 0 deletions tests/UI/pages/BO/modules/psWirePayment/index.ts
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();

0 comments on commit 298fe2b

Please sign in to comment.