diff --git a/src/grid/presenters/price/CertificatePricePresenter.php b/src/grid/presenters/price/CertificatePricePresenter.php index 7d814b4e..18392808 100644 --- a/src/grid/presenters/price/CertificatePricePresenter.php +++ b/src/grid/presenters/price/CertificatePricePresenter.php @@ -10,7 +10,8 @@ namespace hipanel\modules\finance\grid\presenters\price; -use hipanel\modules\finance\models\Price; +use hipanel\modules\finance\models\CertificatePrice; +use hipanel\modules\finance\models\RepresentablePrice; use Money\MoneyFormatter; use yii\i18n\Formatter; use yii\web\User; @@ -32,13 +33,13 @@ public function __construct(Formatter $formatter, User $user, MoneyFormatter $mo } /** - * @param \hipanel\modules\finance\models\CertificatePrice $price + * @param CertificatePrice $price * @return string */ - public function renderPrice(Price $price): string + public function renderPrice(RepresentablePrice $price): string { $result = []; - foreach ($price->sums as $period => $amount) { + foreach ($price->sums as $amount) { $result[] = $this->moneyFormatter->format($amount); } diff --git a/src/grid/presenters/price/TemplatePricePresenter.php b/src/grid/presenters/price/TemplatePricePresenter.php index a9013630..bab9ff62 100644 --- a/src/grid/presenters/price/TemplatePricePresenter.php +++ b/src/grid/presenters/price/TemplatePricePresenter.php @@ -11,9 +11,11 @@ namespace hipanel\modules\finance\grid\presenters\price; use hipanel\helpers\StringHelper; -use hipanel\modules\finance\models\Price; +use hipanel\modules\finance\models\RepresentablePrice; +use hipanel\modules\finance\models\TemplatePrice; use Yii; use yii\base\InvalidConfigException; +use yii\di\NotInstantiableException; use yii\helpers\Html; /** @@ -24,10 +26,12 @@ class TemplatePricePresenter extends PricePresenter { /** - * @param \hipanel\modules\finance\models\TemplatePrice $price + * @param TemplatePrice $price * @return string + * @throws InvalidConfigException + * @throws NotInstantiableException */ - public function renderPrice(Price $price): string + public function renderPrice(RepresentablePrice $price): string { $formatter = Yii::$app->formatter; diff --git a/tests/playwright/Helper/PriceHelper.ts b/tests/playwright/Helper/PriceHelper.ts index 05ff1ea8..39b486b5 100644 --- a/tests/playwright/Helper/PriceHelper.ts +++ b/tests/playwright/Helper/PriceHelper.ts @@ -1,64 +1,58 @@ -import { expect, Locator, Page } from "@playwright/test"; -import Index from "@hipanel-core/page/Index"; +import { expect, Page } from "@playwright/test"; export default class PriceHelper { - private page: Page; - private indexPage: Index - - public constructor(page: Page) { - this.page = page; - this.indexPage = new Index(page); - } - - async createPlan(planName) { - await this.page.goto("/finance/plan/index"); - await this.page.getByRole("link", { name: "Create" }).click(); - await this.page.getByLabel("Name").fill(planName); - await this.page.getByLabel("Type").selectOption("template"); - await this.page.locator("#select2-plan-client-container").click(); - await this.page.getByRole("option", { name: "hipanel_test_reseller" }).click(); - await this.page.locator("#select2-plan-currency-container").click(); - await this.page.getByRole("option", { name: "USD", exact: true}).click(); - await this.page.getByRole("button", { name: "Save" }).click(); + constructor(readonly page: Page) { + } + + async createPlan(planName: string) { + await this.page.goto("/finance/plan/index"); + await this.page.getByRole("link", { name: "Create" }).click(); + await this.page.getByLabel("Name").fill(planName); + await this.page.getByLabel("Type").selectOption("template"); + await this.page.locator("#select2-plan-client-container").click(); + await this.page.getByRole("option", { name: "hipanel_test_reseller" }).click(); + await this.page.locator("#select2-plan-currency-container").click(); + await this.page.getByRole("option", { name: "USD", exact: true }).click(); + await this.page.getByRole("button", { name: "Save" }).click(); + } + + async createProgressivePrice(planName: string) { + await this.page.getByRole("link", { name: "Create prices" }).click(); + await this.page.locator("a").filter({ hasText: /^Create prices$/ }).click(); + await this.page.locator("#select2-type-container").click(); + await expect(this.page.getByRole("heading", { name: "Create prices" })).toBeVisible(); + await this.page.getByRole("option", { name: "Dedicated Server" }).click(); + await this.page.getByRole("button", { name: "Proceed to creation" }).click(); + await expect(this.page.getByRole("heading", { name: "Create suggested prices" })).toBeVisible(); + await expect(this.page.getByRole("heading", { name: `Tariff: ${planName}` })).toBeVisible(); + await this.page.locator(".remove-item").first().click(); + await this.page.locator(".remove-item").first().click(); + let pricesCount = await this.page.locator(".form-instance").count(); + + for (let i = 0; i < pricesCount - 1; i++) { + await this.page.locator("div:nth-child(2) > div > .form-instance > .col-md-1 > .remove-item").click(); } - async createProgressivePrice(planName) { - await this.page.getByRole("link", { name: "Create prices" }).click(); - await this.page.locator("a").filter({ hasText: /^Create prices$/ }).click(); - await this.page.locator("#select2-type-container").click(); - await expect(this.page.getByRole("heading", { name: "Create prices" })).toBeVisible(); - await this.page.getByRole("option", { name: "Dedicated Server" }).click(); - await this.page.getByRole("button", { name: "Proceed to creation" }).click(); - await expect(this.page.getByRole("heading", { name: "Create suggested prices" })).toBeVisible(); - await expect(this.page.getByRole("heading", { name: `Tariff: ${planName}` })).toBeVisible(); - await this.page.locator(".remove-item").first().click(); - await this.page.locator(".remove-item").first().click(); - let pricesCount = await this.page.locator(".form-instance").count(); - - for (let i = 0; i < pricesCount - 1; i++) { - await this.page.locator("div:nth-child(2) > div > .form-instance > .col-md-1 > .remove-item").click(); - } - - await this.page.getByTestId("add progression").click(); - await this.page.locator("#threshold-0-1-quantity").fill("1"); - await this.page.locator("#threshold-0-1-price").fill("0.0085"); - await this.page.getByTestId("add progression").click(); - await this.page.locator("#threshold-0-2-quantity").fill("2"); - await this.page.locator("#threshold-0-2-price").fill("0.0080"); - await this.page.getByTestId("add progression").click(); - await this.page.locator("#threshold-0-3-quantity").fill("3"); - await this.page.locator("#threshold-0-3-price").fill("0.0075"); - - await this.page.getByRole("button", { name: "Save" }).click(); - } - - async deleteProgressivePriceItems() { - await this.page.locator('input[name="selection_all"]').check(); - await this.page.getByRole("button", { name: "Update" }).click(); - await expect( this.page.locator('input#progressiveprice-0-class')).toBeHidden(); - await this.page.locator('.remove-threshold').first().click(); - await this.page.locator('.remove-threshold').first().click(); - await this.page.locator('.remove-threshold').click(); - await this.page.getByRole("button", { name: "Save" }).click(); - } + await this.page.getByTestId("add progression").click(); + await this.page.locator("#threshold-0-1-quantity").fill("1"); + await this.page.locator("#threshold-0-1-price").fill("0.0085"); + await this.page.getByTestId("add progression").click(); + await this.page.locator("#threshold-0-2-quantity").fill("2"); + await this.page.locator("#threshold-0-2-price").fill("0.0080"); + await this.page.getByTestId("add progression").click(); + await this.page.locator("#threshold-0-3-quantity").fill("3"); + await this.page.locator("#threshold-0-3-price").fill("0.0075"); + + await this.page.getByRole("button", { name: "Save" }).click(); + } + + async deleteProgressivePriceItems() { + await this.page.locator("input[name=\"selection_all\"]").check(); + await this.page.getByRole("button", { name: "Update" }).click(); + await expect(this.page.locator("input#progressiveprice-0-class")).toBeHidden(); + await this.page.locator(".remove-threshold").first().click(); + await this.page.locator(".remove-threshold").first().click(); + await this.page.locator(".remove-threshold").click(); + await this.page.getByRole("button", { name: "Save" }).click(); + } } diff --git a/tests/playwright/e2e/client/account-recharging.spec.ts b/tests/playwright/e2e/client/account-recharging.spec.ts index 633ad887..5e4b5246 100644 --- a/tests/playwright/e2e/client/account-recharging.spec.ts +++ b/tests/playwright/e2e/client/account-recharging.spec.ts @@ -1,5 +1,4 @@ -import { test } from "@hipanel-core/fixtures"; -import { expect } from "@playwright/test"; +import { expect, test } from "@hipanel-core/fixtures"; test("Test the Account recharging page works @hipanel-module-finance @client @seller", async ({ clientPage, sellerPage }) => { const pageUrl = "/merchant/pay/deposit"; @@ -7,7 +6,7 @@ test("Test the Account recharging page works @hipanel-module-finance @client @se await page.goto(pageUrl); await expect(page).toHaveTitle("Account recharging"); await expect(page.locator("//input[@id='depositform-amount']")).toBeVisible(); - await expect(page.getByRole('button', { name: 'Proceed' })).toBeVisible(); + await expect(page.getByRole("button", { name: "Proceed" })).toBeVisible(); await expect(page.locator("h4:text('Important information')")).toBeVisible(); await expect(page.locator("p:text('Remember to return to the site after successful payment!')")).toBeVisible(); } diff --git a/tests/playwright/e2e/manager/currency-exchange.spec.ts b/tests/playwright/e2e/manager/currency-exchange.spec.ts index 0d8c61d6..48dfd40e 100644 --- a/tests/playwright/e2e/manager/currency-exchange.spec.ts +++ b/tests/playwright/e2e/manager/currency-exchange.spec.ts @@ -1,7 +1,7 @@ import { test } from "@hipanel-core/fixtures"; import { expect } from "@playwright/test"; import Select2 from "@hipanel-core/input/Select2"; -import Alert from "@hipanel-core/ui/Alert"; +import { Alert } from "@hipanel-core/shared/ui/components"; import AdvancedSearch from "@hipanel-core/helper/AdvancedSearch"; test("the currency exchange operation works and creates a bill @hipanel-module-finance @manager", async ({ page }) => { @@ -28,7 +28,7 @@ test("the currency exchange operation works and creates a bill @hipanel-module-f await advancedSearch.setFilter("client_id", "hipanel_test_user"); await advancedSearch.setFilter("descr", "Exchanging 200.00 USD"); - await advancedSearch.submitButton(); + await advancedSearch.search(); await page.locator("div[role=grid] a:has-text(\"-$200.00\")").first().click(); diff --git a/tests/playwright/e2e/manager/progressive-price.spec.ts b/tests/playwright/e2e/manager/progressive-price.spec.ts index c9c61710..6172d545 100644 --- a/tests/playwright/e2e/manager/progressive-price.spec.ts +++ b/tests/playwright/e2e/manager/progressive-price.spec.ts @@ -2,11 +2,12 @@ import { test } from "@hipanel-core/fixtures"; import { expect } from "@playwright/test"; import PriceHelper from "@hipanel-module-finance/Helper/PriceHelper"; import ViewTableHelper from "@hipanel-module-finance/Helper/ViewTableHelper"; +import { faker } from "@faker-js/faker"; -test("Test the Progressive Price feature works @hipanel-module-finance @manager", { - tag: '@dedicated-server', +test("the Progressive Price feature works @hipanel-module-finance @manager", { + tag: "@dedicated-server", }, async ({ page }) => { - const planName = "TEST-PROGRESSIVE-PRICE-TEMPLATE" + Math.random().toString(36).substring(7); + const planName = "TEST-PROGRESSIVE-PRICE-TEMPLATE-" + faker.string.nanoid(10).toUpperCase(); const priceHelper = new PriceHelper(page); const viewTable = new ViewTableHelper(page); @@ -14,15 +15,20 @@ test("Test the Progressive Price feature works @hipanel-module-finance @manager" await expect(page.locator("h1")).toContainText(planName); - await viewTable.assertCellEquals('Name', planName); - await viewTable.assertCellEquals('Type', 'template'); - await viewTable.assertCellEquals('Status', 'ok'); + await viewTable.assertCellEquals("Name", planName); + await viewTable.assertCellEquals("Type", "template"); + await viewTable.assertCellEquals("Status", "ok"); await priceHelper.createProgressivePrice(planName); - await expect(page.getByRole("cell", { name: "$30.00 per Item over 0 Item $0.0085 per Item over 1 Item $0.008 per Item over 2 Item $0.0075 per Item over 3 Item" })).toBeVisible(); - await expect(page.getByText("Number of IPs")).toBeVisible(); + await expect(page.getByRole("cell", { + name: "First 1 Item $30.00 " + + "Next 1 Item $0.0085 (-100%) " + + "Next 1 Item $0.008 (-6%) " + + "Over 3 Item $0.0075 (-6%) ", + })).toBeVisible(); + page.on("dialog", async dialog => { await dialog.accept(); @@ -30,10 +36,6 @@ test("Test the Progressive Price feature works @hipanel-module-finance @manager" await priceHelper.deleteProgressivePriceItems(); - await page.locator('input[name="selection_all"]').check(); - await page.getByRole("button", { name: "Update" }).click(); - await expect( page.locator('input#templateprice-0-class')).toBeHidden(); - await page.getByRole("button", { name: "Cancel" }).click(); - - await page.getByTestId("delete").click(); + await expect(page.getByText("Number of IPs")).toBeVisible(); + await expect(page.getByText("$30.00 per Item")).toBeVisible(); }); diff --git a/tests/playwright/e2e/sales.spec.ts b/tests/playwright/e2e/sales.spec.ts index c2d4183b..cdbe3650 100644 --- a/tests/playwright/e2e/sales.spec.ts +++ b/tests/playwright/e2e/sales.spec.ts @@ -5,7 +5,7 @@ import ServerView from "@hipanel-module-finance/page/bill/ServerView"; import SaleHelper from "@hipanel-module-finance/Helper/SaleHelper"; import Index from "@hipanel-core/page/Index"; import SaleUpdate from "@hipanel-module-finance/page/bill/SaleUpdate"; -import Alert from "@hipanel-core/ui/Alert"; +import { Alert } from "@hipanel-core/shared/ui/components"; import DateHelper from "@hipanel-core/helper/DateHelper"; const sales: Array = [ diff --git a/tests/playwright/e2e/seller/bill-copy.spec.ts b/tests/playwright/e2e/seller/bill-copy.spec.ts index bc1ef52b..ebb5ff00 100644 --- a/tests/playwright/e2e/seller/bill-copy.spec.ts +++ b/tests/playwright/e2e/seller/bill-copy.spec.ts @@ -4,7 +4,7 @@ import BillForm from "@hipanel-module-finance/page/bill/BillForm"; import BillHelper from "@hipanel-module-finance/Helper/BillHelper"; import Bill from "@hipanel-module-finance/model/Bill"; import Index from "@hipanel-core/page/Index"; -import Alert from "@hipanel-core/ui/Alert"; +import { Alert } from "@hipanel-core/shared/ui/components"; const bill: Bill = { client: "hipanel_test_user", @@ -48,4 +48,3 @@ test("Create and copy bill with charges @hipanel-module-finance @seller", async await billHelper.ensureBillDidntChange(bill, billId); }); - diff --git a/tests/playwright/e2e/seller/bill-creation.spec.ts b/tests/playwright/e2e/seller/bill-creation.spec.ts index 5fbb790a..28fc0056 100644 --- a/tests/playwright/e2e/seller/bill-creation.spec.ts +++ b/tests/playwright/e2e/seller/bill-creation.spec.ts @@ -1,6 +1,6 @@ import { test, expect } from "@hipanel-core/fixtures"; import BillForm from "@hipanel-module-finance/page/bill/BillForm"; -import Alert from "@hipanel-core/ui/Alert"; +import { Alert } from "@hipanel-core/shared/ui/components"; let billId; @@ -92,4 +92,3 @@ test.describe("Bill creation", () => { await expect(page.locator(`table >> text=${chargeDescr}`)).toBeVisible(); }); }); - diff --git a/tests/playwright/e2e/seller/bill-with-charges.spec.ts b/tests/playwright/e2e/seller/bill-with-charges.spec.ts index 7870b5b7..355481e8 100644 --- a/tests/playwright/e2e/seller/bill-with-charges.spec.ts +++ b/tests/playwright/e2e/seller/bill-with-charges.spec.ts @@ -1,6 +1,6 @@ import { test, expect } from "@hipanel-core/fixtures"; import BillForm from "@hipanel-module-finance/page/bill/BillForm"; -import Alert from "@hipanel-core/ui/Alert"; +import { Alert } from "@hipanel-core/shared/ui/components"; import BillView from "@hipanel-module-finance/page/bill/BillView"; test("Test we add the charges to created bill @hipanel-module-finance @seller", async ({ page }) => { diff --git a/tests/playwright/e2e/seller/charge/export.spec.ts b/tests/playwright/e2e/seller/charge/export.spec.ts index fcff1ad2..facfe9df 100644 --- a/tests/playwright/e2e/seller/charge/export.spec.ts +++ b/tests/playwright/e2e/seller/charge/export.spec.ts @@ -5,5 +5,7 @@ test("charge export works correctly @hipanel-module-finance @seller", async ({ p await page.goto("/finance/charge/index"); const indexPage = new Index(page); + await indexPage.columnFilters.applyFilter("client_id", "hipanel_test_user"); + await indexPage.testExport(); }); diff --git a/tests/playwright/e2e/seller/generate-invoice.spec.ts b/tests/playwright/e2e/seller/generate-invoice.spec.ts index b515f854..7bca9020 100644 --- a/tests/playwright/e2e/seller/generate-invoice.spec.ts +++ b/tests/playwright/e2e/seller/generate-invoice.spec.ts @@ -1,11 +1,13 @@ -import { test, expect } from "@hipanel-core/fixtures"; +import { expect, test } from "@hipanel-core/fixtures"; +import { Page } from "@playwright/test"; import BillForm from "@hipanel-module-finance/page/bill/BillForm"; import BillView from "@hipanel-module-finance/page/bill/BillView"; -import Alert from "@hipanel-core/ui/Alert"; +import { Alert } from "@hipanel-core/shared/ui/components"; import Index from "@hipanel-core/page/Index"; import Select2 from "@hipanel-core/input/Select2"; +import Bill from "@hipanel-module-finance/model/Bill"; -const bill = { +const bill: Bill = { client: "hipanel_test_user", type: "Positive balance correction", requisite: "Test Reseller", @@ -14,7 +16,7 @@ const bill = { quantity: 1, }; -async function createBill(page) { +async function createBill(page: Page) { await page.goto("/finance/bill/create"); const form = new BillForm(page); await form.fill([bill]); @@ -24,13 +26,13 @@ async function createBill(page) { return await form.getSavedBillId(); } -async function deleteBill(page, billId) { +async function deleteBill(page: Page, billId) { await page.goto("/finance/bill/view?id=" + billId); - const viewPage = await new BillView(page); + const viewPage = new BillView(page); await viewPage.detailMenuItem("Delete", true).click(); // Handle the confirmation alert - await page.once("dialog", async (dialog) => { + page.once("dialog", async (dialog) => { await dialog.accept(); }); @@ -38,15 +40,15 @@ async function deleteBill(page, billId) { } test("Test 'Generate invoice' button is work and the form opens @hipanel-module-finance @seller", { - tag: '@missing-requisites', + tag: "@missing-requisites", }, async ({ page }) => { const billId = await createBill(page); - const action = '/finance/bill/index'; + const action = "/finance/bill/index"; await page.goto(action); const index = new Index(page); await Select2.fieldByName(page, `BillSearch[requisite_id]`).setValue(bill.requisite); - await index.advancedSearch.submitButton(); + await index.advancedSearch.search(); const rowNumber = await index.getRowNumberInColumnByValue("Description", bill.requisite); await index.chooseNumberRowOnTable(rowNumber); diff --git a/tests/playwright/e2e/seller/internal-transfer.spec.ts b/tests/playwright/e2e/seller/internal-transfer.spec.ts index 24fd5590..7e612f39 100644 --- a/tests/playwright/e2e/seller/internal-transfer.spec.ts +++ b/tests/playwright/e2e/seller/internal-transfer.spec.ts @@ -4,7 +4,7 @@ import BillHelper from "@hipanel-module-finance/Helper/BillHelper"; import Bill from "@hipanel-module-finance/model/Bill"; import TransferForm from "@hipanel-module-finance/page/bill/TransferForm"; import Transfer from "@hipanel-module-finance/model/Transfer"; -import Alert from "@hipanel-core/ui/Alert"; +import { Alert } from "@hipanel-core/shared/ui/components"; const transfer: Transfer = { sum: 100, @@ -52,4 +52,3 @@ test("Ensure transfer is working correctly @hipanel-module-finance @seller", asy await transferForm.submit(); await Alert.on(sellerPage).hasText('Transfer was completed'); }); - diff --git a/tests/playwright/e2e/seller/toggle-sign.spec.ts b/tests/playwright/e2e/seller/toggle-sign.spec.ts index bb5fa710..f7d37b77 100644 --- a/tests/playwright/e2e/seller/toggle-sign.spec.ts +++ b/tests/playwright/e2e/seller/toggle-sign.spec.ts @@ -1,7 +1,7 @@ import { test } from "@hipanel-core/fixtures"; import { expect } from "@playwright/test"; import BillForm from "@hipanel-module-finance/page/bill/BillForm"; -import Alert from "@hipanel-core/ui/Alert"; +import { Alert } from "@hipanel-core/shared/ui/components"; const bill = { client: "hipanel_test_user", diff --git a/tests/playwright/model/Bill.ts b/tests/playwright/model/Bill.ts index 7f2dff07..da761552 100644 --- a/tests/playwright/model/Bill.ts +++ b/tests/playwright/model/Bill.ts @@ -1,15 +1,15 @@ -import Charge from "@hipanel-module-finance/model/Charge"; +import Charge from "./Charge"; -export default class Bill { - public client: string; - public type: string; - public currency: string; - public sum: number; - public quantity: number; - public requisite?: string; - public time?: string | null; - public description?: string | null; - public class?: string | null; - public object?: string | null; - public charges?: Array | null; +export default interface Bill { + client: string; + type: string; + currency: string; + sum: number; + quantity: number; + requisite?: string; + time?: string | null; + description?: string | null; + class?: string | null; + object?: string | null; + charges?: Array | null; } diff --git a/tests/playwright/model/Charge.ts b/tests/playwright/model/Charge.ts index 22c1e3d5..819b892d 100644 --- a/tests/playwright/model/Charge.ts +++ b/tests/playwright/model/Charge.ts @@ -1,9 +1,9 @@ -export default class Charge { - public class: string; - public object: string; - public type: string; - public quantity: number; - public sum: number; - public description?: string | null; - public time?: string | null; +export default interface Charge { + class: string; + object: string; + type: string; + quantity: number; + sum: number; + description?: string | null; + time?: string | null; } diff --git a/tests/playwright/model/Sale.ts b/tests/playwright/model/Sale.ts index b84e0e0e..6dde3728 100644 --- a/tests/playwright/model/Sale.ts +++ b/tests/playwright/model/Sale.ts @@ -1,7 +1,7 @@ -export default class Sale { - public client: string; - public tariff: string; - public column: string; - public server: string; - public type: string; +export default interface Sale { + client: string; + tariff: string; + column: string; + server: string; + type: string; } diff --git a/tests/playwright/model/Transfer.ts b/tests/playwright/model/Transfer.ts index 1f68953c..e18a47e9 100644 --- a/tests/playwright/model/Transfer.ts +++ b/tests/playwright/model/Transfer.ts @@ -1,8 +1,6 @@ -import Bill from "@hipanel-module-finance/model/Bill"; - -export default class Transfer { - sum: number; - client: string; - receiverId: string; - currency: string; +export default interface Transfer { + sum: number; + client: string; + receiverId: string; + currency: string; } diff --git a/tests/playwright/page/bill/BillForm.ts b/tests/playwright/page/bill/BillForm.ts index 51582b3c..511fae58 100644 --- a/tests/playwright/page/bill/BillForm.ts +++ b/tests/playwright/page/bill/BillForm.ts @@ -4,7 +4,7 @@ import TreeSelect from "@hipanel-core/input/TreeSelect"; import SumWithCurrency from "@hipanel-core/input/SumWithCurrency"; import Bill from "@hipanel-module-finance/model/Bill"; import Charge from "@hipanel-module-finance/model/Charge"; -import Alert from "@hipanel-core/ui/Alert"; +import { Alert } from "@hipanel-core/shared/ui/components"; export default class BillForm { private page: Page; @@ -30,7 +30,7 @@ export default class BillForm { await SumWithCurrency.field(this.page, "billform", k).setSumAndCurrency(bill.sum, bill.currency); await this.page.locator(`#billform-${k}-quantity`).fill(bill.quantity.toString()); if (bill.requisite) { - await Select2.field(this.page, `#billform-${k}-requisite_id`).setValue(bill.requisite) + await Select2.field(this.page, `#billform-${k}-requisite_id`).setValue(bill.requisite); } if (bill.charges) { diff --git a/tests/playwright/page/bill/BillView.ts b/tests/playwright/page/bill/BillView.ts index 092d9afc..a961bcab 100644 --- a/tests/playwright/page/bill/BillView.ts +++ b/tests/playwright/page/bill/BillView.ts @@ -7,18 +7,18 @@ export default class BillView { private page: Page; private detailMenuFunctionsLocator: Locator; - public constructor(page: Page) { + constructor(page: Page) { this.page = page; this.detailMenuFunctionsLocator = page.locator(".widget-user-2 .nav"); } - public async checkCharge(charge: Charge) { + async checkCharge(charge: Charge) { await expect(this.page.locator(`tr td a:text("${charge.object}")`).first()).toBeVisible(); await expect(this.page.locator(`tr td b:text("${charge.type}")`).first()).toBeVisible(); await expect(this.page.locator(`tr td a >> text=/.*${charge.sum}.*/i`).first()).toBeVisible(); } - public detailMenuItem(item: string, withAcceptDialog: boolean = false): Locator { + detailMenuItem(item: string, withAcceptDialog: boolean = false): Locator { if (withAcceptDialog) { this.page.on("dialog", dialog => dialog.accept()); } @@ -26,7 +26,7 @@ export default class BillView { return this.detailMenuFunctionsLocator.locator(`:scope a:text("${item}")`); } - public async checkBillData(bill: Bill) { + async checkBillData(bill: Bill) { // TODO: Implement } } diff --git a/tests/playwright/page/bill/SaleUpdate.ts b/tests/playwright/page/bill/SaleUpdate.ts index 0066bba6..3fe403b6 100644 --- a/tests/playwright/page/bill/SaleUpdate.ts +++ b/tests/playwright/page/bill/SaleUpdate.ts @@ -1,11 +1,11 @@ -import { expect, Page } from "@playwright/test"; +import { Page } from "@playwright/test"; import Sale from "@hipanel-module-finance/model/Sale"; import Select2 from "@hipanel-core/input/Select2"; export default class SaleUpdate { private page: Page; - public constructor(page: Page) { + constructor(page: Page) { this.page = page; } @@ -13,7 +13,7 @@ export default class SaleUpdate { for (let i = 0; i < sales.length; i++) { await Select2.field(this.page, `select[id*='sale-${i}-tariff_id']`).setValue(sales[i].tariff); } - await this.page.locator('button:has-text("Save")').click(); + await this.page.locator("button:has-text(\"Save\")").click(); } } diff --git a/tests/playwright/page/bill/ServerView.ts b/tests/playwright/page/bill/ServerView.ts index 1edd2eab..aef05d98 100644 --- a/tests/playwright/page/bill/ServerView.ts +++ b/tests/playwright/page/bill/ServerView.ts @@ -1,4 +1,4 @@ -import { expect, Page } from "@playwright/test"; +import { Page } from "@playwright/test"; import Sale from "@hipanel-module-finance/model/Sale"; import Select2 from "@hipanel-core/input/Select2"; @@ -6,12 +6,12 @@ import Select2 from "@hipanel-core/input/Select2"; export default class ServerView { private page: Page; - public constructor(page: Page) { + constructor(page: Page) { this.page = page; } async changeTariff(sale: Sale) { - await this.page.locator('a:has-text("Change tariff")').click(); + await this.page.locator("a:has-text(\"Change tariff\")").click(); await Select2.field(this.page, "select[id*='server-client_id']").setValue(sale.client); await Select2.field(this.page, "select[id*='server-tariff_id']").setValue(sale.tariff); await this.page.locator("button:has-text('Sell')").first().click(); diff --git a/tests/playwright/page/bill/TransferForm.ts b/tests/playwright/page/bill/TransferForm.ts index 6b043057..e3090b1f 100644 --- a/tests/playwright/page/bill/TransferForm.ts +++ b/tests/playwright/page/bill/TransferForm.ts @@ -1,4 +1,4 @@ -import {expect, Locator, Page} from "@playwright/test"; +import { expect, Locator, Page } from "@playwright/test"; import Select2 from "@hipanel-core/input/Select2"; import Transfer from "@hipanel-module-finance/model/Transfer"; import SumWithCurrency from "@hipanel-core/input/SumWithCurrency"; @@ -8,10 +8,10 @@ export default class TransferForm { private submitBtn: Locator; private notBeBlankFields: Array = [ - 'Sum', - 'Client', - 'Receiver ID', - 'Currency', + "Sum", + "Client", + "Receiver ID", + "Currency", ]; public constructor(page: Page) { @@ -27,7 +27,7 @@ export default class TransferForm { async ensureICantCreateTransferWithoutRequiredData() { await this.gotoCreateTransfer(); await this.submit(); - this.notBeBlankFields.forEach(field => this.hasValidationError(field + ' cannot be blank.')); + this.notBeBlankFields.forEach(field => this.hasValidationError(field + " cannot be blank.")); } async hasValidationError(msg: string) { @@ -36,8 +36,8 @@ export default class TransferForm { async fillTransfer(transferData: Transfer) { await SumWithCurrency.field(this.page, "bill", 0).setSumAndCurrency(transferData.sum, transferData.currency); - await Select2.field(this.page, '#bill-0-client_id').setValue(transferData.client); - await Select2.field(this.page, '#bill-0-receiver_id').setValue(transferData.receiverId); + await Select2.field(this.page, "#bill-0-client_id").setValue(transferData.client); + await Select2.field(this.page, "#bill-0-receiver_id").setValue(transferData.receiverId); } async submit() {