Skip to content

Commit 2276daa

Browse files
committed
HP-2804: refactor e2e tests and models to improve code consistency and strictness
1 parent e2e6918 commit 2276daa

18 files changed

+92
-93
lines changed

tests/playwright/e2e/client/account-recharging.spec.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
import { test } from "@hipanel-core/fixtures";
2-
import { expect } from "@playwright/test";
1+
import { expect, test } from "@hipanel-core/fixtures";
32

43
test("Test the Account recharging page works @hipanel-module-finance @client @seller", async ({ clientPage, sellerPage }) => {
54
const pageUrl = "/merchant/pay/deposit";
65
for (let page of [clientPage, sellerPage]) {
76
await page.goto(pageUrl);
87
await expect(page).toHaveTitle("Account recharging");
98
await expect(page.locator("//input[@id='depositform-amount']")).toBeVisible();
10-
await expect(page.getByRole('button', { name: 'Proceed' })).toBeVisible();
9+
await expect(page.getByRole("button", { name: "Proceed" })).toBeVisible();
1110
await expect(page.locator("h4:text('Important information')")).toBeVisible();
1211
await expect(page.locator("p:text('Remember to return to the site after successful payment!')")).toBeVisible();
1312
}
Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,36 @@
11
import { test } from "@hipanel-core/fixtures";
22
import { expect } from "@playwright/test";
33
import Select2 from "@hipanel-core/input/Select2";
4-
import Alert from "@hipanel-core/ui/Alert";
4+
import { Alert } from "@hipanel-core/shared/ui/components";
5+
import AdvancedSearch from "@hipanel-core/helper/AdvancedSearch";
56

6-
test("Test the currency exchange operation are works and creates a bill @hipanel-module-finance @manager", async ({ managerPage }) => {
7-
await managerPage.goto("/finance/bill/index");
8-
await expect(managerPage).toHaveTitle("Bills");
7+
test("the currency exchange operation works and creates a bill @hipanel-module-finance @manager", async ({ page }) => {
8+
const advancedSearch = new AdvancedSearch(page);
99

10-
await managerPage.locator("a:has-text(\"Currency exchange\")").click();
11-
await expect(managerPage).toHaveTitle("Create currency exchange");
10+
await page.goto("/finance/bill/index");
11+
await expect(page).toHaveTitle("Bills");
12+
13+
await page.locator("a:has-text(\"Currency exchange\")").click();
14+
await expect(page).toHaveTitle("Create currency exchange");
1215

1316
await Promise.all([
14-
managerPage.waitForResponse(response => response.status() === 200 && response.url().includes("get-exchange-rates")),
15-
Select2.field(managerPage, "#currencyexchangeform-client_id").setValue("hipanel_test_user"),
17+
page.waitForResponse(response => response.status() === 200 && response.url().includes("get-exchange-rates")),
18+
Select2.field(page, "#currencyexchangeform-client_id").setValue("hipanel_test_user"),
1619
]);
1720

18-
await Select2.field(managerPage, "#currencyexchangeform-from").setValue("USD");
19-
await Select2.field(managerPage, "#currencyexchangeform-to").setValue("UAH");
20-
await managerPage.locator("input[name=\"CurrencyExchangeForm\\[sum\\]\"]").fill("200");
21-
22-
await managerPage.locator("button:has-text(\"Create\")").click();
21+
await Select2.field(page, "#currencyexchangeform-from").setValue("USD");
22+
await Select2.field(page, "#currencyexchangeform-to").setValue("UAH");
23+
await page.locator("input[name=\"CurrencyExchangeForm\\[sum\\]\"]").fill("200");
2324

24-
await Alert.on(managerPage).hasText("Currency was exchanged successfully");
25+
await page.locator("button:has-text(\"Create\")").click();
2526

26-
await Select2.field(managerPage, "#billsearch-client_id").setValue("hipanel_test_user");
27+
await Alert.on(page).hasText("Currency was exchanged successfully");
2728

28-
await managerPage.goto(managerPage.url() + "&sort=-time");
29+
await advancedSearch.setFilter("client_id", "hipanel_test_user");
30+
await advancedSearch.setFilter("descr", "Exchanging 200.00 USD");
31+
await advancedSearch.submitButton();
2932

30-
await managerPage.locator("div[role=grid] a:has-text(\"-$200.00\")").first().click();
33+
await page.locator("div[role=grid] a:has-text(\"-$200.00\")").first().click();
3134

32-
await expect(managerPage).toHaveTitle(/^hipanel_test_user: -200.00 usd Exchanging 200.00 USD.*/);
35+
await expect(page).toHaveTitle(/^hipanel_test_user: -200.00 usd Exchanging 200.00 USD.*/);
3336
});

tests/playwright/e2e/sales.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import ServerView from "@hipanel-module-finance/page/bill/ServerView";
55
import SaleHelper from "@hipanel-module-finance/Helper/SaleHelper";
66
import Index from "@hipanel-core/page/Index";
77
import SaleUpdate from "@hipanel-module-finance/page/bill/SaleUpdate";
8-
import Alert from "@hipanel-core/ui/Alert";
8+
import { Alert } from "@hipanel-core/shared/ui/components";
99
import DateHelper from "@hipanel-core/helper/DateHelper";
1010

1111
const sales: Array<Sale> = [

tests/playwright/e2e/seller/bill-copy.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import BillForm from "@hipanel-module-finance/page/bill/BillForm";
44
import BillHelper from "@hipanel-module-finance/Helper/BillHelper";
55
import Bill from "@hipanel-module-finance/model/Bill";
66
import Index from "@hipanel-core/page/Index";
7-
import Alert from "@hipanel-core/ui/Alert";
7+
import { Alert } from "@hipanel-core/shared/ui/components";
88

99
const bill: Bill = {
1010
client: "hipanel_test_user",
@@ -48,4 +48,3 @@ test("Create and copy bill with charges @hipanel-module-finance @seller", async
4848
await billHelper.ensureBillDidntChange(bill, billId);
4949

5050
});
51-

tests/playwright/e2e/seller/bill-creation.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { test, expect } from "@hipanel-core/fixtures";
22
import BillForm from "@hipanel-module-finance/page/bill/BillForm";
3-
import Alert from "@hipanel-core/ui/Alert";
3+
import { Alert } from "@hipanel-core/shared/ui/components";
44

55
let billId;
66

@@ -92,4 +92,3 @@ test.describe("Bill creation", () => {
9292
await expect(page.locator(`table >> text=${chargeDescr}`)).toBeVisible();
9393
});
9494
});
95-

tests/playwright/e2e/seller/bill-with-charges.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { test, expect } from "@hipanel-core/fixtures";
22
import BillForm from "@hipanel-module-finance/page/bill/BillForm";
3-
import Alert from "@hipanel-core/ui/Alert";
3+
import { Alert } from "@hipanel-core/shared/ui/components";
44
import BillView from "@hipanel-module-finance/page/bill/BillView";
55

66
test("Test we add the charges to created bill @hipanel-module-finance @seller", async ({ page }) => {

tests/playwright/e2e/seller/generate-invoice.spec.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import { test, expect } from "@hipanel-core/fixtures";
1+
import { expect, test } from "@hipanel-core/fixtures";
2+
import { Page } from "@playwright/test";
23
import BillForm from "@hipanel-module-finance/page/bill/BillForm";
34
import BillView from "@hipanel-module-finance/page/bill/BillView";
4-
import Alert from "@hipanel-core/ui/Alert";
5+
import { Alert } from "@hipanel-core/shared/ui/components";
56
import Index from "@hipanel-core/page/Index";
67
import Select2 from "@hipanel-core/input/Select2";
8+
import Bill from "@hipanel-module-finance/model/Bill";
79

8-
const bill = {
10+
const bill: Bill = {
911
client: "hipanel_test_user",
1012
type: "Positive balance correction",
1113
requisite: "Test Reseller",
@@ -14,7 +16,7 @@ const bill = {
1416
quantity: 1,
1517
};
1618

17-
async function createBill(page) {
19+
async function createBill(page: Page) {
1820
await page.goto("/finance/bill/create");
1921
const form = new BillForm(page);
2022
await form.fill([bill]);
@@ -24,24 +26,24 @@ async function createBill(page) {
2426
return await form.getSavedBillId();
2527
}
2628

27-
async function deleteBill(page, billId) {
29+
async function deleteBill(page: Page, billId) {
2830
await page.goto("/finance/bill/view?id=" + billId);
29-
const viewPage = await new BillView(page);
31+
const viewPage = new BillView(page);
3032
await viewPage.detailMenuItem("Delete", true).click();
3133

3234
// Handle the confirmation alert
33-
await page.once("dialog", async (dialog) => {
35+
page.once("dialog", async (dialog) => {
3436
await dialog.accept();
3537
});
3638

3739
await Alert.on(page).hasText("Payment was deleted successfully");
3840
}
3941

4042
test("Test 'Generate invoice' button is work and the form opens @hipanel-module-finance @seller", {
41-
tag: '@missing-requisites',
43+
tag: "@missing-requisites",
4244
}, async ({ page }) => {
4345
const billId = await createBill(page);
44-
const action = '/finance/bill/index';
46+
const action = "/finance/bill/index";
4547

4648
await page.goto(action);
4749
const index = new Index(page);

tests/playwright/e2e/seller/internal-transfer.spec.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import BillHelper from "@hipanel-module-finance/Helper/BillHelper";
44
import Bill from "@hipanel-module-finance/model/Bill";
55
import TransferForm from "@hipanel-module-finance/page/bill/TransferForm";
66
import Transfer from "@hipanel-module-finance/model/Transfer";
7-
import Alert from "@hipanel-core/ui/Alert";
7+
import { Alert } from "@hipanel-core/shared/ui/components";
88

99
const transfer: Transfer = {
1010
sum: 100,
@@ -52,4 +52,3 @@ test("Ensure transfer is working correctly @hipanel-module-finance @seller", asy
5252
await transferForm.submit();
5353
await Alert.on(sellerPage).hasText('Transfer was completed');
5454
});
55-

tests/playwright/e2e/seller/toggle-sign.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { test } from "@hipanel-core/fixtures";
22
import { expect } from "@playwright/test";
33
import BillForm from "@hipanel-module-finance/page/bill/BillForm";
4-
import Alert from "@hipanel-core/ui/Alert";
4+
import { Alert } from "@hipanel-core/shared/ui/components";
55

66
const bill = {
77
client: "hipanel_test_user",

tests/playwright/model/Bill.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import Charge from "@hipanel-module-finance/model/Charge";
1+
import Charge from "./Charge";
22

3-
export default class Bill {
4-
public client: string;
5-
public type: string;
6-
public currency: string;
7-
public sum: number;
8-
public quantity: number;
9-
public requisite?: string;
10-
public time?: string | null;
11-
public description?: string | null;
12-
public class?: string | null;
13-
public object?: string | null;
14-
public charges?: Array<Charge> | null;
3+
export default interface Bill {
4+
client: string;
5+
type: string;
6+
currency: string;
7+
sum: number;
8+
quantity: number;
9+
requisite?: string;
10+
time?: string | null;
11+
description?: string | null;
12+
class?: string | null;
13+
object?: string | null;
14+
charges?: Array<Charge> | null;
1515
}

0 commit comments

Comments
 (0)