Refactor test cases for improved readability and consistency
- Updated test functions in various test files to enhance code clarity by formatting long lines and improving indentation. - Adjusted assertions to use multi-line formatting for better readability. - Added new test cases for theme settings API to ensure proper functionality. - Ensured consistent use of line breaks and spacing across test files for uniformity.
This commit is contained in:
@@ -5,7 +5,11 @@ from playwright.sync_api import Page, expect
|
||||
UI_ROUTES = [
|
||||
("/", "Dashboard · CalMiner", "Operations Overview"),
|
||||
("/ui/dashboard", "Dashboard · CalMiner", "Operations Overview"),
|
||||
("/ui/scenarios", "Scenario Management · CalMiner", "Create a New Scenario"),
|
||||
(
|
||||
"/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"),
|
||||
@@ -20,35 +24,44 @@ UI_ROUTES = [
|
||||
|
||||
|
||||
@pytest.mark.parametrize("url, title, heading", UI_ROUTES)
|
||||
def test_ui_pages_load_correctly(page: Page, url: str, title: str, heading: str):
|
||||
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}')")
|
||||
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")
|
||||
page.goto("/theme-settings")
|
||||
expect(page).to_have_title("Theme Settings · CalMiner")
|
||||
|
||||
env_rows = page.locator("#theme-env-overrides tbody tr")
|
||||
disabled_inputs = page.locator(
|
||||
"#theme-settings-form input.color-value-input[disabled]")
|
||||
"#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']")
|
||||
"#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]
|
||||
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']")
|
||||
|
||||
Reference in New Issue
Block a user