feat: Enhance end-to-end testing framework with improved server setup and UI validation

This commit is contained in:
2025-10-21 09:04:06 +02:00
parent f020d276bc
commit 9114b584c2
11 changed files with 138 additions and 71 deletions

View File

@@ -6,8 +6,8 @@ from playwright.sync_api import Page, expect
def test_production_form_loads(page: Page):
"""Verify the production form page loads correctly."""
page.goto("/ui/production")
expect(page).to_have_title("CalMiner Production")
expect(page.locator("h1")).to_have_text("Production")
expect(page).to_have_title("Production · CalMiner")
expect(page.locator("h2:has-text('Add Production Output')")).to_be_visible()
def test_create_production_item(page: Page):
@@ -25,9 +25,9 @@ def test_create_production_item(page: Page):
# Create a production item.
production_desc = "Ore extracted - Grade A"
page.select_option("select[name='scenario_id']", label=scenario_name)
page.fill("input[name='description']", production_desc)
page.fill("input[name='amount']", "1500")
page.select_option("#production-form-scenario", label=scenario_name)
page.fill("#production-form-description", production_desc)
page.fill("#production-form-amount", "1500")
page.click("button[type='submit']")
with page.expect_response("**/api/production/") as response_info:
@@ -35,7 +35,12 @@ def test_create_production_item(page: Page):
assert response_info.value.status == 201
# Verify the new item appears in the table.
expect(page.locator(f"tr:has-text('{production_desc}')")).to_be_visible()
page.select_option("#production-scenario-filter", label=scenario_name)
expect(
page.locator("#production-table-body tr").filter(
has_text=production_desc
)
).to_be_visible()
# Verify the feedback message.
expect(page.locator("#production-feedback")