chore(trading): add cross isolated margin info test (#5786)
Co-authored-by: Ben <ben@vega.xyz>
This commit is contained in:
parent
fea97aac19
commit
4ad1a47ded
@ -9,6 +9,16 @@ leverage_input = "#leverage-input"
|
|||||||
tab_positions = "tab-positions"
|
tab_positions = "tab-positions"
|
||||||
margin_row = '[col-id="margin"]'
|
margin_row = '[col-id="margin"]'
|
||||||
|
|
||||||
|
current_margin = "deal-ticket-fee-current-margin"
|
||||||
|
available_collateral = "deal-ticket-fee-available-collateral"
|
||||||
|
additional_margin_required = "deal-ticket-fee-additional-margin-required"
|
||||||
|
liquidation_estimate = "deal-ticket-fee-liquidation-estimate"
|
||||||
|
dialog_content = "dialog-content"
|
||||||
|
cross_margin = "cross-margin"
|
||||||
|
isolated_margin = "isolated-margin"
|
||||||
|
confirm_cross_margin_mode = "confirm-cross-margin-mode"
|
||||||
|
confirm_isolated_margin_mode = "confirm-isolated-margin-mode"
|
||||||
|
|
||||||
|
|
||||||
def create_position(vega: VegaServiceNull, market_id):
|
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_SELL", 100, 110)
|
||||||
@ -29,10 +39,9 @@ def test_switch_cross_isolated_margin(
|
|||||||
expect(page.get_by_test_id(tooltip_content).nth(0)).to_have_text(
|
expect(page.get_by_test_id(tooltip_content).nth(0)).to_have_text(
|
||||||
"Liquidation: 582.81328Margin: 874.21992General account: 998,084.95183"
|
"Liquidation: 582.81328Margin: 874.21992General account: 998,084.95183"
|
||||||
)
|
)
|
||||||
page.get_by_role("button", name="Isolated 10x").click()
|
page.get_by_test_id(isolated_margin).click()
|
||||||
page.locator(leverage_input).clear()
|
page.locator(leverage_input).fill("1")
|
||||||
page.locator(leverage_input).type("1")
|
page.get_by_test_id(confirm_isolated_margin_mode).click()
|
||||||
page.get_by_role("button", name="Confirm").click()
|
|
||||||
wait_for_toast_confirmation(page)
|
wait_for_toast_confirmation(page)
|
||||||
next_epoch(vega=vega)
|
next_epoch(vega=vega)
|
||||||
expect(page.get_by_test_id("toast-content")).to_have_text(
|
expect(page.get_by_test_id("toast-content")).to_have_text(
|
||||||
@ -45,9 +54,52 @@ def test_switch_cross_isolated_margin(
|
|||||||
expect(page.get_by_test_id(tooltip_content).nth(0)).to_have_text(
|
expect(page.get_by_test_id(tooltip_content).nth(0)).to_have_text(
|
||||||
"Liquidation: 583.62409Margin: 11,109.99996Order: 11,000.00"
|
"Liquidation: 583.62409Margin: 11,109.99996Order: 11,000.00"
|
||||||
)
|
)
|
||||||
page.get_by_role("button", name="Cross").click()
|
page.get_by_test_id(cross_margin).click()
|
||||||
page.get_by_role("button", name="Confirm").click()
|
page.get_by_test_id(confirm_cross_margin_mode).click()
|
||||||
wait_for_toast_confirmation(page)
|
wait_for_toast_confirmation(page)
|
||||||
next_epoch(vega=vega)
|
next_epoch(vega=vega)
|
||||||
expect(page.locator(margin_row).nth(1)).to_have_text(
|
expect(page.locator(margin_row).nth(1)).to_have_text(
|
||||||
"22,109.99996Cross1.0x")
|
"22,109.99996Cross1.0x")
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.usefixtures("auth", "risk_accepted")
|
||||||
|
def test_check_cross_isolated_margin_info(
|
||||||
|
continuous_market, vega: VegaServiceNull, page: Page):
|
||||||
|
create_position(vega, continuous_market)
|
||||||
|
page.goto(f"/#/markets/{continuous_market}")
|
||||||
|
expect(page.get_by_test_id(current_margin)).to_have_text(
|
||||||
|
"Current margin874.21992 tDAI")
|
||||||
|
expect(page.get_by_test_id(available_collateral)
|
||||||
|
).to_have_text("Available collateral998,084.95183 tDAI")
|
||||||
|
expect(page.get_by_test_id(additional_margin_required)
|
||||||
|
).to_have_text("Additional margin required0.00 tDAI")
|
||||||
|
expect(page.get_by_test_id(liquidation_estimate)
|
||||||
|
).to_have_text("Liquidation estimate- BTC")
|
||||||
|
page.get_by_test_id(isolated_margin).click()
|
||||||
|
page.locator(leverage_input).fill("6")
|
||||||
|
expect(page.get_by_test_id(dialog_content).get_by_test_id("notification")).to_have_text(
|
||||||
|
"You have an existing position and and open order on this market.Changing the margin mode and leverage will move 2,703.11341 tDAI from your general account to fund the position.")
|
||||||
|
expect(page.get_by_test_id(dialog_content).get_by_test_id(current_margin)).to_have_text(
|
||||||
|
"Current margin874.21992 tDAI")
|
||||||
|
expect(page.get_by_test_id(dialog_content).get_by_test_id(available_collateral)
|
||||||
|
).to_have_text("Available collateral998,084.95183 tDAI")
|
||||||
|
expect(page.get_by_test_id(dialog_content).get_by_test_id(additional_margin_required)
|
||||||
|
).to_have_text("Additional margin required2,703.11341 tDAI")
|
||||||
|
expect(page.get_by_test_id(dialog_content).get_by_test_id(liquidation_estimate)
|
||||||
|
).to_have_text("Liquidation estimate95.23553 BTC")
|
||||||
|
page.get_by_test_id(confirm_isolated_margin_mode).click()
|
||||||
|
wait_for_toast_confirmation(page)
|
||||||
|
next_epoch(vega=vega)
|
||||||
|
expect(page.get_by_test_id("toast-content")).to_have_text(
|
||||||
|
"ConfirmedYour transaction has been confirmedView in block explorerUpdate margin modeBTC:DAI_2023Isolated margin mode, leverage: 6.0x")
|
||||||
|
page.get_by_test_id(cross_margin).click()
|
||||||
|
expect(page.get_by_test_id(dialog_content).get_by_test_id(
|
||||||
|
"notification")).not_to_be_visible()
|
||||||
|
expect(page.get_by_test_id(dialog_content).get_by_test_id(current_margin)).to_have_text(
|
||||||
|
"Current margin4,223.33332 tDAI")
|
||||||
|
expect(page.get_by_test_id(dialog_content).get_by_test_id(available_collateral)
|
||||||
|
).to_have_text("Available collateral995,381.83843 tDAI")
|
||||||
|
expect(page.get_by_test_id(dialog_content).get_by_test_id(additional_margin_required)
|
||||||
|
).to_have_text("Additional margin required0.00 tDAI")
|
||||||
|
expect(page.get_by_test_id(dialog_content).get_by_test_id(liquidation_estimate)
|
||||||
|
).to_have_text("Liquidation estimate0.00 BTC")
|
||||||
|
@ -222,6 +222,7 @@ const CrossMarginModeDialog = ({
|
|||||||
<NoWalletWarning noWalletConnected={!partyId} isReadOnly={isReadOnly} />
|
<NoWalletWarning noWalletConnected={!partyId} isReadOnly={isReadOnly} />
|
||||||
<Button
|
<Button
|
||||||
className="w-full"
|
className="w-full"
|
||||||
|
data-testid="confirm-cross-margin-mode"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
partyId &&
|
partyId &&
|
||||||
!isReadOnly &&
|
!isReadOnly &&
|
||||||
@ -329,7 +330,11 @@ const IsolatedMarginModeDialog = ({
|
|||||||
marginFactor={`${1 / leverage}`}
|
marginFactor={`${1 / leverage}`}
|
||||||
/>
|
/>
|
||||||
<NoWalletWarning noWalletConnected={!partyId} isReadOnly={isReadOnly} />
|
<NoWalletWarning noWalletConnected={!partyId} isReadOnly={isReadOnly} />
|
||||||
<Button className="w-full" type="submit">
|
<Button
|
||||||
|
className="w-full"
|
||||||
|
type="submit"
|
||||||
|
data-testid="confirm-isolated-margin-mode"
|
||||||
|
>
|
||||||
{t('Confirm')}
|
{t('Confirm')}
|
||||||
</Button>
|
</Button>
|
||||||
</form>
|
</form>
|
||||||
@ -363,6 +368,7 @@ export const MarginModeSelector = ({ marketId }: { marketId: string }) => {
|
|||||||
<div className="mb-4 grid h-8 leading-8 font-alpha text-xs grid-cols-2">
|
<div className="mb-4 grid h-8 leading-8 font-alpha text-xs grid-cols-2">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
|
data-testid="cross-margin"
|
||||||
onClick={() => setDialog('cross')}
|
onClick={() => setDialog('cross')}
|
||||||
className={classnames('rounded', {
|
className={classnames('rounded', {
|
||||||
[enabledModeClassName]:
|
[enabledModeClassName]:
|
||||||
@ -374,6 +380,7 @@ export const MarginModeSelector = ({ marketId }: { marketId: string }) => {
|
|||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
|
data-testid="isolated-margin"
|
||||||
onClick={() => setDialog('isolated')}
|
onClick={() => setDialog('isolated')}
|
||||||
className={classnames('rounded', {
|
className={classnames('rounded', {
|
||||||
[enabledModeClassName]:
|
[enabledModeClassName]:
|
||||||
|
Loading…
Reference in New Issue
Block a user