Enhance testing framework and UI feedback
- Updated architecture documentation to include details on UI rendering checks and Playwright end-to-end tests. - Revised testing documentation to specify Playwright for frontend E2E tests and added details on running tests. - Implemented feedback mechanism in scenario form for successful creation notifications. - Added feedback div in ScenarioForm.html for user notifications. - Created new fixtures for Playwright tests to manage server and browser instances. - Developed comprehensive E2E tests for consumption, costs, equipment, maintenance, production, and scenarios. - Added smoke tests to verify UI page loading and form submissions. - Enhanced unit tests for simulation and validation, including new tests for report generation and validation errors. - Created new test files for router validation to ensure consistent error handling. - Established a new test suite for UI routes to validate dashboard and reporting functionalities. - Implemented validation tests to ensure proper handling of JSON payloads.
This commit is contained in:
52
tests/e2e/test_maintenance.py
Normal file
52
tests/e2e/test_maintenance.py
Normal file
@@ -0,0 +1,52 @@
|
||||
from uuid import uuid4
|
||||
|
||||
from playwright.sync_api import Page, expect
|
||||
|
||||
|
||||
def test_maintenance_form_loads(page: Page):
|
||||
"""Verify the maintenance form page loads correctly."""
|
||||
page.goto("/ui/maintenance")
|
||||
expect(page).to_have_title("CalMiner Maintenance")
|
||||
expect(page.locator("h1")).to_have_text("Maintenance")
|
||||
|
||||
|
||||
def test_create_maintenance_item(page: Page):
|
||||
"""Test creating a new maintenance item through the UI."""
|
||||
# First, create a scenario and an equipment item.
|
||||
page.goto("/ui/scenarios")
|
||||
scenario_name = f"Maintenance Test Scenario {uuid4()}"
|
||||
page.fill("input[name='name']", scenario_name)
|
||||
page.click("button[type='submit']")
|
||||
with page.expect_response("**/api/scenarios/"):
|
||||
pass
|
||||
|
||||
page.goto("/ui/equipment")
|
||||
equipment_name = f"Excavator EX-12 {uuid4()}"
|
||||
page.select_option("select[name='scenario_id']", label=scenario_name)
|
||||
page.fill("input[name='name']", equipment_name)
|
||||
page.click("button[type='submit']")
|
||||
with page.expect_response("**/api/equipment/"):
|
||||
pass
|
||||
|
||||
# Now, navigate to the maintenance page and add an item.
|
||||
page.goto("/ui/maintenance")
|
||||
|
||||
# Create a maintenance item.
|
||||
maintenance_desc = "Scheduled engine overhaul"
|
||||
page.select_option("select[name='scenario_id']", label=scenario_name)
|
||||
page.select_option("select[name='equipment_id']", label=equipment_name)
|
||||
page.fill("input[name='maintenance_date']", "2025-12-01")
|
||||
page.fill("textarea[name='description']", maintenance_desc)
|
||||
page.fill("input[name='cost']", "12000")
|
||||
page.click("button[type='submit']")
|
||||
|
||||
with page.expect_response("**/api/maintenance/") as response_info:
|
||||
pass
|
||||
assert response_info.value.status == 201
|
||||
|
||||
# Verify the new item appears in the table.
|
||||
expect(page.locator(f"tr:has-text('{maintenance_desc}')")).to_be_visible()
|
||||
|
||||
# Verify the feedback message.
|
||||
expect(page.locator("#maintenance-feedback")
|
||||
).to_have_text("Maintenance entry saved.")
|
||||
Reference in New Issue
Block a user