feat: Enhance end-to-end testing framework with improved server setup and UI validation
This commit is contained in:
@@ -6,8 +6,8 @@ from playwright.sync_api import Page, expect
|
||||
def test_consumption_form_loads(page: Page):
|
||||
"""Verify the consumption form page loads correctly."""
|
||||
page.goto("/ui/consumption")
|
||||
expect(page).to_have_title("CalMiner Consumption")
|
||||
expect(page.locator("h1")).to_have_text("Consumption")
|
||||
expect(page).to_have_title("Consumption · CalMiner")
|
||||
expect(page.locator("h2:has-text('Add Consumption Record')")).to_be_visible()
|
||||
|
||||
|
||||
def test_create_consumption_item(page: Page):
|
||||
@@ -25,8 +25,8 @@ def test_create_consumption_item(page: Page):
|
||||
|
||||
# Create a consumption item.
|
||||
consumption_desc = "Diesel for generators"
|
||||
page.select_option("select[name='scenario_id']", label=scenario_name)
|
||||
page.fill("input[name='description']", consumption_desc)
|
||||
page.select_option("#consumption-form-scenario", label=scenario_name)
|
||||
page.fill("textarea[name='description']", consumption_desc)
|
||||
page.fill("input[name='amount']", "5000")
|
||||
page.click("button[type='submit']")
|
||||
|
||||
@@ -35,8 +35,14 @@ def test_create_consumption_item(page: Page):
|
||||
assert response_info.value.status == 201
|
||||
|
||||
# Verify the new item appears in the table.
|
||||
expect(page.locator(f"tr:has-text('{consumption_desc}')")).to_be_visible()
|
||||
page.select_option("#consumption-scenario-filter", label=scenario_name)
|
||||
expect(
|
||||
page.locator("#consumption-table-body tr").filter(
|
||||
has_text=consumption_desc
|
||||
)
|
||||
).to_be_visible()
|
||||
|
||||
# Verify the feedback message.
|
||||
expect(page.locator("#consumption-feedback")
|
||||
).to_have_text("Consumption record saved.")
|
||||
expect(page.locator("#consumption-feedback")).to_have_text(
|
||||
"Consumption record saved."
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user