Compare commits

...

1 Commits

Author SHA1 Message Date
Matthew Russell
e1ed910271
chore: revert reuse vega work 2024-02-28 16:54:48 +00:00
7 changed files with 96 additions and 139 deletions

View File

@ -182,27 +182,7 @@ def vega(request):
request.addfinalizer(lambda: cleanup_container(vega_instance)) request.addfinalizer(lambda: cleanup_container(vega_instance))
yield vega_instance yield vega_instance
@pytest.fixture(scope="session", autouse=True)
def shared_vega(request):
with init_vega(request) as vega_instance:
try:
request.addfinalizer(lambda: cleanup_container(vega_instance))
yield vega_instance
finally:
cleanup_container(vega_instance)
@pytest.fixture
def page_shared_vega(shared_vega, browser, request):
with init_page(shared_vega, browser, request) as page_instance:
yield page_instance
@pytest.fixture
def auth_shared_vega(shared_vega: VegaServiceNull, page_shared_vega: Page):
return auth_setup(shared_vega, page_shared_vega)
@pytest.fixture
def risk_accepted_shared_vega(page_shared_vega: Page):
risk_accepted_setup(page_shared_vega)
def cleanup_container(vega_instance): def cleanup_container(vega_instance):
try: try:
@ -303,10 +283,6 @@ def opening_auction_market(vega):
return setup_opening_auction_market(vega) return setup_opening_auction_market(vega)
@pytest.fixture(scope="function")
def shared_continuous_market(shared_vega:VegaServiceNull):
return setup_continuous_market(shared_vega)
@pytest.fixture(scope="function") @pytest.fixture(scope="function")
def continuous_market(vega): def continuous_market(vega):
return setup_continuous_market(vega) return setup_continuous_market(vega)

View File

@ -2,62 +2,35 @@ import pytest
from playwright.sync_api import Page, expect from playwright.sync_api import Page, expect
from vega_sim.null_service import VegaServiceNull from vega_sim.null_service import VegaServiceNull
from datetime import datetime, timedelta from datetime import datetime, timedelta
from conftest import init_page, risk_accepted_setup, auth_setup from conftest import init_vega, cleanup_container
from fixtures.market import setup_continuous_market from fixtures.market import setup_continuous_market
from actions.utils import wait_for_toast_confirmation from actions.utils import wait_for_toast_confirmation
from wallet_config import WalletConfig, MM_WALLET2
from actions.utils import (
change_keys,
create_and_faucet_wallet,
)
order_size = "order-size" order_size = "order-size"
order_price = "order-price" order_price = "order-price"
place_order = "place-order" place_order = "place-order"
order_side_sell = "order-side-SIDE_SELL" order_side_sell = "order-side-SIDE_SELL"
order_side_buy = "order-side-SIDE_BUY"
market_order = "order-type-Market" market_order = "order-type-Market"
limit_order = "order-type-Limit"
tif = "order-tif" tif = "order-tif"
expire = "expire" expire = "expire"
@pytest.fixture(scope="module") @pytest.fixture(scope="module")
def page(shared_vega, browser, request, continuous_market): def vega(request):
with init_page(shared_vega, browser, request) as page: with init_vega(request) as vega_instance:
risk_accepted_setup(page) request.addfinalizer(lambda: cleanup_container(vega_instance)) # Register the cleanup function
auth_setup(shared_vega, page) yield vega_instance
basic_key = WalletConfig("basic_key", "basic_key")
create_and_faucet_wallet(vega=shared_vega, wallet=basic_key)
page.goto(f"/#/markets/{continuous_market}")
change_keys(page, shared_vega, "basic_key")
yield page
@pytest.fixture(scope="module") @pytest.fixture(scope="module")
def continuous_market(shared_vega:VegaServiceNull): def continuous_market(vega):
keypairs = shared_vega.wallet.get_keypairs("MarketSim") return setup_continuous_market(vega)
proposal_key = keypairs.get('market_maker')
termination_key=keypairs.get('FJMKnwfZdd48C8NqvYrG')
mm_2_key=keypairs.get('market_maker_2')
kwargs = {}
if proposal_key is not None:
kwargs['proposal_key'] = proposal_key
if termination_key is not None:
kwargs['termination_key'] = termination_key
if mm_2_key is not None:
kwargs['mm_2_key'] = mm_2_key
return setup_continuous_market(shared_vega, **kwargs)
@pytest.mark.usefixtures("auth", "risk_accepted")
def test_limit_buy_order_GTT( shared_vega: VegaServiceNull, page: Page): def test_limit_buy_order_GTT(continuous_market, vega: VegaServiceNull, page: Page):
page.get_by_test_id(limit_order).click() page.goto(f"/#/markets/{continuous_market}")
page.get_by_test_id(order_side_buy).click()
page.get_by_test_id(tif).select_option("Good 'til Time (GTT)") page.get_by_test_id(tif).select_option("Good 'til Time (GTT)")
page.get_by_test_id(order_size).fill("10") page.get_by_test_id(order_size).fill("10")
page.get_by_test_id(order_price).fill("120") page.get_by_test_id(order_price).fill("120")
@ -74,31 +47,30 @@ def test_limit_buy_order_GTT( shared_vega: VegaServiceNull, page: Page):
) )
page.get_by_test_id(place_order).click() page.get_by_test_id(place_order).click()
wait_for_toast_confirmation(page) wait_for_toast_confirmation(page)
shared_vega.wait_fn(1) vega.wait_fn(1)
shared_vega.wait_for_total_catchup() vega.wait_for_total_catchup()
page.get_by_test_id("All").click() page.get_by_test_id("All").click()
page.reload()
# 7002-SORD-017 # 7002-SORD-017
expect(page.get_by_role("row").nth(4)).to_contain_text("10+10LimitFilled120.00GTT:") expect(page.get_by_role("row").nth(5)).to_contain_text("10+10LimitFilled120.00GTT:")
def test_limit_buy_order(shared_vega: VegaServiceNull, page: Page): @pytest.mark.usefixtures("auth", "risk_accepted")
page.get_by_test_id(limit_order).click() def test_limit_buy_order(continuous_market, vega: VegaServiceNull, page: Page):
page.get_by_test_id(order_side_buy).click() page.goto(f"/#/markets/{continuous_market}")
page.get_by_test_id(order_size).fill("10") page.get_by_test_id(order_size).fill("10")
page.get_by_test_id(order_price).fill("120") page.get_by_test_id(order_price).fill("120")
page.get_by_test_id(place_order).click() page.get_by_test_id(place_order).click()
wait_for_toast_confirmation(page) wait_for_toast_confirmation(page)
shared_vega.wait_fn(2) vega.wait_fn(2)
shared_vega.wait_for_total_catchup() vega.wait_for_total_catchup()
page.get_by_test_id("All").click() page.get_by_test_id("All").click()
page.reload()
# 7002-SORD-017 # 7002-SORD-017
expect(page.get_by_role("row").nth(5)).to_contain_text("10+10LimitFilled120.00GTT") expect(page.get_by_role("row").nth(6)).to_contain_text("10+10LimitFilled120.00GTC")
def test_limit_sell_order(shared_vega: VegaServiceNull, page: Page): @pytest.mark.usefixtures("auth", "risk_accepted")
page.get_by_test_id(limit_order).click() def test_limit_sell_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_size).fill("10")
page.get_by_test_id(order_price).fill("100") page.get_by_test_id(order_price).fill("100")
page.get_by_test_id(order_side_sell).click() page.get_by_test_id(order_side_sell).click()
@ -112,15 +84,15 @@ def test_limit_sell_order(shared_vega: VegaServiceNull, page: Page):
) )
page.get_by_test_id(place_order).click() page.get_by_test_id(place_order).click()
wait_for_toast_confirmation(page) wait_for_toast_confirmation(page)
shared_vega.wait_fn(1) vega.wait_fn(1)
shared_vega.wait_for_total_catchup() vega.wait_for_total_catchup()
page.get_by_test_id("All").click() page.get_by_test_id("All").click()
page.reload() expect(page.get_by_role("row").nth(7)).to_contain_text("10-10LimitFilled100.00GFN")
expect(page.get_by_role("row").nth(6)).to_contain_text("10-10LimitFilled100.00GFN")
@pytest.mark.usefixtures("auth", "risk_accepted")
def test_market_sell_order(shared_vega: VegaServiceNull, page: Page): def test_market_sell_order(continuous_market, vega: VegaServiceNull, page: Page):
page.goto(f"/#/markets/{continuous_market}")
page.get_by_test_id(market_order).click() page.get_by_test_id(market_order).click()
page.get_by_test_id(order_size).fill("10") page.get_by_test_id(order_size).fill("10")
page.get_by_test_id(order_side_sell).click() page.get_by_test_id(order_side_sell).click()
@ -133,32 +105,32 @@ def test_market_sell_order(shared_vega: VegaServiceNull, page: Page):
) )
page.get_by_test_id(place_order).click() page.get_by_test_id(place_order).click()
wait_for_toast_confirmation(page) wait_for_toast_confirmation(page)
shared_vega.wait_fn(1) vega.wait_fn(1)
shared_vega.wait_for_total_catchup() vega.wait_for_total_catchup()
page.get_by_test_id("All").click() page.get_by_test_id("All").click()
page.reload() expect(page.get_by_role("row").nth(8)).to_contain_text("10-10MarketFilled-IOC")
expect(page.get_by_role("row").nth(7)).to_contain_text("10-10MarketFilled-IOC")
def test_market_buy_order(shared_vega: VegaServiceNull, page: Page): @pytest.mark.usefixtures("auth", "risk_accepted")
def test_market_buy_order(continuous_market, vega: VegaServiceNull, page: Page):
page.goto(f"/#/markets/{continuous_market}")
page.get_by_test_id(market_order).click() page.get_by_test_id(market_order).click()
page.get_by_test_id(order_side_buy).click()
page.get_by_test_id(order_size).fill("10") page.get_by_test_id(order_size).fill("10")
page.get_by_test_id(tif).select_option("Fill or Kill (FOK)") page.get_by_test_id(tif).select_option("Fill or Kill (FOK)")
page.get_by_test_id(place_order).click() page.get_by_test_id(place_order).click()
wait_for_toast_confirmation(page) wait_for_toast_confirmation(page)
shared_vega.wait_fn(1) vega.wait_fn(1)
shared_vega.wait_for_total_catchup() vega.wait_for_total_catchup()
page.get_by_test_id("All").click() page.get_by_test_id("All").click()
page.reload()
# 7002-SORD-010 # 7002-SORD-010
# 0003-WTXN-012 # 0003-WTXN-012
# 0003-WTXN-003 # 0003-WTXN-003
expect(page.get_by_role("row").nth(8)).to_contain_text("10+10MarketFilled-FOK") 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(page: Page): 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() expect(page.get_by_test_id("deal-ticket-form")).to_be_visible()
page.get_by_test_id("Order").click() page.get_by_test_id("Order").click()
expect(page.get_by_test_id("deal-ticket-form")).not_to_be_visible() expect(page.get_by_test_id("deal-ticket-form")).not_to_be_visible()

View File

@ -1,4 +1,4 @@
""" import pytest import pytest
from playwright.sync_api import Page, expect from playwright.sync_api import Page, expect
from vega_sim.null_service import VegaServiceNull from vega_sim.null_service import VegaServiceNull
from actions.vega import submit_order from actions.vega import submit_order
@ -87,4 +87,3 @@ def test_margin_and_fees_estimations(continuous_market, vega: VegaServiceNull, p
# expect(page.get_by_test_id("toast-content")).to_contain_text( # expect(page.get_by_test_id("toast-content")).to_contain_text(
# "Your transaction has been confirmed" # "Your transaction has been confirmed"
# ) # )
"""

View File

@ -44,25 +44,25 @@ def create_position(vega: VegaServiceNull, market_id):
vega.wait_fn(1) vega.wait_fn(1)
vega.wait_for_total_catchup vega.wait_for_total_catchup
@pytest.mark.usefixtures("auth_shared_vega", "risk_accepted_shared_vega") @pytest.mark.usefixtures("auth", "risk_accepted")
def test_stop_order_form_error_validation(shared_continuous_market, page_shared_vega: Page): def test_stop_order_form_error_validation(continuous_market, page: Page):
# 7002-SORD-032 # 7002-SORD-032
page_shared_vega.goto(f"/#/markets/{shared_continuous_market}") page.goto(f"/#/markets/{continuous_market}")
page_shared_vega.get_by_test_id(stop_order_btn).click() page.get_by_test_id(stop_order_btn).click()
page_shared_vega.get_by_test_id(stop_limit_order_btn).is_visible() page.get_by_test_id(stop_limit_order_btn).is_visible()
page_shared_vega.get_by_test_id(stop_limit_order_btn).click() page.get_by_test_id(stop_limit_order_btn).click()
page_shared_vega.get_by_test_id(order_side_sell).click() page.get_by_test_id(order_side_sell).click()
page_shared_vega.get_by_test_id(submit_stop_order).click() page.get_by_test_id(submit_stop_order).click()
expect(page_shared_vega.get_by_test_id("stop-order-error-message-trigger-price")).to_have_text( expect(page.get_by_test_id("stop-order-error-message-trigger-price")).to_have_text(
"You need provide a price" "You need provide a price"
) )
expect(page_shared_vega.get_by_test_id("stop-order-error-message-size")).to_have_text( expect(page.get_by_test_id("stop-order-error-message-size")).to_have_text(
"Size cannot be lower than 1" "Size cannot be lower than 1"
) )
page_shared_vega.get_by_test_id(order_size).fill("1") page.get_by_test_id(order_size).fill("1")
page_shared_vega.get_by_test_id(order_price).fill("0.0000001") page.get_by_test_id(order_price).fill("0.0000001")
expect(page_shared_vega.get_by_test_id("stop-order-error-message-price")).to_have_text( expect(page.get_by_test_id("stop-order-error-message-price")).to_have_text(
"Price cannot be lower than 0.00001" "Price cannot be lower than 0.00001"
) )
@ -257,7 +257,7 @@ def test_submit_stop_limit_order_cancel(
).to_have_text("Cancelled") ).to_have_text("Cancelled")
""" class TestStopOcoValidation: class TestStopOcoValidation:
@pytest.fixture(scope="class") @pytest.fixture(scope="class")
def vega(request): def vega(request):
with init_vega(request) as vega_instance: with init_vega(request) as vega_instance:
@ -296,4 +296,3 @@ def test_submit_stop_limit_order_cancel(
expect(page.get_by_test_id("stop-order-warning-limit")).to_have_text( expect(page.get_by_test_id("stop-order-warning-limit")).to_have_text(
"There is a limit of 4 active stop orders per market. Orders submitted above the limit will be immediately rejected." "There is a limit of 4 active stop orders per market. Orders submitted above the limit will be immediately rejected."
) )
"""

View File

@ -1,30 +1,39 @@
import pytest import pytest
from playwright.sync_api import Page, expect, Locator from playwright.sync_api import Page, expect, Locator
from conftest import init_page, risk_accepted_setup
from conftest import init_page, init_vega, cleanup_container
@pytest.fixture(scope="module") @pytest.fixture(scope="module")
def page(shared_vega, browser, request): def vega(request):
with init_page(shared_vega, browser, request) as page: with init_vega(request) as vega_instance:
risk_accepted_setup(page) request.addfinalizer(lambda: cleanup_container(vega_instance))
page.goto("/#/disclaimer") yield vega_instance
@pytest.fixture(scope="module")
def page(vega, browser, request):
with init_page(vega, browser, request) as page:
yield page yield page
@pytest.mark.usefixtures("risk_accepted")
def test_network_switcher(page: Page): def test_network_switcher(page: Page):
page.goto("/#/disclaimer")
navbar = page.locator('nav[aria-label="Main"]') navbar = page.locator('nav[aria-label="Main"]')
assert_network_switcher(navbar) assert_network_switcher(navbar)
@pytest.mark.usefixtures("risk_accepted")
def test_navbar_pages(page: Page): def test_navbar_pages(page: Page):
page.goto("/#/disclaimer")
navbar = page.locator('nav[aria-label="Main"]') navbar = page.locator('nav[aria-label="Main"]')
assert_links(navbar) assert_links(navbar)
@pytest.mark.usefixtures("risk_accepted")
def test_navigation_mobile(page: Page): def test_navigation_mobile(page: Page):
page.goto("/#/disclaimer")
page.set_viewport_size({"width": 800, "height": 1040}) page.set_viewport_size({"width": 800, "height": 1040})
navbar = page.locator('nav[aria-label="Main"]') navbar = page.locator('nav[aria-label="Main"]')
@ -99,4 +108,4 @@ def assert_network_switcher(container: Locator):
expect(mainnet_link).to_be_visible() expect(mainnet_link).to_be_visible()
# 0006-NETW-003 # 0006-NETW-003
expect(mainnet_link).to_have_attribute("href", "https://console.vega.xyz") expect(mainnet_link).to_have_attribute("href", "https://console.vega.xyz")
expect(container.get_by_role("link", name="Fairground testnet")).to_be_visible() expect(container.get_by_role("link", name="Fairground testnet")).to_be_visible()

View File

@ -49,7 +49,7 @@ def markets(vega: VegaServiceNull):
price=130, price=130,
) )
vega.forward("5s") vega.forward("2s")
vega.wait_fn(1) vega.wait_fn(1)
vega.wait_for_total_catchup() vega.wait_for_total_catchup()
@ -63,7 +63,7 @@ def markets(vega: VegaServiceNull):
price=88, price=88,
) )
vega.forward("5s") vega.forward("2s")
vega.wait_fn(1) vega.wait_fn(1)
vega.wait_for_total_catchup() vega.wait_for_total_catchup()
@ -77,7 +77,7 @@ def markets(vega: VegaServiceNull):
price=88, price=88,
) )
vega.forward("5s") vega.forward("2s")
vega.wait_fn(1) vega.wait_fn(1)
vega.wait_for_total_catchup() vega.wait_for_total_catchup()
@ -92,7 +92,7 @@ def markets(vega: VegaServiceNull):
wait=False, wait=False,
) )
vega.forward("5s") vega.forward("2s")
vega.wait_fn(1) vega.wait_fn(1)
vega.wait_for_total_catchup() vega.wait_for_total_catchup()
@ -105,7 +105,7 @@ def markets(vega: VegaServiceNull):
volume=100, volume=100,
price=104, price=104,
) )
vega.forward("5s") vega.forward("2s")
vega.wait_fn(1) vega.wait_fn(1)
vega.wait_for_total_catchup() vega.wait_for_total_catchup()
@ -120,7 +120,7 @@ def markets(vega: VegaServiceNull):
expires_at=vega.get_blockchain_time() + 5 * 1e9, expires_at=vega.get_blockchain_time() + 5 * 1e9,
) )
vega.forward("5s") vega.forward("2s")
vega.wait_fn(1) vega.wait_fn(1)
vega.wait_for_total_catchup() vega.wait_for_total_catchup()
@ -134,7 +134,7 @@ def markets(vega: VegaServiceNull):
volume=20, volume=20,
) )
vega.forward("5s") vega.forward("2s")
vega.wait_fn(1) vega.wait_fn(1)
vega.wait_for_total_catchup() vega.wait_for_total_catchup()
@ -148,7 +148,7 @@ def markets(vega: VegaServiceNull):
volume=40, volume=40,
) )
vega.forward("5s") vega.forward("2s")
vega.wait_fn(1) vega.wait_fn(1)
vega.wait_for_total_catchup() vega.wait_for_total_catchup()
@ -162,7 +162,7 @@ def markets(vega: VegaServiceNull):
volume=60, volume=60,
) )
vega.forward("5s") vega.forward("2s")
vega.wait_fn(1) vega.wait_fn(1)
vega.wait_for_total_catchup() vega.wait_for_total_catchup()
@ -177,7 +177,7 @@ def markets(vega: VegaServiceNull):
volume=60, volume=60,
) )
vega.forward("5s") vega.forward("2s")
vega.wait_fn(1) vega.wait_fn(1)
vega.wait_for_total_catchup() vega.wait_for_total_catchup()
@ -190,7 +190,7 @@ def markets(vega: VegaServiceNull):
volume=10, volume=10,
price=150, price=150,
) )
vega.forward("5s")
vega.wait_fn(1) vega.wait_fn(1)
vega.wait_for_total_catchup() vega.wait_for_total_catchup()
@ -203,7 +203,7 @@ def markets(vega: VegaServiceNull):
volume=10, volume=10,
price=160, price=160,
) )
vega.forward("5s")
vega.wait_fn(1) vega.wait_fn(1)
vega.wait_for_total_catchup() vega.wait_for_total_catchup()
@ -216,7 +216,7 @@ def markets(vega: VegaServiceNull):
volume=10, volume=10,
price=60, price=60,
) )
vega.forward("5s")
vega.wait_fn(1) vega.wait_fn(1)
vega.wait_for_total_catchup() vega.wait_for_total_catchup()

View File

@ -1,15 +1,16 @@
import pytest import pytest
from playwright.sync_api import expect, Page from playwright.sync_api import expect, Page
from conftest import init_page, risk_accepted_setup from conftest import init_vega, cleanup_container
@pytest.fixture(scope="module") @pytest.fixture(scope="module")
def page(shared_vega, browser, request): def vega(request):
with init_page(shared_vega, browser, request) as page: with init_vega(request) as vega_instance:
risk_accepted_setup(page) request.addfinalizer(lambda: cleanup_container(vega_instance))
yield page yield vega_instance
@pytest.mark.usefixtures("risk_accepted")
def test_share_usage_data(page: Page): def test_share_usage_data(page: Page):
page.goto("/") page.goto("/")
page.get_by_test_id("Settings").click() page.get_by_test_id("Settings").click()
@ -40,6 +41,7 @@ ICON_TO_TOAST = {
} }
@pytest.mark.usefixtures("risk_accepted")
def test_toast_positions(page: Page): def test_toast_positions(page: Page):
page.goto("/") page.goto("/")
page.get_by_test_id("Settings").click() page.get_by_test_id("Settings").click()
@ -50,10 +52,10 @@ def test_toast_positions(page: Page):
expect(page.locator(f"[{toast_selector}]")).to_be_visible() expect(page.locator(f"[{toast_selector}]")).to_be_visible()
@pytest.mark.usefixtures("risk_accepted")
def test_dark_mode(page: Page): def test_dark_mode(page: Page):
page.goto("/") page.goto("/")
page.get_by_test_id("Settings").click() page.get_by_test_id("Settings").click()
expect(page.locator("html")).not_to_have_attribute("class", "dark") expect(page.locator("html")).not_to_have_attribute("class", "dark")
page.locator("#switch-settings-theme-switch").click() page.locator("#switch-settings-theme-switch").click()
expect(page.locator("html")).to_have_attribute("class", "dark") expect(page.locator("html")).to_have_attribute("class", "dark")