Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c1083e502b |
+23
-36
@@ -14,18 +14,15 @@ market_order = "order-type-Market"
|
||||
tif = "order-tif"
|
||||
expire = "expire"
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def vega(request):
|
||||
with init_vega(request) as vega:
|
||||
yield vega
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def continuous_market(vega):
|
||||
return setup_continuous_market(vega)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("auth", "risk_accepted")
|
||||
def test_limit_buy_order_GTT(continuous_market, vega: VegaServiceNull, page: Page):
|
||||
page.goto(f"/#/markets/{continuous_market}")
|
||||
@@ -45,26 +42,31 @@ def test_limit_buy_order_GTT(continuous_market, vega: VegaServiceNull, page: Pag
|
||||
)
|
||||
page.get_by_test_id(place_order).click()
|
||||
wait_for_toast_confirmation(page)
|
||||
vega.forward("10s")
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
page.get_by_test_id("All").click()
|
||||
# 7002-SORD-017
|
||||
expect(page.get_by_role("row").nth(5)).to_contain_text("10+10LimitFilled120.00GTT:")
|
||||
|
||||
expect(page.get_by_role("row").nth(5)).to_contain_text(
|
||||
"10+10LimitFilled120.00GTT:"
|
||||
)
|
||||
|
||||
@pytest.mark.usefixtures("auth", "risk_accepted")
|
||||
def test_limit_buy_order(continuous_market, vega: VegaServiceNull, page: Page):
|
||||
page.goto(f"/#/markets/{continuous_market}")
|
||||
|
||||
page.get_by_test_id(order_size).fill("10")
|
||||
page.get_by_test_id(order_price).fill("120")
|
||||
page.get_by_test_id(place_order).click()
|
||||
wait_for_toast_confirmation(page)
|
||||
vega.wait_fn(2)
|
||||
vega.forward("10s")
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
page.get_by_test_id("All").click()
|
||||
# 7002-SORD-017
|
||||
expect(page.get_by_role("row").nth(6)).to_contain_text("10+10LimitFilled120.00GTC")
|
||||
|
||||
expect(page.get_by_role("row").nth(6)).to_contain_text(
|
||||
"10+10LimitFilled120.00GTC"
|
||||
)
|
||||
|
||||
@pytest.mark.usefixtures("auth", "risk_accepted")
|
||||
def test_limit_sell_order(continuous_market, vega: VegaServiceNull, page: Page):
|
||||
@@ -82,11 +84,13 @@ def test_limit_sell_order(continuous_market, vega: VegaServiceNull, page: Page):
|
||||
)
|
||||
page.get_by_test_id(place_order).click()
|
||||
wait_for_toast_confirmation(page)
|
||||
vega.forward("10s")
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
page.get_by_test_id("All").click()
|
||||
expect(page.get_by_role("row").nth(7)).to_contain_text("10-10LimitFilled100.00GFN")
|
||||
|
||||
expect(page.get_by_role("row").nth(7)).to_contain_text(
|
||||
"10-10LimitFilled100.00GFN"
|
||||
)
|
||||
|
||||
@pytest.mark.usefixtures("auth", "risk_accepted")
|
||||
def test_market_sell_order(continuous_market, vega: VegaServiceNull, page: Page):
|
||||
@@ -103,12 +107,14 @@ def test_market_sell_order(continuous_market, vega: VegaServiceNull, page: Page)
|
||||
)
|
||||
page.get_by_test_id(place_order).click()
|
||||
wait_for_toast_confirmation(page)
|
||||
vega.forward("10s")
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
|
||||
|
||||
page.get_by_test_id("All").click()
|
||||
expect(page.get_by_role("row").nth(8)).to_contain_text("10-10MarketFilled-IOC")
|
||||
|
||||
expect(page.get_by_role("row").nth(8)).to_contain_text(
|
||||
"10-10MarketFilled-IOC"
|
||||
)
|
||||
|
||||
@pytest.mark.usefixtures("auth", "risk_accepted")
|
||||
def test_market_buy_order(continuous_market, vega: VegaServiceNull, page: Page):
|
||||
@@ -118,32 +124,13 @@ def test_market_buy_order(continuous_market, vega: VegaServiceNull, page: Page):
|
||||
page.get_by_test_id(tif).select_option("Fill or Kill (FOK)")
|
||||
page.get_by_test_id(place_order).click()
|
||||
wait_for_toast_confirmation(page)
|
||||
vega.forward("10s")
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
page.get_by_test_id("All").click()
|
||||
# 7002-SORD-010
|
||||
# 0003-WTXN-012
|
||||
# 0003-WTXN-003
|
||||
expect(page.get_by_role("row").nth(9)).to_contain_text("10+10MarketFilled-FOK")
|
||||
|
||||
@pytest.mark.usefixtures("risk_accepted")
|
||||
def test_sidebar_should_be_open_after_reload(continuous_market, page: Page):
|
||||
page.goto(f"/#/markets/{continuous_market}")
|
||||
expect(page.get_by_test_id("deal-ticket-form")).to_be_visible()
|
||||
page.get_by_test_id("Order").click()
|
||||
expect(page.get_by_test_id("deal-ticket-form")).not_to_be_visible()
|
||||
page.reload()
|
||||
expect(page.get_by_test_id("deal-ticket-form")).to_be_visible()
|
||||
|
||||
@pytest.mark.skip("We currently can't approve wallet connection through Sim")
|
||||
@pytest.mark.usefixtures("risk_accepted")
|
||||
def test_connect_vega_wallet(continuous_market, page: Page):
|
||||
page.goto(f"/#/markets/{continuous_market}")
|
||||
page.get_by_test_id("order-price").fill("101")
|
||||
page.get_by_test_id("order-connect-wallet").click()
|
||||
expect(page.locator('[role="dialog"]')).to_be_visible()
|
||||
page.get_by_test_id("connector-jsonRpc").click()
|
||||
expect(page.get_by_test_id("wallet-dialog-title")).to_be_visible()
|
||||
# TODO: accept wallet connection and assert wallet is connected.
|
||||
expect(page.get_by_test_id("order-type-Limit")).to_be_checked()
|
||||
expect(page.get_by_test_id("order-price")).to_have_value("101")
|
||||
expect(page.get_by_role("row").nth(9)).to_contain_text(
|
||||
"10+10MarketFilled-FOK"
|
||||
)
|
||||
@@ -0,0 +1,35 @@
|
||||
import pytest
|
||||
from playwright.sync_api import Page, expect
|
||||
from conftest import init_vega
|
||||
from fixtures.market import setup_continuous_market
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def vega(request):
|
||||
with init_vega(request) as vega:
|
||||
yield vega
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def continuous_market(vega):
|
||||
return setup_continuous_market(vega)
|
||||
|
||||
@pytest.mark.skip("We currently can't approve wallet connection through Sim")
|
||||
@pytest.mark.usefixtures("risk_accepted")
|
||||
def test_connect_vega_wallet(continuous_market, page: Page):
|
||||
page.goto(f"/#/markets/{continuous_market}")
|
||||
page.get_by_test_id("order-price").fill("101")
|
||||
page.get_by_test_id("order-connect-wallet").click()
|
||||
expect(page.locator('[role="dialog"]')).to_be_visible()
|
||||
page.get_by_test_id("connector-jsonRpc").click()
|
||||
expect(page.get_by_test_id("wallet-dialog-title")).to_be_visible()
|
||||
# TODO: accept wallet connection and assert wallet is connected.
|
||||
expect(page.get_by_test_id("order-type-Limit")).to_be_checked()
|
||||
expect(page.get_by_test_id("order-price")).to_have_value("101")
|
||||
|
||||
@pytest.mark.usefixtures("risk_accepted")
|
||||
def test_sidebar_should_be_open_after_reload(continuous_market, page: Page):
|
||||
page.goto(f"/#/markets/{continuous_market}")
|
||||
expect(page.get_by_test_id("deal-ticket-form")).to_be_visible()
|
||||
page.get_by_test_id("Order").click()
|
||||
expect(page.get_by_test_id("deal-ticket-form")).not_to_be_visible()
|
||||
page.reload()
|
||||
expect(page.get_by_test_id("deal-ticket-form")).to_be_visible()
|
||||
@@ -41,6 +41,7 @@ close_toast = "toast-close"
|
||||
def create_position(vega: VegaServiceNull, market_id):
|
||||
submit_order(vega, "Key 1", market_id, "SIDE_SELL", 100, 110)
|
||||
submit_order(vega, "Key 1", market_id, "SIDE_BUY", 100, 110)
|
||||
vega.forward("10s")
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup
|
||||
|
||||
@@ -77,6 +78,7 @@ def test_submit_stop_order_rejected(continuous_market, vega: VegaServiceNull, pa
|
||||
page.get_by_test_id(trigger_price).fill("103")
|
||||
page.get_by_test_id(order_size).fill("3")
|
||||
page.get_by_test_id(submit_stop_order).click()
|
||||
vega.forward("10s")
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
page.get_by_test_id(close_toast).click()
|
||||
@@ -267,6 +269,82 @@ class TestStopOcoValidation:
|
||||
def continuous_market(self, vega):
|
||||
return setup_continuous_market(vega)
|
||||
|
||||
@pytest.mark.usefixtures("auth", "risk_accepted")
|
||||
def test_stop_market_order_form_validation(self, continuous_market, page: Page):
|
||||
# 7002-SORD-052
|
||||
# 7002-SORD-055
|
||||
# 7002-SORD-056
|
||||
# 7002-SORD-057
|
||||
# 7002-SORD-058
|
||||
# 7002-SORD-064
|
||||
# 7002-SORD-065
|
||||
page.goto(f"/#/markets/{continuous_market}")
|
||||
page.get_by_test_id(stop_order_btn).click()
|
||||
page.get_by_test_id(stop_market_order_btn).is_visible()
|
||||
page.get_by_test_id(stop_market_order_btn).click()
|
||||
expect(
|
||||
page.get_by_test_id("sidebar-content").get_by_text("Trigger").first
|
||||
).to_be_visible()
|
||||
expect(page.locator('[for="triggerDirection-risesAbove"]')).to_have_text(
|
||||
"Rises above"
|
||||
)
|
||||
expect(page.locator('[for="triggerDirection-fallsBelow"]')).to_have_text(
|
||||
"Falls below"
|
||||
)
|
||||
page.get_by_test_id(trigger_price).click()
|
||||
expect(page.get_by_test_id(trigger_price)).to_be_empty
|
||||
expect(page.locator('[for="triggerType-price"]')).to_have_text("Price")
|
||||
expect(page.locator('[for="triggerType-trailingPercentOffset"]')).to_have_text(
|
||||
"Trailing Percent Offset"
|
||||
)
|
||||
expect(page.locator('[for="order-size"]')).to_have_text("Size")
|
||||
page.get_by_test_id(order_size).click()
|
||||
expect(page.get_by_test_id(order_size)).to_be_empty
|
||||
expect(page.get_by_test_id(order_price)).not_to_be_visible()
|
||||
|
||||
@pytest.mark.usefixtures("auth", "risk_accepted")
|
||||
def test_stop_limit_order_form_validation(self, continuous_market, page: Page):
|
||||
# 7002-SORD-020
|
||||
# 7002-SORD-021
|
||||
# 7002-SORD-022
|
||||
# 7002-SORD-033
|
||||
# 7002-SORD-034
|
||||
# 7002-SORD-035
|
||||
# 7002-SORD-036
|
||||
# 7002-SORD-037
|
||||
# 7002-SORD-038
|
||||
# 7002-SORD-049
|
||||
# 7002-SORD-050
|
||||
# 7002-SORD-051
|
||||
|
||||
page.goto(f"/#/markets/{continuous_market}")
|
||||
page.get_by_test_id(stop_order_btn).click()
|
||||
page.get_by_test_id(stop_limit_order_btn).is_visible()
|
||||
page.get_by_test_id(stop_limit_order_btn).click()
|
||||
expect(
|
||||
page.get_by_test_id("sidebar-content").get_by_text("Trigger").first
|
||||
).to_be_visible()
|
||||
expect(page.locator('[for="triggerDirection-risesAbove"]')).to_have_text(
|
||||
"Rises above"
|
||||
)
|
||||
expect(page.locator('[for="triggerDirection-risesAbove"]')).to_be_checked
|
||||
expect(page.locator('[for="triggerDirection-fallsBelow"]')).to_have_text(
|
||||
"Falls below"
|
||||
)
|
||||
page.get_by_test_id(trigger_price).click()
|
||||
expect(page.get_by_test_id(trigger_price)).to_be_empty
|
||||
expect(page.locator('[for="triggerType-price"]')).to_have_text("Price")
|
||||
expect(page.locator('[for="triggerType-price"]')).to_be_checked
|
||||
expect(page.locator('[for="triggerType-trailingPercentOffset"]')).to_have_text(
|
||||
"Trailing Percent Offset"
|
||||
)
|
||||
expect(page.locator('[for="order-size"]').first).to_have_text("Size")
|
||||
expect(page.locator('[for="order-price"]').last).to_have_text("Price")
|
||||
page.get_by_test_id(order_size).click()
|
||||
expect(page.get_by_test_id(order_size)).to_be_empty
|
||||
page.get_by_test_id(order_price).click()
|
||||
expect(page.get_by_test_id(order_price)).to_be_empty()
|
||||
|
||||
@pytest.mark.skip("core issue")
|
||||
@pytest.mark.usefixtures("auth", "risk_accepted")
|
||||
def test_maximum_number_of_active_stop_orders(
|
||||
|
||||
@@ -681,4 +681,4 @@ def test_fills_taker_fee_tooltip_discount_program(
|
||||
row.locator(COL_FEE).hover()
|
||||
expect(page.get_by_test_id(FEE_BREAKDOWN_TOOLTIP)).to_have_text(
|
||||
f"If the market was activeFees to be paid by the taker; discounts are already applied.Infrastructure fee{infra_fee} tDAILiquidity fee0.00 tDAIMaker fee{maker_fee} tDAITotal fees{total_fee} tDAI"
|
||||
)
|
||||
)
|
||||
|
||||
@@ -35,6 +35,7 @@ class TestIcebergOrdersValidations:
|
||||
"Awaiting confirmationPlease wait for your transaction to be confirmedView in block explorer"
|
||||
)
|
||||
|
||||
vega.forward("10s")
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
expect(page.get_by_test_id("toast-content")).to_have_text(
|
||||
@@ -50,6 +51,7 @@ def test_iceberg_open_order(continuous_market, vega: VegaServiceNull, page: Page
|
||||
page.goto(f"/#/markets/{continuous_market}")
|
||||
|
||||
submit_order(vega, "Key 1", continuous_market, "SIDE_SELL", 102, 101, 2, 1)
|
||||
vega.forward("10s")
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
|
||||
@@ -82,6 +84,7 @@ def test_iceberg_open_order(continuous_market, vega: VegaServiceNull, page: Page
|
||||
|
||||
submit_order(vega, MM_WALLET2.name, continuous_market, "SIDE_BUY", 103, 101)
|
||||
|
||||
vega.forward("10s")
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
expect(
|
||||
|
||||
@@ -16,44 +16,34 @@ def vega(request):
|
||||
def continuous_market(vega):
|
||||
return setup_continuous_market(vega)
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("auth", "risk_accepted")
|
||||
def test_liquidity_provision_amendment(
|
||||
continuous_market, vega: VegaServiceNull, page: Page
|
||||
):
|
||||
def test_liquidity_provision_amendment(continuous_market, vega: VegaServiceNull, page: Page):
|
||||
# TODO Refactor asserting the grid
|
||||
page.goto(f"/#/liquidity/{continuous_market}")
|
||||
change_keys(page, vega, "market_maker")
|
||||
row = (
|
||||
page.get_by_test_id("tab-myLP")
|
||||
.locator(".ag-center-cols-container .ag-row")
|
||||
.first
|
||||
row = page.get_by_test_id(
|
||||
"tab-myLP").locator(".ag-center-cols-container .ag-row").first
|
||||
expect(row).to_contain_text(
|
||||
"Active"
|
||||
)
|
||||
expect(row).to_contain_text("Active")
|
||||
# 5002-LIQP-006
|
||||
expect(page.get_by_test_id("target-stake")).to_have_text("Target stake5.82757 tDAI")
|
||||
expect(page.get_by_test_id("target-stake")
|
||||
).to_have_text("Target stake5.82757 tDAI")
|
||||
# 5002-LIQP-007
|
||||
expect(page.get_by_test_id("supplied-stake")).to_have_text(
|
||||
"Supplied stake10,000.00 tDAI"
|
||||
)
|
||||
expect(page.get_by_test_id("supplied-stake")
|
||||
).to_have_text("Supplied stake10,000.00 tDAI")
|
||||
# 5002-LIQP-008
|
||||
expect(page.get_by_test_id("liquidity-supplied")).to_have_text(
|
||||
"Liquidity supplied 171,598.11%"
|
||||
)
|
||||
expect(page.get_by_test_id("liquidity-supplied")
|
||||
).to_have_text("Liquidity supplied 171,598.11%")
|
||||
expect(page.get_by_test_id("fees-paid")).to_have_text("Fees paid-")
|
||||
# 5002-LIQP-009
|
||||
expect(page.get_by_test_id("liquidity-market-id")).to_have_text(
|
||||
"Market ID" + truncate_middle(continuous_market)
|
||||
)
|
||||
expect(page.get_by_test_id("liquidity-learn-more")).to_have_text(
|
||||
"Learn moreProviding liquidity"
|
||||
)
|
||||
expect(page.get_by_test_id("liquidity-market-id")
|
||||
).to_have_text("Market ID" + truncate_middle(continuous_market))
|
||||
expect(page.get_by_test_id("liquidity-learn-more")
|
||||
).to_have_text("Learn moreProviding liquidity")
|
||||
# 002-LIQP-010
|
||||
expect(
|
||||
page.get_by_test_id("liquidity-learn-more").get_by_test_id("external-link")
|
||||
).to_have_attribute(
|
||||
"href", "https://docs.vega.xyz/testnet/concepts/liquidity/provision"
|
||||
)
|
||||
expect(page.get_by_test_id("liquidity-learn-more").get_by_test_id("external-link")
|
||||
).to_have_attribute("href", "https://docs.vega.xyz/testnet/concepts/liquidity/provision")
|
||||
|
||||
vega.submit_simple_liquidity(
|
||||
key_name="market_maker",
|
||||
@@ -66,50 +56,41 @@ def test_liquidity_provision_amendment(
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
page.reload()
|
||||
row = (
|
||||
page.get_by_test_id("tab-myLP")
|
||||
.locator(".ag-center-cols-container .ag-row")
|
||||
.first
|
||||
row = page.get_by_test_id(
|
||||
"tab-myLP").locator(".ag-center-cols-container .ag-row").first
|
||||
expect(row).to_contain_text(
|
||||
"Updating next epoch"
|
||||
)
|
||||
expect(row).to_contain_text("Updating next epoch")
|
||||
next_epoch(vega=vega)
|
||||
page.reload()
|
||||
expect(page.get_by_test_id("supplied-stake")).to_have_text(
|
||||
"Supplied stake1.00001 tDAI"
|
||||
expect(page.get_by_test_id("supplied-stake")
|
||||
).to_have_text("Supplied stake1.00001 tDAI")
|
||||
expect(page.get_by_test_id("liquidity-supplied")
|
||||
).to_have_text("Liquidity supplied 17.16%")
|
||||
row = page.get_by_test_id(
|
||||
"tab-myLP").locator(".ag-center-cols-container .ag-row").first
|
||||
expect(row).to_contain_text(
|
||||
"Active"
|
||||
)
|
||||
expect(page.get_by_test_id("liquidity-supplied")).to_have_text(
|
||||
"Liquidity supplied 17.16%"
|
||||
)
|
||||
row = (
|
||||
page.get_by_test_id("tab-myLP")
|
||||
.locator(".ag-center-cols-container .ag-row")
|
||||
.first
|
||||
)
|
||||
expect(row).to_contain_text("Active")
|
||||
|
||||
|
||||
@pytest.mark.skip("Waiting for the ability to cancel LP")
|
||||
@pytest.mark.usefixtures("auth", "risk_accepted")
|
||||
def test_liquidity_provision_cancelled(
|
||||
continuous_market, vega: VegaServiceNull, page: Page
|
||||
):
|
||||
def test_liquidity_provision_inactive(continuous_market, vega: VegaServiceNull, page: Page):
|
||||
# TODO Refactor asserting the grid
|
||||
page.goto(f"/#/liquidity/{continuous_market}")
|
||||
change_keys(page, vega, "market_maker")
|
||||
row = (
|
||||
page.get_by_test_id("tab-myLP")
|
||||
.locator(".ag-center-cols-container .ag-row")
|
||||
.first
|
||||
row = page.get_by_test_id(
|
||||
"tab-myLP").locator(".ag-center-cols-container .ag-row").first
|
||||
expect(row).to_contain_text(
|
||||
"Active"
|
||||
)
|
||||
expect(row).to_contain_text("Active")
|
||||
vega.cancel_liquidity(
|
||||
vega.submit_simple_liquidity(
|
||||
key_name="market_maker",
|
||||
market_id=continuous_market,
|
||||
commitment_amount=0,
|
||||
fee=0,
|
||||
is_amendment=False,
|
||||
)
|
||||
next_epoch(vega=vega)
|
||||
page.reload()
|
||||
expect(page.get_by_test_id("supplied-stake")).to_have_text(
|
||||
"Supplied stake0.00 tDAI"
|
||||
)
|
||||
expect(page.get_by_test_id("liquidity-supplied")).to_have_text(
|
||||
"Liquidity supplied 0.00%"
|
||||
)
|
||||
expect(page.locator(".ag-overlay-panel")).to_have_text("No data")
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
|
||||
@@ -5,7 +5,6 @@ from vega_sim.null_service import VegaServiceNull
|
||||
from playwright.sync_api import Page, expect
|
||||
from fixtures.market import setup_continuous_market
|
||||
from conftest import init_vega
|
||||
from actions.utils import next_epoch
|
||||
|
||||
|
||||
@pytest.fixture(scope="class")
|
||||
@@ -22,7 +21,9 @@ def create_settled_market(vega: VegaServiceNull):
|
||||
settlement_price=110,
|
||||
market_id=market_id,
|
||||
)
|
||||
next_epoch(vega=vega)
|
||||
vega.forward("10s")
|
||||
vega.wait_fn(10)
|
||||
vega.wait_for_total_catchup()
|
||||
|
||||
|
||||
class TestSettledMarket:
|
||||
@@ -122,7 +123,9 @@ def test_terminated_market_no_settlement_date(page: Page, vega: VegaServiceNull)
|
||||
payload={"trading.terminated": "true"},
|
||||
key_name="FJMKnwfZdd48C8NqvYrG",
|
||||
)
|
||||
next_epoch(vega=vega)
|
||||
vega.forward("60s")
|
||||
vega.wait_fn(10)
|
||||
vega.wait_for_total_catchup()
|
||||
page.goto(f"/#/markets/all")
|
||||
page.get_by_test_id("Closed markets").click()
|
||||
row_selector = page.locator(
|
||||
|
||||
@@ -0,0 +1,222 @@
|
||||
import pytest
|
||||
from playwright.sync_api import Page, expect
|
||||
from vega_sim.null_service import VegaServiceNull
|
||||
from actions.vega import submit_order
|
||||
from actions.utils import change_keys
|
||||
from wallet_config import MM_WALLET, MM_WALLET2
|
||||
import logging
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
table_row_selector = (
|
||||
'[data-testid="tab-open-markets"] .ag-center-cols-container .ag-row'
|
||||
)
|
||||
trading_mode_col = '[col-id="tradingMode"]'
|
||||
state_col = '[col-id="state"]'
|
||||
item_value = "item-value"
|
||||
price_monitoring_bounds_row = "key-value-table-row"
|
||||
market_trading_mode = "market-trading-mode"
|
||||
market_state = "market-state"
|
||||
liquidity_supplied = "liquidity-supplied"
|
||||
item_value = "item-value"
|
||||
price_monitoring_bounds_row = "key-value-table-row"
|
||||
market_trading_mode = "market-trading-mode"
|
||||
market_state = "market-state"
|
||||
liquidity_supplied = "liquidity-supplied"
|
||||
|
||||
initial_commitment: float = 100
|
||||
initial_price: float = 1
|
||||
initial_volume: float = 1
|
||||
initial_spread: float = 0.1
|
||||
market_name = "BTC:DAI_2023"
|
||||
|
||||
@pytest.mark.skip("tbd")
|
||||
@pytest.mark.usefixtures("risk_accepted", "auth")
|
||||
def test_price_monitoring(simple_market, vega: VegaServiceNull, page: Page):
|
||||
page.goto(f"/#/markets/all")
|
||||
expect(page.locator(table_row_selector).locator(trading_mode_col)).to_have_text(
|
||||
"Opening auction"
|
||||
)
|
||||
expect(page.locator(table_row_selector).locator('[col-id="state"]')).to_have_text(
|
||||
"Pending"
|
||||
)
|
||||
result = page.get_by_text(market_name)
|
||||
result.first.click()
|
||||
page.get_by_test_id(market_trading_mode).get_by_text("Opening auction").hover()
|
||||
expect(page.get_by_test_id("opening-auction-sub-status").first).to_have_text(
|
||||
"Opening auction: Not enough liquidity to open"
|
||||
)
|
||||
logger.info(page.get_by_test_id("opening-auction-sub-status").inner_text)
|
||||
vega.submit_liquidity(
|
||||
key_name=MM_WALLET.name,
|
||||
market_id=simple_market,
|
||||
commitment_amount=initial_commitment,
|
||||
fee=0.002,
|
||||
is_amendment=False,
|
||||
)
|
||||
|
||||
vega.submit_order(
|
||||
market_id=simple_market,
|
||||
trading_key=MM_WALLET.name,
|
||||
side="SIDE_BUY",
|
||||
order_type="TYPE_LIMIT",
|
||||
price=initial_price - 0.0005,
|
||||
wait=False,
|
||||
time_in_force="TIME_IN_FORCE_GTC",
|
||||
volume=99,
|
||||
)
|
||||
vega.submit_order(
|
||||
market_id=simple_market,
|
||||
trading_key=MM_WALLET.name,
|
||||
side="SIDE_SELL",
|
||||
order_type="TYPE_LIMIT",
|
||||
price=initial_price + 0.0005,
|
||||
wait=False,
|
||||
time_in_force="TIME_IN_FORCE_GTC",
|
||||
volume=99,
|
||||
)
|
||||
# 6002-MDET-009
|
||||
expect(
|
||||
page.get_by_test_id(liquidity_supplied).get_by_test_id(item_value)
|
||||
).to_have_text("0.00 (0.00%)")
|
||||
|
||||
# add orders to provide liquidity
|
||||
submit_order(
|
||||
vega, MM_WALLET.name, simple_market, "SIDE_BUY", initial_volume, initial_price
|
||||
)
|
||||
submit_order(
|
||||
vega, MM_WALLET.name, simple_market, "SIDE_SELL", initial_volume, initial_price
|
||||
)
|
||||
submit_order(
|
||||
vega,
|
||||
MM_WALLET.name,
|
||||
simple_market,
|
||||
"SIDE_BUY",
|
||||
initial_volume,
|
||||
initial_price + initial_spread / 2,
|
||||
)
|
||||
submit_order(
|
||||
vega,
|
||||
MM_WALLET.name,
|
||||
simple_market,
|
||||
"SIDE_SELL",
|
||||
initial_volume,
|
||||
initial_price + initial_spread / 2,
|
||||
)
|
||||
submit_order(
|
||||
vega, MM_WALLET2.name, simple_market, "SIDE_SELL", initial_volume, initial_price
|
||||
)
|
||||
expect(
|
||||
page.get_by_test_id(liquidity_supplied).get_by_test_id(item_value)
|
||||
).to_have_text("100.00 (>100%)")
|
||||
vega.forward("10s")
|
||||
vega.wait_fn(10)
|
||||
vega.wait_for_total_catchup()
|
||||
expect(
|
||||
page.get_by_test_id(liquidity_supplied).get_by_test_id(item_value)
|
||||
).to_have_text("50.00 (>100%)")
|
||||
|
||||
page.goto(f"/#/markets/all")
|
||||
# temporary skip
|
||||
# expect(page.locator(table_row_selector).locator(trading_mode_col)).to_have_text(
|
||||
# "Continuous"
|
||||
# )
|
||||
|
||||
# commented out because we have an issue #4233
|
||||
# expect(page.locator(row_selector).locator(state_col)
|
||||
# ).to_have_text("Pending")
|
||||
|
||||
page.goto(f"/#/markets/all")
|
||||
result = page.get_by_text(market_name)
|
||||
result.first.click()
|
||||
|
||||
page.get_by_test_id("Info").click()
|
||||
page.get_by_test_id("accordion-title").get_by_text(
|
||||
"Price monitoring bounds 1"
|
||||
).click()
|
||||
expect(
|
||||
page.get_by_test_id(price_monitoring_bounds_row).first.get_by_text(
|
||||
"1.32217 BTC"
|
||||
)
|
||||
).to_be_visible()
|
||||
expect(
|
||||
page.get_by_test_id(price_monitoring_bounds_row).last.get_by_text("0.79245 BTC")
|
||||
).to_be_visible()
|
||||
|
||||
# add orders that change the price so that it goes beyond the limits of price monitoring
|
||||
submit_order(vega, MM_WALLET.name, simple_market, "SIDE_SELL", 100, 110)
|
||||
submit_order(vega, MM_WALLET2.name, simple_market, "SIDE_BUY", 100, 90)
|
||||
submit_order(vega, MM_WALLET.name, simple_market, "SIDE_SELL", 100, 105)
|
||||
submit_order(vega, MM_WALLET2.name, simple_market, "SIDE_BUY", 100, 95)
|
||||
|
||||
# add order at the current price so that it is possible to change the status to price monitoring
|
||||
to_cancel = submit_order(vega, MM_WALLET2.name, simple_market, "SIDE_BUY", 1, 105)
|
||||
|
||||
vega.forward("10s")
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
expect(
|
||||
page.get_by_test_id(price_monitoring_bounds_row).first.get_by_text(
|
||||
"135.44204 BTC"
|
||||
)
|
||||
).to_be_visible()
|
||||
expect(
|
||||
page.get_by_test_id(price_monitoring_bounds_row).last.get_by_text(
|
||||
"81.17758 BTC"
|
||||
)
|
||||
).to_be_visible()
|
||||
expect(
|
||||
page.get_by_test_id(market_trading_mode).get_by_test_id(item_value)
|
||||
).to_have_text("Monitoring auction - price")
|
||||
expect(page.get_by_test_id(market_state).get_by_test_id(item_value)).to_have_text(
|
||||
"Suspended"
|
||||
)
|
||||
expect(
|
||||
page.get_by_test_id(liquidity_supplied).get_by_test_id(item_value)
|
||||
).to_have_text("50.00 (8.78%)")
|
||||
|
||||
# cancel order to increase liquidity
|
||||
vega.cancel_order(MM_WALLET2.name, simple_market, to_cancel)
|
||||
|
||||
vega.forward("10s")
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
|
||||
expect(page.get_by_text(market_name).first).to_be_attached()
|
||||
expect(
|
||||
page.get_by_test_id(market_trading_mode).get_by_test_id(item_value)
|
||||
).to_have_text("Continuous")
|
||||
expect(page.get_by_test_id(market_state).get_by_test_id(item_value)).to_have_text(
|
||||
"Active"
|
||||
)
|
||||
# commented out because we have an issue #4233
|
||||
# expect(page.get_by_text("Opening auction")).to_be_hidden()
|
||||
|
||||
# 6002-MDET-009
|
||||
expect(
|
||||
page.get_by_test_id(liquidity_supplied).get_by_test_id(item_value)
|
||||
).to_have_text("50.00 (>100%)")
|
||||
|
||||
|
||||
COL_ID_FEE = ".ag-center-cols-container [col-id='fee'] .ag-cell-value"
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("risk_accepted", "auth")
|
||||
def test_auction_uncross_fees(continuous_market, vega: VegaServiceNull, page: Page):
|
||||
page.goto(f"/#/markets/{continuous_market}")
|
||||
page.get_by_test_id("Fills").click()
|
||||
expect(page.locator(COL_ID_FEE)).to_have_text("0.00 tDAI")
|
||||
# tbd - tooltip is not visible without this wait
|
||||
page.wait_for_timeout(1000)
|
||||
page.get_by_role("gridcell", name="0.00 tDAI").nth(0).hover()
|
||||
expect(page.get_by_test_id("fee-breakdown-tooltip")).to_have_text(
|
||||
"If the market was suspendedDuring auction, half the infrastructure and liquidity fees will be paid.Infrastructure fee0.00 tDAILiquidity fee0.00 tDAIMaker fee0.00 tDAITotal fees0.00 tDAI"
|
||||
)
|
||||
change_keys(page, vega, "market_maker")
|
||||
expect(page.locator(COL_ID_FEE)).to_have_text("0.00 tDAI")
|
||||
# tbd - tooltip is not visible without this wait
|
||||
page.wait_for_timeout(1000)
|
||||
page.get_by_role("gridcell", name="0.00 tDAI").nth(0).hover()
|
||||
expect(page.get_by_test_id("fee-breakdown-tooltip")).to_have_text(
|
||||
"If the market was suspendedDuring auction, half the infrastructure and liquidity fees will be paid.Infrastructure fee0.00 tDAILiquidity fee0.00 tDAIMaker fee0.00 tDAITotal fees0.00 tDAI"
|
||||
)
|
||||
@@ -25,3 +25,65 @@ def test_market_selector(continuous_market, page: Page):
|
||||
expect(btc_market.locator("span.rounded-md.leading-none")).to_be_visible()
|
||||
expect(btc_market.locator("span.rounded-md.leading-none")).to_have_text("Futr")
|
||||
expect(btc_market.locator('[data-testid="sparkline-svg"]')).not_to_be_visible
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("simple_market", "auth", "risk_accepted")
|
||||
@pytest.mark.parametrize(
|
||||
"simple_market",
|
||||
[
|
||||
{
|
||||
"custom_market_name": "APPL.MF21",
|
||||
"custom_asset_name": "tUSDC",
|
||||
"custom_asset_symbol": "tUSDC",
|
||||
}
|
||||
],
|
||||
indirect=True,
|
||||
)
|
||||
def test_market_selector_filter(continuous_market, page: Page):
|
||||
page.goto(f"/#/markets/{continuous_market}")
|
||||
page.get_by_test_id("header-title").click()
|
||||
# 6001-MARK-027
|
||||
page.get_by_test_id("product-Spot").click()
|
||||
expect(page.get_by_test_id("market-selector-list")).to_contain_text(
|
||||
"Spot markets coming soon."
|
||||
)
|
||||
page.get_by_test_id("product-Perpetual").click()
|
||||
expect(page.get_by_test_id("market-selector-list")).to_contain_text(
|
||||
"No perpetual markets."
|
||||
)
|
||||
page.get_by_test_id("product-Future").click()
|
||||
expect(page.locator('[data-testid="market-selector-list"] a')).to_have_count(2)
|
||||
|
||||
# 6001-MARK-029
|
||||
page.get_by_test_id("search-term").fill("btc")
|
||||
expect(page.locator('[data-testid="market-selector-list"] a')).to_have_count(1)
|
||||
# tbd - 5465
|
||||
expect(page.locator('[data-testid="market-selector-list"] a').nth(0)).to_contain_text(
|
||||
"BTC:DAI_2023107.50 tDAI"
|
||||
)
|
||||
|
||||
page.get_by_test_id("search-term").clear()
|
||||
expect(page.locator('[data-testid="market-selector-list"] a')).to_have_count(2)
|
||||
|
||||
# 6001-MARK-030
|
||||
# 6001-MARK-031
|
||||
# 6001-MARK-032
|
||||
# 6001-MARK-033
|
||||
page.get_by_test_id("sort-trigger").click()
|
||||
|
||||
expect(page.get_by_test_id("sort-item-Gained")).to_have_text("Top gaining")
|
||||
expect(page.get_by_test_id("sort-item-Gained")).to_be_visible()
|
||||
expect(page.get_by_test_id("sort-item-Lost")).to_have_text("Top losing")
|
||||
expect(page.get_by_test_id("sort-item-Lost")).to_be_visible()
|
||||
expect(page.get_by_test_id("sort-item-New")).to_have_text("New markets")
|
||||
expect(page.get_by_test_id("sort-item-New")).to_be_visible()
|
||||
|
||||
# 6001-MARK-028
|
||||
page.get_by_test_id("sort-trigger").click(force=True)
|
||||
page.get_by_test_id("asset-trigger").click()
|
||||
page.get_by_role("menuitemcheckbox").nth(0).get_by_text("tDAI").click()
|
||||
expect(page.locator('[data-testid="market-selector-list"] a')).to_have_count(1)
|
||||
# tbd - 5465
|
||||
expect(page.locator('[data-testid="market-selector-list"] a').nth(0)).to_contain_text(
|
||||
"BTC:DAI_2023107.50 tDAI"
|
||||
)
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
import pytest
|
||||
from playwright.sync_api import Page, expect
|
||||
|
||||
from conftest import init_page, init_vega, risk_accepted_setup
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def vega(request):
|
||||
with init_vega(request) as vega:
|
||||
yield vega
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def page(vega, browser, request):
|
||||
with init_page(vega, browser, request) as page:
|
||||
risk_accepted_setup(page)
|
||||
page.goto("/#/markets/all")
|
||||
yield page
|
||||
|
||||
|
||||
def test_no_open_markets(page: Page):
|
||||
# 6001-MARK-034
|
||||
page.get_by_test_id("Open markets").click()
|
||||
expect(page.locator(".ag-overlay-wrapper")).to_have_text("No markets")
|
||||
|
||||
|
||||
def test_no_closed_markets(page: Page):
|
||||
page.get_by_test_id("Closed markets").click()
|
||||
expect(page.locator(".ag-overlay-wrapper")).to_have_text("No markets")
|
||||
|
||||
|
||||
def test_no_proposed_markets(page: Page):
|
||||
# 6001-MARK-061
|
||||
page.get_by_test_id("Proposed markets").click()
|
||||
expect(page.locator(".ag-overlay-wrapper")).to_have_text("No proposed markets")
|
||||
@@ -4,14 +4,9 @@ from vega_sim.null_service import VegaServiceNull
|
||||
from actions.vega import submit_order
|
||||
from fixtures.market import setup_simple_market
|
||||
from conftest import init_vega
|
||||
from actions.utils import wait_for_toast_confirmation, change_keys
|
||||
from actions.utils import wait_for_toast_confirmation
|
||||
from wallet_config import MM_WALLET, MM_WALLET2
|
||||
|
||||
market_trading_mode = "market-trading-mode"
|
||||
market_state = "market-state"
|
||||
item_value = "item-value"
|
||||
|
||||
COL_ID_FEE = ".ag-center-cols-container [col-id='fee'] .ag-cell-value"
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def vega(request):
|
||||
@@ -138,29 +133,3 @@ def test_market_monitoring_auction_price_volatility_market_order(
|
||||
"This market is in auction due to high price volatility. Only limit orders are permitted when market is in auction."
|
||||
)
|
||||
expect(page.get_by_test_id("deal-ticket-error-message-type")).to_be_visible()
|
||||
|
||||
@pytest.mark.usefixtures("risk_accepted", "auth", "setup_market_monitoring_auction")
|
||||
def test_market_price_volatility(
|
||||
page: Page, simple_market, vega: VegaServiceNull
|
||||
):
|
||||
page.goto(f"/#/markets/{simple_market}")
|
||||
expect(
|
||||
page.get_by_test_id(market_trading_mode).get_by_test_id(item_value)
|
||||
).to_have_text("Monitoring auction - price")
|
||||
expect(page.get_by_test_id(market_state).get_by_test_id(item_value)).to_have_text(
|
||||
"Suspended"
|
||||
)
|
||||
|
||||
@pytest.mark.usefixtures("risk_accepted", "auth", "setup_market_monitoring_auction")
|
||||
def test_auction_uncross_fees(simple_market, vega: VegaServiceNull, page: Page):
|
||||
page.goto(f"/#/markets/{simple_market}")
|
||||
change_keys(page, vega, "market_maker")
|
||||
page.get_by_test_id("Fills").click()
|
||||
row = page.locator('[row-index="3"]').nth(1)
|
||||
expect(row.locator('[col-id="fee"]')).to_have_text("0.00 tDAI")
|
||||
# tbd - tooltip is not visible without this wait
|
||||
page.wait_for_timeout(1000)
|
||||
row.locator('[col-id="fee"]').hover()
|
||||
expect(page.get_by_test_id("fee-breakdown-tooltip")).to_have_text(
|
||||
"If the market was suspendedDuring auction, half the infrastructure and liquidity fees will be paid.Infrastructure fee0.00 tDAILiquidity fee0.00 tDAIMaker fee0.00 tDAITotal fees0.00 tDAI"
|
||||
)
|
||||
@@ -73,6 +73,9 @@ def test_market_lifecycle(proposed_market, vega: VegaServiceNull, page: Page):
|
||||
)
|
||||
|
||||
# "wait" for market to be approved and enacted
|
||||
vega.forward("60s")
|
||||
vega.wait_fn(10)
|
||||
vega.wait_for_total_catchup()
|
||||
next_epoch(vega=vega)
|
||||
# check that market is in pending state
|
||||
expect(trading_mode).to_have_text("Opening auction")
|
||||
@@ -115,7 +118,8 @@ def test_market_lifecycle(proposed_market, vega: VegaServiceNull, page: Page):
|
||||
submit_order(vega, MM_WALLET.name, market_id, "SIDE_SELL", 1, 100)
|
||||
submit_order(vega, MM_WALLET2.name, market_id, "SIDE_BUY", 1, 100)
|
||||
|
||||
vega.wait_fn(2)
|
||||
vega.forward("10s")
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
|
||||
# check market state is now active and trading mode is continuous
|
||||
@@ -135,7 +139,9 @@ def test_market_lifecycle(proposed_market, vega: VegaServiceNull, page: Page):
|
||||
.get_by_test_id(f"update-state-banner-{market_id}")
|
||||
).to_be_visible()
|
||||
|
||||
next_epoch(vega=vega)
|
||||
vega.forward("60s")
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
|
||||
expect(
|
||||
page.get_by_test_id("market-banner")
|
||||
@@ -149,7 +155,9 @@ def test_market_lifecycle(proposed_market, vega: VegaServiceNull, page: Page):
|
||||
forward_time_to_enactment = False
|
||||
)
|
||||
|
||||
next_epoch(vega=vega)
|
||||
vega.forward("60s")
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
|
||||
expect(page.get_by_test_id("market-banner")).not_to_be_visible()
|
||||
|
||||
@@ -162,7 +170,9 @@ def test_market_lifecycle(proposed_market, vega: VegaServiceNull, page: Page):
|
||||
payload={"trading.terminated": "true"},
|
||||
key_name=GOVERNANCE_WALLET.name,
|
||||
)
|
||||
next_epoch(vega=vega)
|
||||
vega.forward("60s")
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
|
||||
# market state should be changed to "No trading" because of the invalid oracle
|
||||
expect(trading_mode).to_have_text("No trading")
|
||||
@@ -174,7 +184,9 @@ def test_market_lifecycle(proposed_market, vega: VegaServiceNull, page: Page):
|
||||
settlement_price=100,
|
||||
market_id=market_id,
|
||||
)
|
||||
next_epoch(vega=vega)
|
||||
vega.forward("10s")
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
|
||||
# check market state is now settled
|
||||
expect(trading_mode).to_have_text("No trading")
|
||||
|
||||
@@ -44,7 +44,7 @@ def verify_order_value(
|
||||
actual_text = element.text_content()
|
||||
|
||||
if actual_text is None:
|
||||
raise Exception(f"no text found for test_id {test_id}")
|
||||
raise Exception(f"no text found for test_id {test_id}")
|
||||
|
||||
assert re.match(
|
||||
expected_text, actual_text
|
||||
|
||||
@@ -144,4 +144,5 @@ def test_limit_order_trade_order_trade_away(continuous_market, page: Page):
|
||||
page.get_by_test_id("Orderbook").click()
|
||||
price_element = page.get_by_test_id("price-11000000").nth(1)
|
||||
# 6003-ORDB-010
|
||||
print(price_element)
|
||||
expect(price_element).to_be_hidden()
|
||||
|
||||
@@ -106,6 +106,7 @@ def test_orderbook_grid_content(setup_market, page: Page):
|
||||
matching_order[1],
|
||||
)
|
||||
|
||||
vega.forward("10s")
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
|
||||
@@ -232,6 +233,7 @@ def test_orderbook_price_movement(setup_market, page: Page):
|
||||
matching_order_1[1],
|
||||
)
|
||||
|
||||
vega.forward("10s")
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
|
||||
@@ -252,6 +254,7 @@ def test_orderbook_price_movement(setup_market, page: Page):
|
||||
matching_order_2[1],
|
||||
)
|
||||
|
||||
vega.forward("10s")
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ class TestPerpetuals:
|
||||
settlement_price=110,
|
||||
market_id=perps_market,
|
||||
)
|
||||
vega.forward("10s")
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
submit_multiple_orders(
|
||||
@@ -47,7 +48,8 @@ class TestPerpetuals:
|
||||
settlement_price=110,
|
||||
market_id=perps_market,
|
||||
)
|
||||
vega.wait_fn(10)
|
||||
vega.forward("10s")
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
return perps_market
|
||||
|
||||
@@ -108,6 +110,7 @@ def test_perps_market_termination_proposed(page: Page, vega: VegaServiceNull):
|
||||
forward_time_to_enactment=False,
|
||||
)
|
||||
|
||||
vega.forward("10s")
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
banner_text = page.get_by_test_id(
|
||||
@@ -132,6 +135,7 @@ def test_perps_market_terminated(page: Page, vega: VegaServiceNull):
|
||||
approve_proposal=True,
|
||||
forward_time_to_enactment=True,
|
||||
)
|
||||
vega.forward("10s")
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ def check_pnl_color_value(element, expected_color, expected_value):
|
||||
assert color == expected_color, f"Unexpected color: {color}"
|
||||
assert value == expected_value, f"Unexpected value: {value}"
|
||||
|
||||
#TODO move this test to jest
|
||||
|
||||
@pytest.mark.usefixtures("auth", "risk_accepted")
|
||||
def test_pnl(continuous_market, vega: VegaServiceNull, page: Page):
|
||||
page.set_viewport_size({"width": 1748, "height": 977})
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
import os
|
||||
import pytest
|
||||
from playwright.sync_api import Page, expect
|
||||
|
||||
#TODO migrate to jest
|
||||
@pytest.mark.usefixtures("auth", "risk_accepted", "continuous_market")
|
||||
def test_ledger_entries_downloads(page: Page):
|
||||
page.goto("/#/portfolio")
|
||||
page.get_by_test_id("Ledger entries").click()
|
||||
expect(page.get_by_test_id("ledger-download-button")).to_be_enabled()
|
||||
# 7007-LEEN-001
|
||||
page.get_by_test_id("ledger-download-button").click()
|
||||
# 7007-LEEN-009
|
||||
expect(page.get_by_test_id("toast-content")).to_contain_text(("Your file is ready"))
|
||||
# Get the user's Downloads directory
|
||||
downloads_directory = os.path.expanduser("~") + "/Downloads/"
|
||||
# Start waiting for the download
|
||||
with page.expect_download() as download_info:
|
||||
# Perform the action that initiates download
|
||||
page.get_by_role("link", name="Get file here").click()
|
||||
|
||||
download = download_info.value
|
||||
# Wait for the download process to complete and save the downloaded file in the Downloads directory
|
||||
download.save_as(os.path.join(downloads_directory, download.suggested_filename))
|
||||
|
||||
# Verify the download by asserting that the file exists
|
||||
downloaded_file_path = os.path.join(
|
||||
downloads_directory, download.suggested_filename
|
||||
)
|
||||
assert os.path.exists(
|
||||
downloaded_file_path
|
||||
), f"Download failed! File not found at: {downloaded_file_path}"
|
||||
@@ -15,6 +15,7 @@ def test_closed_market_position(vega: VegaServiceNull, page: Page):
|
||||
settlement_price=110,
|
||||
market_id=market_id,
|
||||
)
|
||||
vega.forward("10s")
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
page.goto(f"/#/markets/{market_id}")
|
||||
|
||||
@@ -149,5 +149,7 @@ def provide_successor_liquidity(
|
||||
)
|
||||
|
||||
submit_order(vega, "Key 1", market_id, "SIDE_BUY", 1, 110)
|
||||
|
||||
vega.forward("10s")
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
|
||||
@@ -1,109 +0,0 @@
|
||||
import pytest
|
||||
from playwright.sync_api import expect, Page
|
||||
import vega_sim.proto.vega as vega_protos
|
||||
from vega_sim.null_service import VegaServiceNull
|
||||
from conftest import init_vega
|
||||
from actions.utils import next_epoch
|
||||
from fixtures.market import setup_continuous_market
|
||||
from wallet_config import PARTY_A, PARTY_B, PARTY_C, PARTY_D, MM_WALLET
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def vega(request):
|
||||
with init_vega(request) as vega:
|
||||
yield vega
|
||||
|
||||
|
||||
def setup_teams_and_games(vega: VegaServiceNull):
|
||||
tDAI_market = setup_continuous_market(vega)
|
||||
tDAI_asset_id = vega.find_asset_id(symbol="tDAI")
|
||||
vega.mint(key_name=PARTY_B.name, asset=tDAI_asset_id, amount=100000)
|
||||
vega.mint(key_name=PARTY_C.name, asset=tDAI_asset_id, amount=100000)
|
||||
vega.mint(key_name=PARTY_A.name, asset=tDAI_asset_id, amount=100000)
|
||||
vega.mint(key_name=PARTY_D.name, asset=tDAI_asset_id, amount=100000)
|
||||
next_epoch(vega=vega)
|
||||
|
||||
tDAI_asset_id = vega.find_asset_id(symbol="tDAI")
|
||||
vega.update_network_parameter(
|
||||
MM_WALLET.name, parameter="reward.asset", new_value=tDAI_asset_id
|
||||
)
|
||||
|
||||
next_epoch(vega=vega)
|
||||
|
||||
team_name = create_team(vega)
|
||||
|
||||
next_epoch(vega)
|
||||
teams = vega.list_teams()
|
||||
|
||||
# list_teams actually returns a dictionary {"team_id": Team}
|
||||
team_id = list(teams.keys())[0]
|
||||
|
||||
vega.apply_referral_code(PARTY_B.name, team_id)
|
||||
|
||||
# go to next epoch so we can check joinedAt and joinedAtEpoch appropriately
|
||||
next_epoch(vega)
|
||||
|
||||
vega.apply_referral_code(PARTY_C.name, team_id)
|
||||
|
||||
next_epoch(vega)
|
||||
|
||||
vega.apply_referral_code(PARTY_D.name, team_id)
|
||||
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
vega.recurring_transfer(
|
||||
from_key_name=PARTY_A.name,
|
||||
from_account_type=vega_protos.vega.ACCOUNT_TYPE_GENERAL,
|
||||
to_account_type=vega_protos.vega.ACCOUNT_TYPE_REWARD_MAKER_PAID_FEES,
|
||||
asset=tDAI_asset_id,
|
||||
reference="reward",
|
||||
asset_for_metric=tDAI_asset_id,
|
||||
metric=vega_protos.vega.DISPATCH_METRIC_MAKER_FEES_PAID,
|
||||
entity_scope=vega_protos.vega.ENTITY_SCOPE_TEAMS,
|
||||
n_top_performers=1,
|
||||
amount=100,
|
||||
factor=1.0,
|
||||
)
|
||||
vega.submit_order(
|
||||
trading_key=PARTY_B.name,
|
||||
market_id=tDAI_market,
|
||||
order_type="TYPE_MARKET",
|
||||
time_in_force="TIME_IN_FORCE_IOC",
|
||||
side="SIDE_BUY",
|
||||
volume=1,
|
||||
)
|
||||
vega.submit_order(
|
||||
trading_key=PARTY_A.name,
|
||||
market_id=tDAI_market,
|
||||
order_type="TYPE_MARKET",
|
||||
time_in_force="TIME_IN_FORCE_IOC",
|
||||
side="SIDE_BUY",
|
||||
volume=1,
|
||||
)
|
||||
next_epoch(vega=vega)
|
||||
return tDAI_market, tDAI_asset_id, team_id, team_name
|
||||
|
||||
|
||||
@pytest.mark.usefixtures("auth", "risk_accepted")
|
||||
def test_teams(vega: VegaServiceNull, page: Page):
|
||||
market_id, asset_id, team_id, team_name = setup_teams_and_games(vega)
|
||||
page.goto(f"/#/competitions/team/{team_id}")
|
||||
print(team_name)
|
||||
print(team_id)
|
||||
#page.pause()
|
||||
expect(page.get_by_role("heading", level=1)).to_have_text(team_name)
|
||||
expect(page.get_by_text("Members (3)")).to_be_visible()
|
||||
|
||||
|
||||
def create_team(vega: VegaServiceNull):
|
||||
team_name = "Foobar"
|
||||
|
||||
vega.create_referral_set(
|
||||
key_name=PARTY_A.name,
|
||||
name=team_name,
|
||||
team_url="https://vega.xyz",
|
||||
avatar_url="http://placekitten.com/200/200",
|
||||
closed=False,
|
||||
)
|
||||
|
||||
return team_name
|
||||
@@ -22,6 +22,8 @@ def test_trade_match_table(opening_auction_market: str, vega: VegaServiceNull, p
|
||||
price=10e15,
|
||||
wait=False,
|
||||
)
|
||||
|
||||
vega.forward("10s")
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
|
||||
@@ -32,6 +34,7 @@ def test_trade_match_table(opening_auction_market: str, vega: VegaServiceNull, p
|
||||
"SIDE_BUY",
|
||||
[[5, 110], [5, 105], [1, 50]],
|
||||
)
|
||||
vega.forward("10s")
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
|
||||
@@ -42,6 +45,7 @@ def test_trade_match_table(opening_auction_market: str, vega: VegaServiceNull, p
|
||||
"SIDE_SELL",
|
||||
[[5, 90], [5, 95], [1, 150]],
|
||||
)
|
||||
vega.forward("60s")
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@ def test_transfer_submit(continuous_market, vega: VegaServiceNull, page: Page):
|
||||
|
||||
page.locator('[data-testid=transfer-form] [type="submit"]').click()
|
||||
wait_for_toast_confirmation(page)
|
||||
vega.forward("10s")
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
expected_confirmation_text = re.compile(
|
||||
@@ -141,12 +142,14 @@ def test_transfer_vesting_below_minimum(
|
||||
asset=asset_id,
|
||||
amount=24.999999,
|
||||
)
|
||||
vega.forward("10s")
|
||||
vega.wait_fn(10)
|
||||
vega.wait_for_total_catchup()
|
||||
|
||||
page.get_by_test_id("use-max-button").first.click()
|
||||
page.locator('[data-testid=transfer-form] [type="submit"]').click()
|
||||
wait_for_toast_confirmation(page)
|
||||
vega.forward("10s")
|
||||
vega.wait_fn(1)
|
||||
vega.wait_for_total_catchup()
|
||||
expected_confirmation_text = re.compile(
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
import { waitFor, fireEvent, render, screen } from '@testing-library/react';
|
||||
import {
|
||||
waitFor,
|
||||
fireEvent,
|
||||
render,
|
||||
screen,
|
||||
act,
|
||||
} from '@testing-library/react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import BigNumber from 'bignumber.js';
|
||||
import type { DepositFormProps } from './deposit-form';
|
||||
@@ -83,10 +89,7 @@ describe('Deposit form', () => {
|
||||
render(<DepositForm {...props} />);
|
||||
|
||||
// Assert default values (including) from/to provided by useVegaWallet and useWeb3React
|
||||
// Wait for first value to show as form is rendered conditionally based on chainId
|
||||
expect(
|
||||
await screen.findByText('From (Ethereum address)')
|
||||
).toBeInTheDocument();
|
||||
expect(screen.getByText('From (Ethereum address)')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('ethereum-address')).toHaveTextContent(
|
||||
truncateMiddle(MOCK_ETH_ADDRESS)
|
||||
);
|
||||
@@ -316,40 +319,34 @@ describe('Deposit form', () => {
|
||||
|
||||
it('shows "View asset details" button when an asset is selected', async () => {
|
||||
render(<DepositForm {...props} selectedAsset={asset} />);
|
||||
expect(await screen.findByTestId('view-asset-details')).toBeInTheDocument();
|
||||
expect(await screen.getByTestId('view-asset-details')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('does not shows "View asset details" button when no asset is selected', async () => {
|
||||
render(<DepositForm {...props} />);
|
||||
await waitFor(() => {
|
||||
expect(screen.queryAllByTestId('view-asset-details')).toHaveLength(0);
|
||||
});
|
||||
expect(await screen.queryAllByTestId('view-asset-details')).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('renders a connect button if Ethereum wallet is not connected', async () => {
|
||||
it('renders a connect button if Ethereum wallet is not connected', () => {
|
||||
(useWeb3React as jest.Mock).mockReturnValue({
|
||||
isActive: false,
|
||||
account: '',
|
||||
});
|
||||
|
||||
render(<DepositForm {...props} />);
|
||||
|
||||
expect(
|
||||
await screen.findByRole('button', { name: 'Connect' })
|
||||
).toBeInTheDocument();
|
||||
expect(screen.getByRole('button', { name: 'Connect' })).toBeInTheDocument();
|
||||
expect(
|
||||
screen.queryByLabelText('From (Ethereum address)')
|
||||
).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders a disabled input if Ethereum wallet is connected', async () => {
|
||||
it('renders a disabled input if Ethereum wallet is connected', () => {
|
||||
(useWeb3React as jest.Mock).mockReturnValue({
|
||||
isActive: true,
|
||||
account: MOCK_ETH_ADDRESS,
|
||||
});
|
||||
render(<DepositForm {...props} />);
|
||||
|
||||
expect(await screen.findByTestId('deposit-form')).toBeInTheDocument();
|
||||
expect(
|
||||
screen.queryByRole('button', { name: 'Connect' })
|
||||
).not.toBeInTheDocument();
|
||||
@@ -359,56 +356,53 @@ describe('Deposit form', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('prevents submission if you are on the wrong chain', async () => {
|
||||
// Make mocks return a chain id mismatch
|
||||
it('prevents submission if you are on the wrong chain', () => {
|
||||
(useWeb3React as jest.Mock).mockReturnValue({
|
||||
isActive: true,
|
||||
account: MOCK_ETH_ADDRESS,
|
||||
chainId: 1,
|
||||
});
|
||||
(useWeb3ConnectStore as unknown as jest.Mock).mockImplementationOnce(
|
||||
(useWeb3ConnectStore as unknown as jest.Mock).mockImplementation(
|
||||
// eslint-disable-next-line
|
||||
(selector: (result: ReturnType<typeof useWeb3ConnectStore>) => any) => {
|
||||
return selector({
|
||||
desiredChainId: 11155111,
|
||||
open: jest.fn(),
|
||||
foo: 'asdf',
|
||||
});
|
||||
}
|
||||
);
|
||||
render(<DepositForm {...props} />);
|
||||
|
||||
expect(await screen.findByTestId('chain-error')).toHaveTextContent(
|
||||
expect(screen.getByTestId('chain-error')).toHaveTextContent(
|
||||
/this app only works on/i
|
||||
);
|
||||
|
||||
expect(screen.queryByTestId('deposit-form')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('Remaining deposit allowance tooltip should be rendered', async () => {
|
||||
render(<DepositForm {...props} selectedAsset={asset} />);
|
||||
|
||||
expect(await screen.findByTestId('deposit-form')).toBeInTheDocument();
|
||||
|
||||
await userEvent.hover(screen.getByText('Remaining deposit allowance'));
|
||||
|
||||
expect(
|
||||
await screen.findByRole('tooltip', {
|
||||
name: /VEGA has a lifetime deposit limit of 20 asset-symbol per address/,
|
||||
})
|
||||
).toBeInTheDocument();
|
||||
await act(async () => {
|
||||
await userEvent.hover(screen.getByText('Remaining deposit allowance'));
|
||||
});
|
||||
await waitFor(async () => {
|
||||
await expect(
|
||||
screen.getByRole('tooltip', {
|
||||
name: /VEGA has a lifetime deposit limit of 20 asset-symbol per address/,
|
||||
})
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
it('Ethereum deposit cap tooltip should be rendered', async () => {
|
||||
render(<DepositForm {...props} selectedAsset={asset} />);
|
||||
|
||||
expect(await screen.findByTestId('deposit-form')).toBeInTheDocument();
|
||||
|
||||
await userEvent.hover(screen.getByText('Ethereum deposit cap'));
|
||||
|
||||
expect(
|
||||
await screen.findByRole('tooltip', {
|
||||
name: /The deposit cap is set when you approve an asset for use with this app/,
|
||||
})
|
||||
).toBeInTheDocument();
|
||||
await act(async () => {
|
||||
await userEvent.hover(screen.getByText('Ethereum deposit cap'));
|
||||
});
|
||||
await waitFor(async () => {
|
||||
await expect(
|
||||
screen.getByRole('tooltip', {
|
||||
name: /The deposit cap is set when you approve an asset for use with this app/,
|
||||
})
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -92,9 +92,7 @@ export const DepositForm = ({
|
||||
const maxSafe = useMaxSafe();
|
||||
const { open: openAssetDetailsDialog } = useAssetDetailsDialogStore();
|
||||
const openDialog = useWeb3ConnectStore((store) => store.open);
|
||||
const { isActive, account, chainId } = useWeb3React();
|
||||
const desiredChainId = useWeb3ConnectStore((store) => store.desiredChainId);
|
||||
const invalidChain = isActive && chainId !== desiredChainId;
|
||||
const { isActive, account } = useWeb3React();
|
||||
const { pubKey, pubKeys: _pubKeys } = useVegaWallet();
|
||||
const [approveNotificationIntent, setApproveNotificationIntent] =
|
||||
useState<Intent>(Intent.Warning);
|
||||
@@ -154,20 +152,7 @@ export const DepositForm = ({
|
||||
const approved =
|
||||
balances && balances.allowance.isGreaterThan(0) ? true : false;
|
||||
|
||||
return invalidChain ? (
|
||||
<div className="mb-2">
|
||||
<Notification
|
||||
intent={Intent.Danger}
|
||||
testId="chain-error"
|
||||
message={t(
|
||||
'This app only works on {{chainId}}. Switch your Ethereum wallet to the correct network.',
|
||||
{
|
||||
chainId: getChainName(desiredChainId),
|
||||
}
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
) : (
|
||||
return (
|
||||
<form
|
||||
onSubmit={handleSubmit(onSubmit)}
|
||||
noValidate={true}
|
||||
@@ -432,11 +417,7 @@ export const DepositForm = ({
|
||||
intent={approveNotificationIntent}
|
||||
amount={amount}
|
||||
/>
|
||||
<FormButton
|
||||
approved={approved}
|
||||
isActive={isActive}
|
||||
selectedAsset={selectedAsset}
|
||||
/>
|
||||
<FormButton approved={approved} selectedAsset={selectedAsset} />
|
||||
</form>
|
||||
);
|
||||
};
|
||||
@@ -444,21 +425,35 @@ export const DepositForm = ({
|
||||
interface FormButtonProps {
|
||||
approved: boolean;
|
||||
selectedAsset: AssetFieldsFragment | undefined;
|
||||
isActive: boolean;
|
||||
}
|
||||
|
||||
const FormButton = ({ approved, selectedAsset, isActive }: FormButtonProps) => {
|
||||
const FormButton = ({ approved, selectedAsset }: FormButtonProps) => {
|
||||
const t = useT();
|
||||
|
||||
const { isActive, chainId } = useWeb3React();
|
||||
const desiredChainId = useWeb3ConnectStore((store) => store.desiredChainId);
|
||||
const invalidChain = isActive && chainId !== desiredChainId;
|
||||
return (
|
||||
<TradingButton
|
||||
type="submit"
|
||||
data-testid="deposit-submit"
|
||||
fill
|
||||
disabled={!isActive}
|
||||
>
|
||||
{t('Deposit')}
|
||||
</TradingButton>
|
||||
<>
|
||||
{invalidChain && (
|
||||
<div className="mb-2">
|
||||
<Notification
|
||||
intent={Intent.Danger}
|
||||
testId="chain-error"
|
||||
message={t('This app only works on {{chainId}}.', {
|
||||
chainId: getChainName(desiredChainId),
|
||||
})}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
<TradingButton
|
||||
type="submit"
|
||||
data-testid="deposit-submit"
|
||||
fill
|
||||
disabled={!isActive || invalidChain}
|
||||
>
|
||||
{t('Deposit')}
|
||||
</TradingButton>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
"The {{symbol}} faucet is not available at this time": "The {{symbol}} faucet is not available at this time",
|
||||
"The deposit cap is set when you approve an asset for use with this app. To increase this cap, approve {{assetSymbol}} again and choose a higher cap. Check the documentation for your Ethereum wallet app for details.": "The deposit cap is set when you approve an asset for use with this app. To increase this cap, approve {{assetSymbol}} again and choose a higher cap. Check the documentation for your Ethereum wallet app for details.",
|
||||
"The faucet transaction was rejected by the connected Ethereum wallet": "The faucet transaction was rejected by the connected Ethereum wallet",
|
||||
"This app only works on {{chainId}}. Switch your Ethereum wallet to the correct network.": "This app only works on {{chainId}}. Switch your Ethereum wallet to the correct network.",
|
||||
"This app only works on {{chainId}}.": "This app only works on {{chainId}}.",
|
||||
"To (Vega key)": "To (Vega key)",
|
||||
"To date, {{currentDeposit}} {{assetSymbol}} has been deposited from this Ethereum address, so you can deposit up to {{remainingDeposit}} {{assetSymbol}} more.": "To date, {{currentDeposit}} {{assetSymbol}} has been deposited from this Ethereum address, so you can deposit up to {{remainingDeposit}} {{assetSymbol}} more.",
|
||||
"Use maximum": "Use maximum",
|
||||
|
||||
Reference in New Issue
Block a user