feat(PORT-004C): seed workspace routes from portfolio settings

This commit is contained in:
Bu5hm4nn
2026-03-24 21:14:09 +01:00
parent 2cbe4f274d
commit 5ac66ea97b
8 changed files with 350 additions and 51 deletions

View File

@@ -36,6 +36,7 @@ def test_homepage_and_options_page_render() -> None:
expect(page.locator("text=Alert Status").first).to_be_visible(timeout=15000)
page.goto(f"{BASE_URL}/backtests", wait_until="networkidle", timeout=30000)
page.wait_for_url(f"{workspace_url}/backtests", timeout=15000)
expect(page.locator("text=Backtests").first).to_be_visible(timeout=15000)
expect(page.locator("text=Scenario Form").first).to_be_visible(timeout=15000)
expect(page.locator("text=Scenario Summary").first).to_be_visible(timeout=15000)
@@ -58,6 +59,7 @@ def test_homepage_and_options_page_render() -> None:
assert "Server error" not in rerun_text
page.goto(f"{BASE_URL}/event-comparison", wait_until="networkidle", timeout=30000)
page.wait_for_url(f"{workspace_url}/event-comparison", timeout=15000)
expect(page.locator("text=Event Comparison").first).to_be_visible(timeout=15000)
expect(page.locator("text=Comparison Form").first).to_be_visible(timeout=15000)
expect(page.locator("text=Ranked Results").first).to_be_visible(timeout=15000)
@@ -102,6 +104,8 @@ def test_homepage_and_options_page_render() -> None:
page.get_by_text("Gold weight + entry price", exact=True).click()
page.get_by_label("Entry price ($/oz)").fill("4400")
page.get_by_label("Gold weight (oz)").fill("220")
page.get_by_label("Loan amount ($)").fill("222000")
page.get_by_label("Margin call LTV threshold").fill("0.8")
budget_input = page.get_by_label("Monthly hedge budget ($)")
budget_input.fill("12345")
page.get_by_role("button", name="Save settings").click()
@@ -109,11 +113,30 @@ def test_homepage_and_options_page_render() -> None:
page.reload(wait_until="domcontentloaded", timeout=30000)
expect(page.get_by_label("Monthly hedge budget ($)")).to_have_value("12345")
expect(page.get_by_label("Entry price ($/oz)")).to_have_value("4400")
expect(page.get_by_label("Loan amount ($)")).to_have_value("222000")
expect(page.get_by_label("Margin call LTV threshold")).to_have_value("0.8")
settings_text = page.locator("body").inner_text(timeout=15000)
assert "RuntimeError" not in settings_text
assert "Server error" not in settings_text
page.screenshot(path=str(ARTIFACTS / "settings.png"), full_page=True)
page.goto(f"{workspace_url}/backtests", wait_until="networkidle", timeout=30000)
expect(page.get_by_label("Underlying units")).to_have_value("9680")
expect(page.get_by_label("Loan amount")).to_have_value("222000")
expect(page.get_by_label("Margin call LTV")).to_have_value("0.8")
backtests_workspace_text = page.locator("body").inner_text(timeout=15000)
assert "Scenario Summary" in backtests_workspace_text
assert "$968,000" in backtests_workspace_text
page.goto(f"{workspace_url}/event-comparison", wait_until="networkidle", timeout=30000)
expect(page.get_by_label("Underlying units")).to_have_value("9680")
expect(page.get_by_label("Loan amount")).to_have_value("222000")
expect(page.get_by_label("Margin call LTV")).to_have_value("0.8")
event_workspace_text = page.locator("body").inner_text(timeout=15000)
assert "$222,000" in event_workspace_text
assert "9,680" in event_workspace_text
assert "80.0%" in event_workspace_text
page.goto(workspace_url, wait_until="domcontentloaded", timeout=30000)
overview_text = page.locator("body").inner_text(timeout=15000)
assert "Hedge Analysis" in overview_text
@@ -121,9 +144,14 @@ def test_homepage_and_options_page_render() -> None:
assert "Backtests" in overview_text
assert "Event Comparison" in overview_text
assert "Live quote source: configured entry price fallback" in overview_text
assert "$878.79" in overview_text
assert "$1,261.36" in overview_text
assert "$968,000.00" in overview_text
assert "$823,000.00" in overview_text
assert "$746,000.00" in overview_text
expect(page.get_by_role("link", name="Hedge Analysis")).to_have_attribute("href", f"/{workspace_id}/hedge")
expect(page.get_by_role("link", name="Backtests")).to_have_attribute("href", f"/{workspace_id}/backtests")
expect(page.get_by_role("link", name="Event Comparison")).to_have_attribute(
"href", f"/{workspace_id}/event-comparison"
)
second_context = browser.new_context(viewport={"width": 1440, "height": 1000})
second_page = second_context.new_page()
@@ -139,6 +167,7 @@ def test_homepage_and_options_page_render() -> None:
second_context.close()
page.goto(f"{BASE_URL}/hedge", wait_until="domcontentloaded", timeout=30000)
page.wait_for_url(f"{workspace_url}/hedge", timeout=15000)
expect(page.locator("text=Hedge Analysis").first).to_be_visible(timeout=15000)
expect(page.locator("text=Strategy selector").first).to_be_visible(timeout=15000)
expect(page.locator("text=Strategy Controls").first).to_be_visible(timeout=15000)
@@ -156,13 +185,16 @@ def test_homepage_and_options_page_render() -> None:
assert "Start value" in hedge_text
assert "Start price" in hedge_text
assert "Weight" in hedge_text
assert "$215,000" in hedge_text
assert "$215.00/oz" in hedge_text
assert "1,000 oz" in hedge_text
assert "Loan amount" in hedge_text
assert "Monthly hedge budget" in hedge_text
assert "$968,000" in hedge_text
assert "$4,400.00/oz" in hedge_text
assert "220 oz" in hedge_text
assert "$222,000" in hedge_text
assert "80.0%" in hedge_text
assert "$12,345" in hedge_text
assert "Unhedged equity" in hedge_text
assert "Hedged equity" in hedge_text
assert "$27,000" in hedge_text
assert "$58,750" in hedge_text
page.screenshot(path=str(ARTIFACTS / "hedge.png"), full_page=True)
browser.close()