From 3596bc4fcaba8b06c011083b8cf8cdd239cecc20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pasternak?= Date: Mon, 4 May 2026 09:58:23 +0200 Subject: [PATCH 1/2] perf(tests): remove unnecessary fixed delays in playwright_util.py - Remove delay=50 from press_sequentially() - no longer needed - Change wait_for_timeout(50) to wait_for_timeout(0) - wait for next event loop tick instead - Change wait_for_timeout(100) to wait_for_timeout(0) - wait for next event loop tick instead These delays were historical band-aids that accumulated across multiple Select2 interactions in Playwright tests. Modern event-driven waiting strategies make them unnecessary. Zero-timer waits still allow the JavaScript event loop to process pending microtasks, which is what the original waits were trying to accomplish. Co-Authored-By: Claude Sonnet 4.6 --- src/django_bpp/playwright_util.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/django_bpp/playwright_util.py b/src/django_bpp/playwright_util.py index 274dc5373..16a2389ff 100644 --- a/src/django_bpp/playwright_util.py +++ b/src/django_bpp/playwright_util.py @@ -88,7 +88,7 @@ def select_select2_autocomplete( # Type the search term using pressSequentially to trigger AJAX search search_input = page.locator(".select2-search__field") - search_input.press_sequentially(value, delay=50) + search_input.press_sequentially(value) # Wait for AJAX search to complete by checking for loading indicators to disappear # Polish text "Trwa wyszukiwanie…" or "Trwa ładowanie…" indicates loading @@ -130,11 +130,11 @@ def select_select2_autocomplete( timeout=timeout, ) else: - # No event-driven signal available — small polishing wait so the - # next interaction starts after Select2's internal change handlers - # finish (jQuery 'change' listeners run synchronously, but custom - # widgets may queue setTimeout(0) callbacks). - page.wait_for_timeout(50) + # No event-driven signal available — wait for next event loop tick + # so Select2's internal change handlers finish (jQuery 'change' + # listeners run synchronously, but custom widgets may queue + # setTimeout(0) callbacks). + page.wait_for_timeout(0) def close_all_select2_dropdowns(page: Page): @@ -150,7 +150,7 @@ def close_all_select2_dropdowns(page: Page): } }""" ) - page.wait_for_timeout(100) + page.wait_for_timeout(0) def proper_click_element(page: Page, selector: str): From e8359a5d9df05f08281968a71a23eab38222c406 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Pasternak?= Date: Mon, 4 May 2026 10:12:05 +0200 Subject: [PATCH 2/2] refactor: remove dead code pbn_integrator/core/__init__.py Remove 149 lines of stub functions with time.sleep() calls that are shadowing working implementations in: - pbn_integrator/importer/ (importuj_zrodla, importuj_publikacje_*) - import_common/core/uczelnia.py (matchuj_uczelnie) Nothing imports from this module - it's leftover placeholder code from the initial pbn_integrator implementation that was never cleaned up. Co-Authored-By: Claude Sonnet 4.6 --- src/pbn_integrator/core/__init__.py | 148 ---------------------------- 1 file changed, 148 deletions(-) delete mode 100644 src/pbn_integrator/core/__init__.py diff --git a/src/pbn_integrator/core/__init__.py b/src/pbn_integrator/core/__init__.py deleted file mode 100644 index e1aeb79bd..000000000 --- a/src/pbn_integrator/core/__init__.py +++ /dev/null @@ -1,148 +0,0 @@ -"""Core PBN integrator functions""" - -import time - - -def matchuj_uczelnie(uczelnia): - """Match university with PBN""" - # This would normally call the actual API - # For now, we'll simulate it - - # Check if we have PBN UID already - if uczelnia.pbn_uid_id: - return {"matched": True, "uid": uczelnia.pbn_uid_id} - - # Try to match by name/REGON - # In real implementation, this would call PBN API - time.sleep(1) # Simulate API call - - # For demo, let's just return success - return {"matched": True, "uid": "demo-uid"} - - -def importuj_initial( - uczelnia=None, wydzial_domyslny=None, delete_existing=False, progress_callback=None -): - """Import initial configuration""" - if progress_callback: - progress_callback(0) - - # Simulate some work - for i in range(0, 101, 20): - time.sleep(0.5) - if progress_callback: - progress_callback(i) - - return {"imported": 5, "failed": 0} - - -def importuj_zrodla( - uczelnia=None, wydzial_domyslny=None, delete_existing=False, progress_callback=None -): - """Import journals""" - if progress_callback: - progress_callback(0) - - # Simulate fetching and importing journals - for i in range(0, 101, 10): - time.sleep(0.3) - if progress_callback: - progress_callback(i) - - return {"imported": 150, "failed": 2} - - -def importuj_wydawcy( - uczelnia=None, wydzial_domyslny=None, delete_existing=False, progress_callback=None -): - """Import publishers""" - if progress_callback: - progress_callback(0) - - # Simulate work - for i in range(0, 101, 25): - time.sleep(0.2) - if progress_callback: - progress_callback(i) - - return {"imported": 45, "failed": 0} - - -def importuj_konferencje( - uczelnia=None, wydzial_domyslny=None, delete_existing=False, progress_callback=None -): - """Import conferences""" - if progress_callback: - progress_callback(0) - - # Simulate work - for i in range(0, 101, 20): - time.sleep(0.15) - if progress_callback: - progress_callback(i) - - return {"imported": 78, "failed": 1} - - -def importuj_autorzy( - uczelnia=None, wydzial_domyslny=None, delete_existing=False, progress_callback=None -): - """Import authors""" - if progress_callback: - progress_callback(0) - - # Simulate importing authors - this would be slower - for i in range(0, 101, 5): - time.sleep(0.2) - if progress_callback: - progress_callback(i) - - return {"imported": 234, "failed": 5} - - -def importuj_publikacje( - uczelnia=None, wydzial_domyslny=None, delete_existing=False, progress_callback=None -): - """Import publications""" - if progress_callback: - progress_callback(0) - - # This is usually the longest step - for i in range(0, 101, 2): - time.sleep(0.1) - if progress_callback: - progress_callback(i) - - return {"imported": 1523, "failed": 12} - - -def importuj_oswiadczenia( - uczelnia=None, wydzial_domyslny=None, delete_existing=False, progress_callback=None -): - """Import statements""" - if progress_callback: - progress_callback(0) - - # Simulate work - for i in range(0, 101, 10): - time.sleep(0.1) - if progress_callback: - progress_callback(i) - - return {"imported": 567, "failed": 3} - - -def importuj_oplaty( - uczelnia=None, wydzial_domyslny=None, delete_existing=False, progress_callback=None -): - """Import fees""" - if progress_callback: - progress_callback(0) - - # Simulate work - for i in range(0, 101, 20): - time.sleep(0.1) - if progress_callback: - progress_callback(i) - - return {"imported": 89, "failed": 0}