Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:

- name: Install Playwright Browsers
run: |
pipenv run playwright install --with-deps
pipenv run playwright install chromium

- name: Start Clima
run: |-
Expand Down
76 changes: 36 additions & 40 deletions tests/test_explorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,46 +12,42 @@ def setup(page: Page, base_url):
yield


# -------------------- Test Title & Section Headings --------------------
def test_explorer_titles(page: Page):
"""Check key titles and headings are visible"""
expect(page.get_by_text("Select a variable:")).to_be_visible()
expect(page.get_by_text("Yearly chart")).to_be_visible()
expect(page.get_by_text("Daily chart")).to_be_visible()
expect(page.get_by_text("Heatmap chart")).to_be_visible()
expect(page.get_by_text("Descriptive statistics")).to_be_visible()
expect(page.get_by_text("Customizable heatmap")).to_be_visible()
expect(page.get_by_text("More charts")).to_be_visible()


# -------------------- Test Section One Charts --------------------
def test_section_one_charts(page: Page):
"""Check if Section One charts render properly"""
expect(page.locator("#yearly-explore")).to_be_visible()
expect(page.locator("#query-daily")).to_be_visible()
expect(page.locator("#query-heatmap")).to_be_visible()
expect(page.locator("#table-data-explorer")).to_be_visible()


# -------------------- Test Section Two Charts --------------------
def test_section_two_charts(page: Page):
"""Ensure Section Two charts and summary elements appear"""
expect(page.locator("#custom-heatmap")).to_be_visible()


# -------------------- Test Section Three Controls --------------------
def test_section_three_controls(page: Page):
"""Check 'More charts' section inputs and controls"""
expect(page.locator("#explorer-sec3-var-x-dropdown")).to_be_visible()
expect(page.locator("#explorer-sec3-var-y-dropdown")).to_be_visible()
expect(page.locator("#explorer-sec3-colorby-dropdown")).to_be_visible()


# -------------------- Test Section Three Charts --------------------
def test_section_three_charts(page: Page):
"""Check if 2-variable and 3-variable graphs are rendered"""
expect(page.locator("#three-var")).to_be_visible()
expect(page.locator("#two-var")).to_be_visible()
# -------------------- Test Explorer Core Elements --------------------
def test_explorer_core_elements(page: Page):
"""Check key titles and section one & two charts"""
# Titles
for text in [
"Select a variable:",
"Yearly chart",
"Daily chart",
"Heatmap chart",
"Descriptive statistics",
"Customizable heatmap",
"More charts",
]:
expect(page.get_by_text(text)).to_be_visible()
# Charts
for chart in [
"#yearly-explore",
"#query-daily",
"#query-heatmap",
"#table-data-explorer",
"#custom-heatmap",
]:
expect(page.locator(chart)).to_be_visible()


# -------------------- Test Section Three --------------------
def test_explorer_section_three(page: Page):
"""Section 3 dropdowns and chart visibility"""
for selector in [
"#explorer-sec3-var-x-dropdown",
"#explorer-sec3-var-y-dropdown",
"#explorer-sec3-colorby-dropdown",
"#three-var",
"#two-var",
]:
expect(page.locator(selector)).to_be_visible()


# -------------------- Test Dropdown Interaction --------------------
Expand Down
57 changes: 27 additions & 30 deletions tests/test_natural_ventilation.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,50 +12,47 @@ def setup(page: Page, base_url):
yield


# -------------------- Test Title and Main Sections --------------------
def test_nv_title(page: Page):
"""Verify the title and main chart sections are visible"""
# -------------------- Test Core Elements --------------------
def test_nv_core_elements(page: Page):
"""Verify title, charts, filters, and switch are visible"""

# Main title and charts
expect(page.get_by_text("Natural Ventilation Potential")).to_be_visible()
expect(page.locator("#nv-heatmap-chart")).to_be_visible()
expect(page.locator("#nv-bar-chart")).to_be_visible()


# -------------------- Test Input Controls --------------------
def test_nv_input_controls(page: Page):
"""Check input controls for temperature and dew point filters"""
expect(page.locator("#nv-dbt-filter")).to_be_visible()
expect(page.locator("#nv-dpt-filter")).to_be_visible()
expect(page.locator("#nv-tdb-min-val")).to_be_visible()
expect(page.locator("#nv-tdb-max-val")).to_be_visible()
expect(page.locator("#nv-dpt-max-val")).to_be_visible()
expect(page.locator("#enable-condensation")).to_be_visible()


# -------------------- Test Normalize Switch --------------------
def test_nv_normalize_switch(page: Page):
"""Ensure normalize switch and tooltip are visible"""
# Filters and inputs
element_ids = [
"#nv-dbt-filter",
"#nv-dpt-filter",
"#nv-tdb-min-val",
"#nv-tdb-max-val",
"#nv-dpt-max-val",
"#enable-condensation",
]
for eid in element_ids:
expect(page.locator(eid)).to_be_visible()

# Switch label
expect(page.get_by_text("Normalize data")).to_be_visible()


# -------------------- Test Apply Filter Button Interaction --------------------
# -------------------- Test Filter Button Triggers Chart --------------------
def test_nv_apply_filter(page: Page):
"""Click Apply Filter and check that the heatmap updates"""
"""Click Dry Bulb filter and verify heatmap still renders"""
button = page.locator("#nv-dbt-filter")
expect(button).to_be_visible()
button.click()
expect(page.locator("#nv-heatmap-chart")).to_be_visible()


# -------------------- Test Condensation Checkbox Interaction --------------------
def test_nv_condensation_checkbox(page: Page):
"""Toggle condensation checkbox and verify dew point filter enables"""
# -------------------- Test Condensation Toggle Effect --------------------
def test_nv_condensation_checkbox_toggle(page: Page):
"""Toggling checkbox should enable/disable dew point filter"""
checkbox = page.locator("input#enable-condensation")
button = page.locator("#nv-dpt-filter")

expect(button).to_be_disabled()
dewpoint_button = page.locator("#nv-dpt-filter")

expect(dewpoint_button).to_be_disabled()
checkbox.click()
expect(button).to_be_enabled()

expect(dewpoint_button).to_be_enabled()
checkbox.click()
expect(button).to_be_disabled()
expect(dewpoint_button).to_be_disabled()
59 changes: 33 additions & 26 deletions tests/test_outdoor.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,36 +12,43 @@ def setup(page: Page, base_url):
yield


# -------------------- Test Title & Section Headings --------------------
def test_outdoor_titles(page: Page):
"""Verify key outdoor section titles are visible"""
expect(page.get_by_text("Select a scenario:")).to_be_visible()
expect(page.get_by_text("UTCI heatmap chart")).to_be_visible()
expect(page.get_by_text("UTCI thermal stress chart")).to_be_visible()
expect(page.get_by_text("Normalize data")).to_be_visible()
expect(page.get_by_text("The Best Weather Condition is:")).to_be_visible()


# -------------------- Test Image & Switch Components --------------------
def test_outdoor_image_and_switch(page: Page):
"""Verify that image and switch controls are visible"""
# -------------------- Test Outdoor Page Core Elements --------------------
def test_outdoor_core_elements(page: Page):
"""Verify core UI components (titles, image, charts) are visible"""
# Section titles
expected_texts = [
"Select a scenario:",
"UTCI heatmap chart",
"UTCI thermal stress chart",
"Normalize data",
"The Best Weather Condition is:",
]
for text in expected_texts:
expect(page.get_by_text(text)).to_be_visible()

# Image and switch
expect(page.locator("#image-selection")).to_be_visible()


# -------------------- Test Charts Rendering --------------------
def test_outdoor_charts_render(page: Page):
"""Ensure that main UTCI charts are rendered"""
expect(page.locator("#utci-heatmap")).to_be_visible()
expect(page.locator("#utci-category-heatmap")).to_be_visible()
expect(page.locator("#utci-summary-chart")).to_be_visible()
# Charts
chart_ids = [
"#utci-heatmap",
"#utci-category-heatmap",
"#utci-summary-chart",
]
for cid in chart_ids:
expect(page.locator(cid)).to_be_visible()


# -------------------- Test Dropdown Interaction --------------------
def test_dropdown_interaction(page: Page):
"""Switch scenario from dropdown and verify chart reloads"""
def test_outdoor_dropdown_interaction(page: Page):
"""Switch scenario in dropdown and verify all charts reload"""
dropdown = page.locator("#outdoor-dropdown")
dropdown.click()
page.get_by_text("UTCI: Sun & no Wind", exact=True)
expect(page.locator("#utci-heatmap")).to_be_visible()
expect(page.locator("#utci-category-heatmap")).to_be_visible()
expect(page.locator("#utci-summary-chart")).to_be_visible()
page.get_by_text("UTCI: Sun & no Wind", exact=True).click()

for chart_id in [
"#utci-heatmap",
"#utci-category-heatmap",
"#utci-summary-chart",
]:
expect(page.locator(chart_id)).to_be_visible()
23 changes: 10 additions & 13 deletions tests/test_psy-chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,28 @@ def setup(page: Page, base_url):
yield


# -------------------- Test Page Title --------------------
def test_psy_title(page: Page):
"""Check if main Psy Chart title is visible"""
# -------------------- Test Psy Page Core Elements --------------------
def test_psy_core_elements(page: Page):
"""Verify page title, controls, and chart are visible"""
# Title
expect(page.get_by_role("heading", name="Psychrometric Chart")).to_be_visible()


# -------------------- Test Dropdowns and Sliders --------------------
def test_psy_controls_visible(page: Page):
"""Check all interactive inputs are visible"""
# Controls
expect(page.locator("#psy-var-dropdown")).to_be_visible()
expect(page.locator("#psy-min-val")).to_be_visible()
expect(page.locator("#psy-max-val")).to_be_visible()
expect(page.get_by_role("button", name="Apply filter")).to_be_visible()


# -------------------- Test Psy Chart Render --------------------
def test_psy_chart_rendered(page: Page):
"""Check that the psy chart is rendered"""
# Chart
expect(page.locator("#psych-chart")).to_be_visible()


# -------------------- Test Dropdown Interaction --------------------
# -------------------- Test Interaction: Dropdown Switch --------------------
def test_dropdown_change_triggers_chart(page: Page):
"""Switch dropdown to another variable and check chart still renders"""
"""Switch dropdown to another variable and ensure chart re-renders"""
dropdown = page.locator("#psy-color-by-dropdown")
dropdown.click()
page.get_by_text("Dry bulb temperature").click()

# After dropdown change, chart should still be visible
expect(page.locator("#psych-chart")).to_be_visible()
30 changes: 14 additions & 16 deletions tests/test_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,36 +9,34 @@ def setup(page: Page, base_url):
yield


# -------------------- Test Page Load --------------------
def test_select_page_loads(page: Page):
"""Verify that the Select Weather File page loads successfully"""
# -------------------- Test Select Page Core Elements --------------------
def test_select_core_elements(page: Page):
"""Verify that the Select Weather File page loads and shows basic elements"""
# Main text and alerts
expect(page.locator("text=Select an EPW file from your computer")).to_be_visible()
expect(page.locator("#upload-data")).to_be_visible()
expect(page.locator("#alert")).to_contain_text("upload an EPW file")


# -------------------- Test Upload Button Visible --------------------
def test_upload_button_visible(page: Page):
"""Ensure the upload EPW button is visible"""
# Upload button
upload_button = page.locator("#upload-data-button")
expect(upload_button).to_be_visible()
expect(upload_button).to_contain_text("Select an EPW file")

# Upload section container
expect(page.locator("#upload-data")).to_be_visible()


# -------------------- Test Upload EPW File --------------------
def test_upload_epw_file_success(page: Page):
# -------------------- Test EPW pload and Map Rendering --------------------
def test_upload_and_map_rendering(page: Page):
"""
Simulate uploading an EPW file and verify success alert appears.
This test uses helper 'upload_epw_file' from utils.py.
Simulate uploading an EPW file, verify success message and map rendering
"""
upload_epw_file(page)

# Confirm success alert
alert_box = page.locator("#alert")
expect(alert_box).to_be_visible()
expect(alert_box).to_contain_text("EPW was successfully loaded!")


# -------------------- Test Map Renders --------------------
def test_map_renders(page: Page):
"""Verify that the map (epw_location.json plot) renders properly"""
# Map rendered after file upload
map_container = page.locator("#tab-one-map")
expect(map_container).to_be_visible()
Loading