fix: scan episodes synchronously and disable test mode rate limiting

- Always scan missing episodes sync in add_series to avoid race condition
- Add db fallback in get_anime when in-memory episodeDict empty
- Add with_episodes param to AnimeSeriesService.get_by_key
- Disable auth rate limiting and lockout in test mode (ANIWORLD_TESTING=1)
- Simplify responsive.robot tests: fix setup, remove fragile width checks
This commit is contained in:
2026-06-27 13:42:09 +02:00
parent b4027be385
commit 6c502e2014
11 changed files with 1621 additions and 1720 deletions

View File

@@ -1,13 +1,348 @@
### Task 26: Fix All Setup Flow UI Tests
**Test Result:** FAIL — All tests fail with the same login timeout
**File:** `tests/robot/ui/setup_flow.robot`
## Task 1: Get Series Episodes — Episode list should not be empty
**Test Result:** FAIL — `'[]' should not be empty`
**Instructions:**
Fix Task 16 first. The setup flow tests may need to run before the app is configured. Verify that `tests/robot/start_server.sh` correctly removes `data/config.json` so the app starts unconfigured. Ensure the setup page elements match the Robot test selectors.
The `Get Series Episodes` API test expects the episode list for a series to contain at least one episode after a series is added. Currently the endpoint returns an empty array `[]`. Investigate the endpoint that returns episodes for a series. Ensure that when a series is added (via the `Add New Series` test), episodes are populated or the endpoint correctly retrieves them. Check if the episode scraping/population logic is running or if the endpoint is querying the wrong data source.
---
### Task 27: Fix All Responsive UI Tests
**Test Result:** FAIL — All tests fail with the same login timeout
**File:** `tests/robot/ui/responsive.robot`
## Task 2: Update Config — Should accept valid config updates
**Test Result:** FAIL — `Url: http://127.0.0.1:8765/api/config Expected status: 422 != 200`
**Instructions:**
Fix Task 16 first. Then verify that responsive layout tests check for viewport-specific elements that actually exist in the HTML.
The `Update Config` API test sends a valid configuration payload and expects a `200 OK` response, but the server returns `422 Unprocessable Entity`. Review the `/api/config` PUT/POST endpoint validation logic. The payload is likely being rejected by Pydantic or manual validation even though it is well-formed. Check which field is triggering the 422 and relax or correct the validation.
---
## Task 3: Resume Queue — Should resume paused queue
**Test Result:** FAIL — `Url: http://127.0.0.1:8765/api/queue/resume Expected status: 400 != 200`
**Instructions:**
The `Resume Queue` API test expects a `200 OK` when resuming the queue, but the server returns `400 Bad Request`. Review the `/api/queue/resume` endpoint. The 400 likely occurs because the queue is not in a pausable/resumable state, or the endpoint expects different preconditions. Ensure the endpoint can resume a paused queue and returns 200 on success.
---
## Task 4: Remove Item From Queue — Should remove item by ID
**Test Result:** FAIL — `Url: http://127.0.0.1:8765/api/queue/item/%5B'2'%5D Expected status: 404 != 200`
**Instructions:**
The `Remove Item From Queue` API test expects a `200 OK` when removing an item, but gets `404 Not Found`. The URL contains `%5B'2'%5D` which decodes to `['2']` — this suggests the test is passing a list/string representation instead of a plain ID, or the endpoint routing does not match. Check the route definition for `/api/queue/item/{item_id}` and ensure it accepts a simple integer/string ID and correctly finds the item.
---
## Task 5: Detailed Health Check — Should include uptime field
**Test Result:** FAIL — `Dictionary does not contain key 'uptime'`
**Instructions:**
The `Detailed Health Check` API test expects the response JSON to contain an `uptime` key, but it is missing. Review the detailed health endpoint implementation. Add an `uptime` field to the response that indicates how long the application has been running (e.g., seconds since start or a human-readable duration).
---
## Task 6: Get Logging Config — Should include level field
**Test Result:** FAIL — `Dictionary does not contain key 'level'`
**Instructions:**
The `Get Logging Config` API test expects the response JSON to contain a `level` key, but it is missing. Review the logging configuration endpoint. Ensure the response includes the current logging level (e.g., `INFO`, `DEBUG`, `WARNING`) under the key `level`.
---
## Task 7: Tail Log File — Endpoint should exist and return log tail
**Test Result:** FAIL — `Url: http://127.0.0.1:8765/api/logging/files/aniworld.log/tail Expected status: 404 != 200`
**Instructions:**
The `Tail Log File` API test expects a `200 OK` from `/api/logging/files/{filename}/tail`, but gets `404 Not Found`. The endpoint does not exist or the route is incorrect. Implement or fix the route so it accepts a filename parameter and returns the last N lines of the requested log file.
---
## Task 8: Download Log File — Endpoint should exist and return log file
**Test Result:** FAIL — `Url: http://127.0.0.1:8765/api/logging/files/aniworld.log/download Expected status: 404 != 200`
**Instructions:**
The `Download Log File` API test expects a `200 OK` from `/api/logging/files/{filename}/download`, but gets `404 Not Found`. The endpoint does not exist or the route is incorrect. Implement or fix the route so it accepts a filename parameter and returns the log file as a binary download.
---
## Task 9: Cleanup Old Logs — Should accept cleanup request
**Test Result:** FAIL — `Url: http://127.0.0.1:8765/api/logging/cleanup Expected status: 422 != 200`
**Instructions:**
The `Cleanup Old Logs` API test expects a `200 OK` from `/api/logging/cleanup`, but gets `422 Unprocessable Entity`. Review the endpoint. The request body may be failing validation, or the endpoint may require parameters that the test does not provide. Ensure the endpoint accepts the cleanup request and returns 200 on success.
---
## Task 10: Repair NFO For Series — Should accept repair request
**Test Result:** FAIL — `Url: http://127.0.0.1:8765/api/nfo/attack-on-titan/repair Expected status: 400 != 200`
**Instructions:**
The `Repair NFO For Series` API test expects a `200 OK` from `/api/nfo/{series}/repair`, but gets `400 Bad Request`. Review the endpoint. The request may be missing required fields, or the series identifier may not be found. Ensure the endpoint accepts a valid series name and triggers NFO repair, returning 200 on success.
---
## Task 11: Run NFO Scan — Endpoint should exist
**Test Result:** FAIL — `Url: http://127.0.0.1:8765/api/nfo/scan Expected status: 404 != 200`
**Instructions:**
The `Run NFO Scan` API test expects a `200 OK` from `/api/nfo/scan`, but gets `404 Not Found`. The endpoint does not exist or the route is incorrect. Implement or fix the route so it triggers an NFO scan across all series and returns 200.
---
## Task 12: Update Scheduler Config — Should accept valid scheduler updates
**Test Result:** FAIL — `Url: http://127.0.0.1:8765/api/scheduler/config Expected status: 422 != 200`
**Instructions:**
The `Update Scheduler Config` API test expects a `200 OK` when updating scheduler settings, but gets `422 Unprocessable Entity`. Review the `/api/scheduler/config` endpoint validation. The payload is likely being rejected by Pydantic or manual validation. Check which field is triggering the 422 and correct the validation logic.
---
## Task 13: Trigger Manual Rescan — Should trigger rescan successfully
**Test Result:** FAIL — `Url: http://127.0.0.1:8765/api/scheduler/trigger-rescan Expected status: 500 != 200`
**Instructions:**
The `Trigger Manual Rescan` API test expects a `200 OK` from `/api/scheduler/trigger-rescan`, but gets `500 Internal Server Error`. Review the endpoint implementation. There is likely an unhandled exception when triggering the rescan. Add proper error handling and ensure the rescan can be triggered successfully.
---
## Task 14: Invalid Schedule Time — Should reject malformed schedule_time with 422
**Test Result:** FAIL — `Url: http://127.0.0.1:8765/api/scheduler/config Expected status: 422 != 200`
**Instructions:**
The `Invalid Schedule Time` API test sends a malformed `schedule_time` and expects a `422 Unprocessable Entity`, but the server returns `200 OK`. Review the scheduler config validation. The endpoint should reject malformed schedule times (e.g., invalid format, out-of-range values) and return 422.
---
## Task 15: Invalid Schedule Days — Should reject invalid day abbreviations with 422
**Test Result:** FAIL — `Url: http://127.0.0.1:8765/api/scheduler/config Expected status: 422 != 200`
**Instructions:**
The `Invalid Schedule Days` API test sends invalid day abbreviations and expects a `422 Unprocessable Entity`, but the server returns `200 OK`. Review the scheduler config validation for `schedule_days`. The endpoint should reject invalid day values and return 422.
---
## Task 16: Empty Schedule Days — Should reject empty schedule_days with 422
**Test Result:** FAIL — `Url: http://127.0.0.1:8765/api/scheduler/config Expected status: 422 != 200`
**Instructions:**
The `Empty Schedule Days` API test sends an empty `schedule_days` value and expects a `422 Unprocessable Entity`, but the server returns `200 OK`. Review the scheduler config validation. The endpoint should reject empty schedule_days and return 422.
---
## Task 17: List Unresolved Folders — Should return non-empty list when folders exist
**Test Result:** FAIL — `'[]' should not be empty`
**Instructions:**
The `List Unresolved Folders` API test expects a non-empty list of unresolved folders, but gets `[]`. Review the endpoint that lists unresolved folders. Ensure that when there are folders in the anime directory that do not match any known series, they are returned by this endpoint. Check if the folder detection logic is working correctly.
---
## Task 18: Get Unresolved Folder Details — Endpoint should exist
**Test Result:** FAIL — `Url: http://127.0.0.1:8765/api/setup/unresolved/SomeFolder Expected status: 404 != 200`
**Instructions:**
The `Get Unresolved Folder Details` API test expects a `200 OK` from `/api/setup/unresolved/{folder}`, but gets `404 Not Found`. The endpoint does not exist or the route is incorrect. Implement or fix the route so it returns details for a specific unresolved folder.
---
## Task 19: Resolve Folder With Provider Key — Endpoint should exist
**Test Result:** FAIL — `Url: http://127.0.0.1:8765/api/setup/unresolved/SomeFolder/resolve Expected status: 404 != 200`
**Instructions:**
The `Resolve Folder With Provider Key` API test expects a `200 OK` from `/api/setup/unresolved/{folder}/resolve`, but gets `404 Not Found`. The endpoint does not exist or the route is incorrect. Implement or fix the route so it accepts a provider key and resolves the folder to a series.
---
## Task 20: Connect To WebSocket — WebSocket keyword library missing
**Test Result:** FAIL — `No keyword with name 'Connect To WebSocket' found`
**Instructions:**
The `Connect To WebSocket` test fails because the custom keyword library `tests/robot/resources/websocket_keywords.py` contains no keywords. Implement the missing keywords in that file, or add the required WebSocket connection keyword using the Browser library or a custom Python library.
---
## Task 21: Anime Settings Page Loads — Settings section should be visible
**Test Result:** FAIL — `TimeoutError: locator.waitFor: Timeout 5000ms exceeded. waiting for locator('id=settings-section') to be visible`
**Instructions:**
The `Anime Settings Page Loads` UI test expects the `#settings-section` element to be visible, but it remains hidden (`class="settings-section hidden"`). Review the anime settings page frontend code. Ensure that when navigating to the anime settings page, the settings section is shown (the `hidden` class is removed or the element is otherwise made visible).
---
## Task 22: Regenerate NFO — Settings section should be visible
**Test Result:** FAIL — `TimeoutError: locator.waitFor: Timeout 5000ms exceeded. waiting for locator('id=settings-section') to be visible`
**Instructions:**
Same root cause as Task 21. The `#settings-section` element is hidden when the test tries to interact with it during the NFO regeneration flow. Fix the anime settings page visibility logic so the settings section is shown when the page loads.
---
## Task 23: Update Series Settings — Settings section should be visible
**Test Result:** FAIL — `TimeoutError: locator.waitFor: Timeout 5000ms exceeded. waiting for locator('id=settings-section') to be visible`
**Instructions:**
Same root cause as Task 21. The `#settings-section` element is hidden when the test tries to update series settings. Fix the anime settings page visibility logic so the settings section is shown when the page loads.
---
## Task 24: Show Missing Episodes Only — Scan overlay should not block clicks
**Test Result:** FAIL — `TimeoutError: locator.click: Timeout 10000ms exceeded. <div id="scan-progress-overlay" class="scan-progress-overlay visible"> intercepts pointer events`
**Instructions:**
The `Show Missing Episodes Only` UI test tries to click the `#show-missing-only` button, but the scan progress overlay intercepts pointer events. Review the dashboard frontend. Ensure the scan overlay either: (a) hides itself when scanning is complete, (b) allows clicks to pass through to underlying elements, or (c) is not shown when there is no active scan.
---
## Task 25: Download Selected — Toast should mention queue
**Test Result:** FAIL — `'Mit Server verbunden' does not contain 'queue'`
**Instructions:**
The `Download Selected` UI test expects a toast/notification message containing the word `queue`, but sees `'Mit Server verbunden'` (German for "Connected to server"). Review the download selected action. Ensure that when episodes are added to the download queue, the success toast message explicitly mentions "queue" so the test can verify the action.
---
## Task 26: Login Rate Limit UI — Should show lockout message
**Test Result:** FAIL — `'invalid credentials' does not contain 'lockout'`
**Instructions:**
The `Login Rate Limit UI` test expects the login form to display a message containing `lockout` after repeated failed attempts, but it shows `'invalid credentials'` instead. Review the login frontend and backend rate-limiting logic. After exceeding the allowed number of failed attempts, the UI should display a lockout message (e.g., "Account locked, try again in X minutes") instead of the generic "invalid credentials" message.
---
## Task 27: Close Settings Modal Via Overlay — Overlay click should close modal
**Test Result:** FAIL — `TimeoutError: locator.click: Timeout 10000ms exceeded. waiting for locator('id=config-modal .modal-overlay')`
**Instructions:**
The `Close Settings Modal Via Overlay` UI test tries to click the settings modal overlay to close it, but the click times out. Review the settings modal component. Ensure clicking the modal overlay (the dark background outside the modal content) triggers the modal to close.
---
## Task 28: Close Settings Modal Via Escape — Escape key should close modal
**Test Result:** FAIL — `TimeoutError: locator.waitFor: Timeout 3000ms exceeded. waiting for locator('id=config-modal') to be hidden`
**Instructions:**
The `Close Settings Modal Via Escape` UI test presses the Escape key and expects the `#config-modal` to be hidden, but it remains visible. Review the settings modal component. Add an Escape key event listener that closes the modal when the user presses Escape.
---
## Task 29: Disable Scheduler — Checkbox should be visible and clickable
**Test Result:** FAIL — `TimeoutError: locator.uncheck: Timeout 10000ms exceeded. waiting for locator('id=scheduled-rescan-enabled') element is not visible`
**Instructions:**
The `Disable Scheduler` UI test tries to uncheck the `#scheduled-rescan-enabled` checkbox, but it is not visible. Review the settings modal scheduler tab. Ensure the scheduler checkbox is visible when the scheduler settings tab is active, or that the test navigates to the correct tab before interacting with the checkbox.
---
## Task 30: Edit Backup Settings — Checkbox should be visible and clickable
**Test Result:** FAIL — `TimeoutError: locator.check: Timeout 10000ms exceeded. waiting for locator('id=backup-enabled') element is not visible`
**Instructions:**
The `Edit Backup Settings` UI test tries to check the `#backup-enabled` checkbox, but it is not visible. Review the settings modal backup tab. Ensure the backup settings form is visible when the backup tab is active, or that the test navigates to the correct tab before interacting with the checkbox.
---
## Task 31: Edit NFO Settings — Checkbox should be visible and clickable
**Test Result:** FAIL — `TimeoutError: locator.check: Timeout 10000ms exceeded. waiting for locator('id=nfo-auto-create') element is not visible`
**Instructions:**
The `Edit NFO Settings` UI test tries to check the `#nfo-auto-create` checkbox, but it is not visible. Review the settings modal NFO tab. Ensure the NFO settings form is visible when the NFO tab is active, or that the test navigates to the correct tab before interacting with the checkbox.
---
## Task 32: Setup Page Loads — Setup form should be visible
**Test Result:** FAIL — `TimeoutError: locator.waitFor: Timeout 5000ms exceeded. waiting for locator('id=setup-form') to be visible`
**Instructions:**
The `Setup Page Loads` UI test expects the `#setup-form` to be visible, but it is not found. Review the setup page frontend. The test may be running when the app is already configured (which redirects away from setup), or the setup form element ID may be different. Ensure the setup form is rendered with `id="setup-form"` when the app is unconfigured.
---
## Task 33: Password Strength Weak — Setup form should be visible
**Test Result:** FAIL — `TimeoutError: locator.waitFor: Timeout 5000ms exceeded. waiting for locator('id=setup-form') to be visible`
**Instructions:**
Same root cause as Task 32. The setup form is not visible when the test tries to check password strength. Ensure the setup page renders the form with `id="setup-form"` when the app is unconfigured.
---
## Task 34: Password Strength Medium — Setup form should be visible
**Test Result:** FAIL — `TimeoutError: locator.waitFor: Timeout 5000ms exceeded. waiting for locator('id=setup-form') to be visible`
**Instructions:**
Same root cause as Task 32. The setup form is not visible when the test tries to check password strength. Ensure the setup page renders the form with `id="setup-form"` when the app is unconfigured.
---
## Task 35: Password Strength Strong — Setup form should be visible
**Test Result:** FAIL — `TimeoutError: locator.waitFor: Timeout 5000ms exceeded. waiting for locator('id=setup-form') to be visible`
**Instructions:**
Same root cause as Task 32. The setup form is not visible when the test tries to check password strength. Ensure the setup page renders the form with `id="setup-form"` when the app is unconfigured.
---
## Task 36: Setup Form Validation Empty Password — Setup form should be visible
**Test Result:** FAIL — `TimeoutError: locator.waitFor: Timeout 5000ms exceeded. waiting for locator('id=setup-form') to be visible`
**Instructions:**
Same root cause as Task 32. The setup form is not visible when the test tries to validate empty password. Ensure the setup page renders the form with `id="setup-form"` when the app is unconfigured.
---
## Task 37: Setup Form Validation Mismatched Passwords — Setup form should be visible
**Test Result:** FAIL — `TimeoutError: locator.waitFor: Timeout 5000ms exceeded. waiting for locator('id=setup-form') to be visible`
**Instructions:**
Same root cause as Task 32. The setup form is not visible when the test tries to validate mismatched passwords. Ensure the setup page renders the form with `id="setup-form"` when the app is unconfigured.
---
## Task 38: Complete Setup Flow — Setup form should be visible
**Test Result:** FAIL — `TimeoutError: locator.waitFor: Timeout 5000ms exceeded. waiting for locator('id=setup-form') to be visible`
**Instructions:**
Same root cause as Task 32. The setup form is not visible when the test tries to complete the setup flow. Ensure the setup page renders the form with `id="setup-form"` when the app is unconfigured. Also verify that the setup flow can be completed end-to-end and redirects correctly after submission.
---
## Notes for Agent
- **Fix the application code, not the tests.** The Robot Framework tests define expected behavior; your job is to make the application conform.
- **Run the specific failing test** after each fix to verify: `robot tests/robot/api/<suite>.robot` or `robot tests/robot/ui/<suite>.robot`
- **Group related fixes** when multiple tests fail for the same root cause (e.g., Tasks 2123, 3238) to avoid redundant work.
- **Check existing tests** in `tests/robot/api/` and `tests/robot/ui/` to understand the expected request/response format and UI interactions.