fix(e2e): resolve blocklist import test failures

auth.resource:
- add Login Via HTTP keyword for RequestsLibrary auth (CSRF-aware)
- fix session_duration_minutes type: bare int → ${60}
- add Process library import to common.resource

03_blocklist_import.robot:
- fix selector to button[data-testid] (was matching all buttons)
- use GET/POST On Session with auth session for blocklist API calls
- fix log response key: entries → items
- fix enabled=true → ${TRUE} for boolean type
- fix ${len(sources)} → Get Length keyword
- make Ensure Blocklist Source Exists accept session argument
- replace strict error assertion with specific error banner check
- add graceful Terminate Process teardown

02_ban_records.robot:
- add Process library import

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-08 08:07:39 +02:00
parent e4c3ae718c
commit aa717a28f8
4 changed files with 81 additions and 35 deletions

View File

@@ -1,4 +1,16 @@
*** Keywords ***
Login Via HTTP
[Documentation] Login via HTTP and store session cookie for RequestsLibrary.
... Call this before any RequestsLibrary keyword that needs auth.
${headers}= Create Dictionary X-BanGUI-Request 1
Create Session bangsess ${BACKEND_URL} headers=${headers}
${login_payload}= Create Dictionary password Hallo123!
${login_resp}= POST On Session bangsess /api/v1/auth/login
... json=${login_payload}
... expected_status=200
Log HTTP login done. cookies=${login_resp.cookies}
RETURN bangsess
Login As Admin
[Documentation] Creates a new context and page and logs in via UI.
... Caller should NOT call New Context/New Page before this.
@@ -14,7 +26,7 @@ Login As Admin
... database_path=bangui.db
... fail2ban_socket=/var/run/fail2ban/fail2ban.sock
... timezone=UTC
... session_duration_minutes=60
... session_duration_minutes=${60}
POST ${BACKEND_URL}/api/v1/setup json=${setup_payload}
Log Setup POST completed.
END
@@ -25,6 +37,9 @@ Login As Admin
Go To ${FRONTEND_URL}
Wait For Load State domcontentloaded
# Wait for React to fully initialize before login attempt
Sleep 5s
# Use fetch to call login API with browser credentials so the session cookie
# gets stored in the browser context. Use relative URL so Vite proxy handles it.
${login_result}= Evaluate JavaScript ${None}
@@ -46,6 +61,12 @@ Login As Admin
... }
Log API login result: ${login_result}
# Check if login actually succeeded before marking as authenticated
${login_ok}= Set Variable ${login_result}[ok]
IF not ${login_ok}
Fatal Error Login API failed: ${login_result}
END
# Set sessionStorage so AuthProvider considers us authenticated without waiting
# for API re-validation on the next navigation.
Evaluate JavaScript ${None} () => sessionStorage.setItem('bangui_authenticated', 'true')