feat(BT-001A): add backtest scenario runner page

This commit is contained in:
Bu5hm4nn
2026-03-24 19:00:22 +01:00
parent 8566cc203f
commit d2d85bccdb
6 changed files with 467 additions and 3 deletions

View File

@@ -14,7 +14,7 @@ def test_homepage_and_options_page_render() -> None:
browser = p.chromium.launch(headless=True)
page = browser.new_page(viewport={"width": 1440, "height": 1000})
page.goto(BASE_URL, wait_until="networkidle", timeout=30000)
page.goto(BASE_URL, wait_until="domcontentloaded", timeout=30000)
expect(page).to_have_title("NiceGUI")
expect(page.locator("text=Vault Dashboard").first).to_be_visible(timeout=10000)
expect(page.locator("text=Overview").first).to_be_visible(timeout=10000)
@@ -22,6 +22,28 @@ def test_homepage_and_options_page_render() -> None:
expect(page.locator("text=Alert Status").first).to_be_visible(timeout=15000)
page.screenshot(path=str(ARTIFACTS / "overview.png"), full_page=True)
page.goto(f"{BASE_URL}/backtests", wait_until="networkidle", timeout=30000)
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)
expect(page.locator("text=Daily Results").first).to_be_visible(timeout=15000)
backtests_text = page.locator("body").inner_text(timeout=15000)
assert "Auto-derived entry spot: $100.00" in backtests_text
assert "RuntimeError" not in backtests_text
assert "Server error" not in backtests_text
assert "Traceback" not in backtests_text
page.screenshot(path=str(ARTIFACTS / "backtests.png"), full_page=True)
page.get_by_label("Template").click()
page.get_by_text("Protective Put 95%", exact=True).click()
page.get_by_role("button", name="Run backtest").click()
expect(page.locator("text=Scenario Summary").first).to_be_visible(timeout=15000)
expect(page.locator("text=Template: Protective Put 95%").first).to_be_visible(timeout=15000)
rerun_text = page.locator("body").inner_text(timeout=15000)
assert "Margin call days hedged" in rerun_text
assert "RuntimeError" not in rerun_text
assert "Server error" not in rerun_text
page.goto(f"{BASE_URL}/options", wait_until="domcontentloaded", timeout=30000)
expect(page.locator("text=Options Chain").first).to_be_visible(timeout=15000)
expect(page.locator("text=Filters").first).to_be_visible(timeout=15000)