Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HP-1456 Tests playwright for requisites #449

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions tests/playwright/Helper/RequisiteHelper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { expect, Locator, Page } from "@playwright/test";
import Select2 from "@hipanel-core/input/Select2";

export default class RequisiteHelper {
private page: Page;

public constructor(page: Page) {
this.page = page;
}

async gotoIndexRequisite() {
await this.page.goto('/finance/requisite/index');
await expect(this.page).toHaveTitle("Requisites");
}

async seeNewInvoice() {
await this.page.locator('text=Test Reseller / Test Reseller >> nth=0').click();
await this.page.locator('.editable-input').click();
await this.page.locator('.select2-search__field').fill('Test Reseller');
await this.page.locator('text=Test ResellerTest Reseller').click();
await this.page.locator('text=Requisite Test Reseller / Test ResellerTest Reseller×Test Reseller >> button >> nth=1').click();
await this.page.locator('.text-right > .btn-group > a >> nth=0').click();
await this.page.locator('input:has-text("See new")').first().click();
}
}
60 changes: 60 additions & 0 deletions tests/playwright/e2e/seller/requisites-create.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { test } from "@hipanel-core/fixtures";
import { expect } from "@playwright/test";
import Alert from "@hipanel-core/ui/Alert";
import RequisiteForm from "@hipanel-module-finance/page/RequisiteForm";
import Requisite from "@hipanel-module-finance/model/Requisite";
import Index from "@hipanel-core/page/Index";
import Select2 from "@hipanel-core/input/Select2";
import Input from "@hipanel-core/input/Input";
import RequisiteHelper from "@hipanel-module-finance/Helper/RequisiteHelper";

const requisites: Requisite[] = [
{
currency: "usd",
bankAccount: "TE00001111000011110000111100",
bankName: "USbank",
bankAddress: "0 Test street, Ukraine",
swiftCode: "TEST01WW",
corespondentBank: "CorTestBank",
correspondentBankSwiftCode: "TEST01YY",
},
{
currency: "eur",
bankAccount: "ET00001111000011110000111100",
bankName: "EUbank",
bankAddress: "1 Test street, Ukraine",
swiftCode: "ETST01WW",
corespondentBank: "CorTestBank",
correspondentBankSwiftCode: "ETST01YY",
}
];
const requisiteName = 'Test Reseller\nTest Reseller';
const clientTest = 'hipanel_test_user';

test("Test create requisites @hipanel-module-finance @seller", async ({ sellerPage }) => {
const requisiteHelper = new RequisiteHelper(sellerPage);

requisiteHelper.gotoIndexRequisite();

const requisiteForm = new RequisiteForm(sellerPage);
await requisiteForm.gotoRequisiteView(requisiteName);
await requisiteForm.edit();

await requisiteForm.fill(requisites);
await requisiteForm.saveRequisite();

await requisiteForm.seeSuccessAlert();
});

test("Test see new invoice @hipanel-module-finance @seller", async ({ sellerPage }) => {
const requisiteHelper = new RequisiteHelper(sellerPage);
const index = new Index(sellerPage);

await sellerPage.goto("/client/client/index");
await expect(sellerPage).toHaveTitle("Clients");

await Input.filterBy(sellerPage, 'Login').setValue(clientTest);
await index.clickColumnOnTable('Login', 1);

await expect(sellerPage).toHaveURL(new RegExp(".*finance/purse/generate-monthly-document.*"));
});
11 changes: 11 additions & 0 deletions tests/playwright/model/Requisite.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import Charge from "@hipanel-module-finance/model/Charge";

export default class Requisite {
public currency: string;
public bankAccount: string;
public bankName: string;
public bankAddress: string;
public swiftCode: string;
public corespondentBank: string;
public correspondentBankSwiftCode: string;
}
56 changes: 56 additions & 0 deletions tests/playwright/page/RequisiteForm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { expect, Locator, Page } from "@playwright/test";
import Select2 from "@hipanel-core/input/Select2";
import TreeSelect from "@hipanel-core/input/TreeSelect";
import SumWithCurrency from "@hipanel-core/input/SumWithCurrency";
import Alert from "@hipanel-core/ui/Alert";
import Requisite from "@hipanel-module-finance/model/Requisite";
import Index from "@hipanel-core/page/Index";
import Input from "@hipanel-core/input/Input";
import Dropdown from "@hipanel-core/input/Dropdown";

export default class RequisiteForm {
private page: Page;
private index: Index
private addBankDetailsBtn: Locator;

constructor(page: Page) {
this.page = page;
this.index = new Index(page);
this.addBankDetailsBtn = this.page.locator('button:has-text("Add bank details")');
}

async fill(requisites: Requisite[]) {
for (const requisite of requisites) {
let k = requisites.indexOf(requisite);
await this.fillRequisite(requisite, k);
}
}

async fillRequisite(requisite: Requisite, n: number = 0) {
await this.addBankDetailsBtn.click();

await Dropdown.field(this.page, `#bankdetails-${n}-currency`).setValue(requisite.currency);
await Input.field(this.page, `#bankdetails-${n}-bank_account`).setValue(requisite.bankAccount);
await Input.field(this.page, `#bankdetails-${n}-bank_name`).setValue(requisite.bankName);
await Input.field(this.page, `#bankdetails-${n}-bank_address`).setValue(requisite.bankAddress);
await Input.field(this.page, `#bankdetails-${n}-bank_swift`).setValue(requisite.swiftCode);
await Input.field(this.page, `#bankdetails-${n}-bank_correspondent`).setValue(requisite.corespondentBank);
await Input.field(this.page, `#bankdetails-${n}-bank_correspondent_swift`).setValue(requisite.correspondentBankSwiftCode);
}

async gotoRequisiteView(name: string) {
await this.index.clickLinkOnTable('Name', name);
}

async edit() {
await this.index.clickProfileMenuOnViewPage('Edit');
}

async saveRequisite() {
await this.page.locator('button.btn-success:has-text("Save")').click();
}

async seeSuccessAlert() {
await Alert.on(this.page).hasText("Contact was updated");
}
}