"""E2E: Missing SKUs page with resolved toggle and multi-CODMAT modal.""" import pytest from playwright.sync_api import Page, expect pytestmark = pytest.mark.e2e @pytest.fixture(autouse=True) def navigate_to_missing(page: Page, app_url: str): page.goto(f"{app_url}/missing-skus") page.wait_for_load_state("networkidle") def test_missing_skus_page_loads(page: Page): """Verify the page renders with the correct heading.""" expect(page.locator("h4")).to_contain_text("SKU-uri Lipsa") def test_resolved_toggle_buttons(page: Page): """R10: Verify resolved filter pills exist and 'unresolved' is active by default.""" unresolved = page.locator(".filter-pill[data-sku-status='unresolved']") resolved = page.locator(".filter-pill[data-sku-status='resolved']") all_btn = page.locator(".filter-pill[data-sku-status='all']") expect(unresolved).to_be_attached() expect(resolved).to_be_attached() expect(all_btn).to_be_attached() # Unresolved should be active by default classes = unresolved.get_attribute("class") assert "active" in classes, f"Expected unresolved pill to be active, got classes: {classes}" def test_resolved_toggle_switches(page: Page): """R10: Clicking resolved/all toggles changes active state correctly.""" resolved = page.locator(".filter-pill[data-sku-status='resolved']") unresolved = page.locator(".filter-pill[data-sku-status='unresolved']") all_btn = page.locator(".filter-pill[data-sku-status='all']") # Click "Rezolvate" resolved.click() page.wait_for_timeout(500) classes_res = resolved.get_attribute("class") assert "active" in classes_res, f"Expected resolved pill to be active, got: {classes_res}" classes_unr = unresolved.get_attribute("class") assert "active" not in classes_unr, f"Expected unresolved pill to be inactive, got: {classes_unr}" # Click "Toate" all_btn.click() page.wait_for_timeout(500) classes_all = all_btn.get_attribute("class") assert "active" in classes_all, f"Expected all pill to be active, got: {classes_all}" def test_quick_map_modal_multi_codmat(page: Page): """R11: Verify the quick mapping modal supports multiple CODMATs.""" modal = page.locator("#quickMapModal") expect(modal).to_be_attached() expect(page.locator("#qmSku")).to_be_attached() expect(page.locator("#qmProductName")).to_be_attached() expect(page.locator("#qmCodmatLines")).to_be_attached() expect(page.locator("#qmPctWarning")).to_be_attached() def test_export_csv_button(page: Page): """Verify Export CSV button is visible on the page.""" btn = page.locator("button", has_text="Export CSV") expect(btn).to_be_visible() def test_rescan_button(page: Page): """Verify Re-Scan button is visible on the page.""" btn = page.locator("#rescanBtn") expect(btn).to_be_visible()