|
1 | 1 | import { test } from "@hipanel-core/fixtures"; |
2 | 2 | import { expect } from "@playwright/test"; |
3 | 3 | 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"; |
5 | 6 |
|
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); |
9 | 9 |
|
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"); |
12 | 15 |
|
13 | 16 | 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"), |
16 | 19 | ]); |
17 | 20 |
|
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"); |
23 | 24 |
|
24 | | - await Alert.on(managerPage).hasText("Currency was exchanged successfully"); |
| 25 | + await page.locator("button:has-text(\"Create\")").click(); |
25 | 26 |
|
26 | | - await Select2.field(managerPage, "#billsearch-client_id").setValue("hipanel_test_user"); |
| 27 | + await Alert.on(page).hasText("Currency was exchanged successfully"); |
27 | 28 |
|
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(); |
29 | 32 |
|
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(); |
31 | 34 |
|
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.*/); |
33 | 36 | }); |
0 commit comments