Files
calminer/tests/e2e/test_smoke.py
zwitschi 5b1322ddbc
Some checks failed
Run Tests / test (push) Failing after 1m51s
feat: Add application-level settings for CSS color management
- Introduced a new table `application_setting` to store configurable application options.
- Implemented functions to manage CSS color settings, including loading, updating, and reading environment overrides.
- Added a new settings view to render and manage theme colors.
- Updated UI to include a settings page with theme color management and environment overrides display.
- Enhanced CSS styles for the settings page and sidebar navigation.
- Created unit and end-to-end tests for the new settings functionality and CSS management.
2025-10-25 19:20:52 +02:00

73 lines
3.0 KiB
Python

import pytest
from playwright.sync_api import Page, expect
# A list of UI routes to check, with their URL, expected title, and a key heading text.
UI_ROUTES = [
("/", "Dashboard · CalMiner", "Operations Overview"),
("/ui/dashboard", "Dashboard · CalMiner", "Operations Overview"),
("/ui/scenarios", "Scenario Management · CalMiner", "Create a New Scenario"),
("/ui/parameters", "Process Parameters · CalMiner", "Scenario Parameters"),
("/ui/settings", "Settings · CalMiner", "Settings"),
("/ui/costs", "Costs · CalMiner", "Cost Overview"),
("/ui/consumption", "Consumption · CalMiner", "Consumption Tracking"),
("/ui/production", "Production · CalMiner", "Production Output"),
("/ui/equipment", "Equipment · CalMiner", "Equipment Inventory"),
("/ui/maintenance", "Maintenance · CalMiner", "Maintenance Schedule"),
("/ui/simulations", "Simulations · CalMiner", "Monte Carlo Simulations"),
("/ui/reporting", "Reporting · CalMiner", "Scenario KPI Summary"),
("/ui/currencies", "Currencies · CalMiner", "Currency Overview"),
]
@pytest.mark.parametrize("url, title, heading", UI_ROUTES)
def test_ui_pages_load_correctly(page: Page, url: str, title: str, heading: str):
"""Verify that all UI pages load with the correct title and a visible heading."""
page.goto(url)
expect(page).to_have_title(title)
# The app uses a mix of h1 and h2 for main page headings.
heading_locator = page.locator(
f"h1:has-text('{heading}'), h2:has-text('{heading}')")
expect(heading_locator.first).to_be_visible()
def test_settings_theme_form_interaction(page: Page):
page.goto("/ui/settings")
expect(page).to_have_title("Settings · CalMiner")
env_rows = page.locator("#theme-env-overrides tbody tr")
disabled_inputs = page.locator(
"#theme-settings-form input.color-value-input[disabled]")
env_row_count = env_rows.count()
disabled_count = disabled_inputs.count()
assert disabled_count == env_row_count
color_input = page.locator(
"#theme-settings-form input[name='--color-primary']")
expect(color_input).to_be_visible()
expect(color_input).to_be_enabled()
original_value = color_input.input_value()
candidate_values = ("#114455", "#225566")
new_value = candidate_values[0] if original_value != candidate_values[0] else candidate_values[1]
color_input.fill(new_value)
page.click("#theme-settings-form button[type='submit']")
feedback = page.locator("#theme-settings-feedback")
expect(feedback).to_contain_text("updated successfully")
computed_color = page.evaluate(
"() => getComputedStyle(document.documentElement).getPropertyValue('--color-primary').trim()"
)
assert computed_color.lower() == new_value.lower()
page.reload()
expect(color_input).to_have_value(new_value)
color_input.fill(original_value)
page.click("#theme-settings-form button[type='submit']")
expect(feedback).to_contain_text("updated successfully")
page.reload()
expect(color_input).to_have_value(original_value)