feat: add e2e test suite with Robot Framework
Add e2e/ dir with Robot Framework tests for page loading, ban records, blocklist import, config edit. Add requirements.txt. Update Makefile with test commands. Update .gitignore, backend docs, testing requirements docs.
This commit is contained in:
2
e2e/requirements.txt
Normal file
2
e2e/requirements.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
robotframework>=7
|
||||
robotframework-browser>=18
|
||||
31
e2e/resources/auth.resource
Normal file
31
e2e/resources/auth.resource
Normal file
@@ -0,0 +1,31 @@
|
||||
*** Settings ***
|
||||
Resource ${CURDIR}/common.resource
|
||||
|
||||
*** Keywords ***
|
||||
Login As Admin
|
||||
# Check setup status.
|
||||
${response}= GET ${BACKEND_URL}/api/setup/status
|
||||
${body}= Set Variable ${response.json()}
|
||||
|
||||
IF ${body}[setup_complete] == ${false}
|
||||
# Complete the setup wizard with the dev master password ("Hallo123!").
|
||||
${password}= Set Variable Hallo123!
|
||||
${hashed}= Evaluate "sha256('${password}'.encode()).hexdigest()" modules=hashlib
|
||||
${setup_payload}= Create Dictionary password=${hashed}
|
||||
POST ${BACKEND_URL}/api/setup/complete json=${setup_payload}
|
||||
|
||||
# Retry login after setup.
|
||||
${response}= GET ${BACKEND_URL}/api/auth/login
|
||||
END
|
||||
|
||||
# Perform login.
|
||||
${password}= Set Variable Hallo123!
|
||||
${hashed}= Evaluate "sha256('${password}'.encode()).hexdigest()" modules=hashlib
|
||||
${login_payload}= Create Dictionary password=${hashed}
|
||||
${response}= POST ${BACKEND_URL}/api/auth/login json=${login_payload}
|
||||
|
||||
# Store session cookie for subsequent requests.
|
||||
${cookies}= Get Cookies
|
||||
${session_cookie}= Get Cookie Value bangui_session
|
||||
Set Browser Variables session_cookie=${session_cookie}
|
||||
Log Logged in as admin.
|
||||
25
e2e/resources/common.resource
Normal file
25
e2e/resources/common.resource
Normal file
@@ -0,0 +1,25 @@
|
||||
*** Settings ***
|
||||
Library Browser
|
||||
Library HttpLibrary
|
||||
|
||||
Variables ${CURDIR}/../../.env
|
||||
|
||||
# Health check timeout for suite setup (120 s poll interval).
|
||||
Suite Setup Wait For Backend Health timeout=120 interval=5
|
||||
|
||||
*** Variables ***
|
||||
${FRONTEND_URL} http://localhost:5173
|
||||
${BACKEND_URL} http://localhost:8000
|
||||
|
||||
*** Keywords ***
|
||||
Wait For Backend Health
|
||||
[Arguments] ${timeout}=120 ${interval}=5
|
||||
${deadline}= Evaluate time.time() + ${timeout}
|
||||
WHILE True
|
||||
${now}= Evaluate time.time()
|
||||
IF ${now} >= ${deadline} FAIL Backend did not become healthy within ${timeout} seconds
|
||||
${response}= GET ${BACKEND_URL}/api/health expected_status=200
|
||||
IF ${response.status} == 200 BREAK
|
||||
Sleep ${interval}
|
||||
END
|
||||
Log Backend is healthy.
|
||||
13
e2e/tests/01_page_loading.robot
Normal file
13
e2e/tests/01_page_loading.robot
Normal file
@@ -0,0 +1,13 @@
|
||||
*** Settings ***
|
||||
Resource ${CURDIR}/../../resources/common.resource
|
||||
|
||||
*** Test Cases ***
|
||||
Page Loads And Shows Navigation
|
||||
New Browser chromium headless=${TRUE}
|
||||
New Page ${FRONTEND_URL}
|
||||
|
||||
# Confirm the page title or root element is present.
|
||||
${title}= Get Title
|
||||
Should Not Be Empty ${title}
|
||||
|
||||
Close Browser
|
||||
16
e2e/tests/02_ban_records.robot
Normal file
16
e2e/tests/02_ban_records.robot
Normal file
@@ -0,0 +1,16 @@
|
||||
*** Settings ***
|
||||
Resource ${CURDIR}/../../resources/common.resource
|
||||
Resource ${CURDIR}/../../resources/auth.resource
|
||||
|
||||
*** Test Cases ***
|
||||
Ban Records Are Visible
|
||||
New Browser chromium headless=${TRUE}
|
||||
Login As Admin
|
||||
|
||||
Go To ${FRONTEND_URL}/bans
|
||||
|
||||
# Basic presence check — the ban table or empty state should be present.
|
||||
${content}= Get Page Source
|
||||
Should Not Be Empty ${content}
|
||||
|
||||
Close Browser
|
||||
15
e2e/tests/03_blocklist_import.robot
Normal file
15
e2e/tests/03_blocklist_import.robot
Normal file
@@ -0,0 +1,15 @@
|
||||
*** Settings ***
|
||||
Resource ${CURDIR}/../../resources/common.resource
|
||||
Resource ${CURDIR}/../../resources/auth.resource
|
||||
|
||||
*** Test Cases ***
|
||||
Blocklist Import Page Opens
|
||||
New Browser chromium headless=${TRUE}
|
||||
Login As Admin
|
||||
|
||||
Go To ${FRONTEND_URL}/blocklists
|
||||
|
||||
${content}= Get Page Source
|
||||
Should Not Be Empty ${content}
|
||||
|
||||
Close Browser
|
||||
15
e2e/tests/04_config_edit.robot
Normal file
15
e2e/tests/04_config_edit.robot
Normal file
@@ -0,0 +1,15 @@
|
||||
*** Settings ***
|
||||
Resource ${CURDIR}/../../resources/common.resource
|
||||
Resource ${CURDIR}/../../resources/auth.resource
|
||||
|
||||
*** Test Cases ***
|
||||
Config Edit Page Opens
|
||||
New Browser chromium headless=${TRUE}
|
||||
Login As Admin
|
||||
|
||||
Go To ${FRONTEND_URL}/config
|
||||
|
||||
${content}= Get Page Source
|
||||
Should Not Be Empty ${content}
|
||||
|
||||
Close Browser
|
||||
Reference in New Issue
Block a user