Spaces:
Paused
Paused
| """E2E tests for complete assessment workflow.""" | |
| import pytest | |
| from playwright.sync_api import Page, expect | |
| def select_sample(page: Page, sample_text: str): | |
| """Helper to select a sample from the dropdown.""" | |
| page.locator("#sample_dropdown input[role='listbox']").click() | |
| page.wait_for_timeout(300) | |
| page.locator(f"[role='option']:has-text('{sample_text}')").click() | |
| # Wait for form to be populated - check that project_name has a value | |
| # (status gets cleared when dropdown resets, so we can't rely on it) | |
| page.wait_for_function( | |
| """() => { | |
| const textarea = document.querySelector('#project_name textarea'); | |
| return textarea && textarea.value && textarea.value.includes('Sample:'); | |
| }""", | |
| timeout=30000 | |
| ) | |
| class TestFullWorkflow: | |
| """Test complete assessment generation workflow.""" | |
| def test_generate_with_sample(self, page: Page): | |
| """Test full generation workflow with sample data.""" | |
| select_sample(page, "Bar & Dining Area") | |
| # Navigate to Results tab | |
| page.locator("#tab-results-button").click() | |
| page.wait_for_timeout(500) | |
| # Check preflight shows ready | |
| expect(page.locator("#preflight_status")).to_contain_text("Ready to Generate") | |
| # Click generate | |
| page.locator("#generate_btn").click() | |
| # Wait for generation - check for "Complete" in the status textbox input | |
| # The processing_status is a Textbox, so we need to check the input value | |
| page.wait_for_function( | |
| """() => { | |
| const input = document.querySelector('#processing_status input, #processing_status textarea'); | |
| return input && input.value && input.value.includes('Complete'); | |
| }""", | |
| timeout=120000 | |
| ) | |
| # Verify outputs are visible | |
| expect(page.locator("#sow_output")).to_be_visible() | |
| expect(page.locator("#download_md")).to_be_visible() | |
| def test_preflight_check_incomplete_session(self, page: Page): | |
| """Test preflight shows errors for incomplete session.""" | |
| # Don't load sample - go directly to Results | |
| page.locator("#tab-results-button").click() | |
| page.wait_for_timeout(500) | |
| # Should show cannot generate message | |
| expect(page.locator("#preflight_status")).to_contain_text("Cannot Generate") | |
| class TestTabNavigation: | |
| """Test tab navigation and validation.""" | |
| def test_click_tab_navigation(self, page: Page): | |
| """Test clicking tab buttons navigates correctly.""" | |
| # Start on Tab 1 (Project) | |
| expect(page.locator("#project_name")).to_be_visible() | |
| # Click Tab 2 (Rooms) | |
| page.locator("#tab-rooms-button").click() | |
| page.wait_for_timeout(300) | |
| expect(page.locator("#room_name")).to_be_visible() | |
| # Click Tab 3 (Images) | |
| page.locator("#tab-images-button").click() | |
| page.wait_for_timeout(300) | |
| expect(page.locator("#image_upload")).to_be_visible() | |
| # Click Tab 4 (Observations) | |
| page.locator("#tab-observations-button").click() | |
| page.wait_for_timeout(300) | |
| expect(page.locator("#smoke_odor")).to_be_visible() | |
| # Click Tab 5 (Results) | |
| page.locator("#tab-results-button").click() | |
| page.wait_for_timeout(300) | |
| expect(page.locator("#generate_btn")).to_be_visible() | |
| def test_keyboard_shortcuts(self, page: Page): | |
| """Test Ctrl+1-5 keyboard shortcuts.""" | |
| # Start on Tab 1 | |
| expect(page.locator("#project_name")).to_be_visible() | |
| # Ctrl+3 -> Images tab | |
| page.keyboard.press("Control+3") | |
| page.wait_for_timeout(300) | |
| expect(page.locator("#image_upload")).to_be_visible() | |
| # Ctrl+5 -> Results tab | |
| page.keyboard.press("Control+5") | |
| page.wait_for_timeout(300) | |
| expect(page.locator("#generate_btn")).to_be_visible() | |
| # Ctrl+1 -> Back to Project | |
| page.keyboard.press("Control+1") | |
| page.wait_for_timeout(300) | |
| expect(page.locator("#project_name")).to_be_visible() | |
| def test_tab1_validation_prevents_navigation(self, page: Page): | |
| """Test that incomplete Tab 1 shows validation errors.""" | |
| # Try to validate empty Tab 1 | |
| page.get_by_role("button", name="Validate & Continue to Rooms").click() | |
| page.wait_for_timeout(500) | |
| # Should show validation error message with required field errors | |
| validation = page.locator("#tab1_validation") | |
| expect(validation).to_contain_text("Please fix the following") | |
| class TestBackNavigation: | |
| """Test back button navigation.""" | |
| def test_back_from_rooms_to_project(self, page: Page): | |
| """Test back button from Rooms tab.""" | |
| # Go to Rooms tab | |
| page.locator("#tab-rooms-button").click() | |
| page.wait_for_timeout(300) | |
| # Click back | |
| page.get_by_role("button", name="Back to Project").click() | |
| page.wait_for_timeout(300) | |
| # Should be on Project tab | |
| expect(page.locator("#project_name")).to_be_visible() | |
| def test_back_from_images_to_rooms(self, page: Page): | |
| """Test back button from Images tab.""" | |
| # Go to Images tab | |
| page.locator("#tab-images-button").click() | |
| page.wait_for_timeout(300) | |
| # Click back | |
| page.get_by_role("button", name="Back to Rooms").click() | |
| page.wait_for_timeout(300) | |
| # Should be on Rooms tab | |
| expect(page.locator("#room_name")).to_be_visible() | |