"""E2E: Missing SKUs page with resolved toggle and multi-CODMAT modal.""" import pytest from playwright.sync_api import Page, expect @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 buttons exist and Nerezolvate is active by default.""" expect(page.locator("#btnUnresolved")).to_be_visible() expect(page.locator("#btnResolved")).to_be_visible() expect(page.locator("#btnAll")).to_be_visible() classes = page.locator("#btnUnresolved").get_attribute("class") assert "btn-primary" in classes, f"Expected #btnUnresolved to be active (btn-primary), got classes: {classes}" def test_resolved_toggle_switches(page: Page): """R10: Clicking resolved/all toggles changes active state correctly.""" # Click "Rezolvate" page.locator("#btnResolved").click() page.wait_for_timeout(500) classes_res = page.locator("#btnResolved").get_attribute("class") assert "btn-success" in classes_res, f"Expected #btnResolved to be active (btn-success), got: {classes_res}" classes_unr = page.locator("#btnUnresolved").get_attribute("class") assert "btn-outline" in classes_unr, f"Expected #btnUnresolved to be outline after deactivation, got: {classes_unr}" # Click "Toate" page.locator("#btnAll").click() page.wait_for_timeout(500) classes_all = page.locator("#btnAll").get_attribute("class") assert "btn-secondary" in classes_all, f"Expected #btnAll to be active (btn-secondary), got: {classes_all}" def test_map_modal_multi_codmat(page: Page): """R11: Verify the mapping modal supports multiple CODMATs.""" modal = page.locator("#mapModal") expect(modal).to_be_attached() add_btn = page.locator("#mapModal button", has_text="Adauga CODMAT") expect(add_btn).to_be_attached() expect(page.locator("#mapProductName")).to_be_attached() expect(page.locator("#mapPctWarning")).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("button", has_text="Re-Scan") expect(btn).to_be_visible()