From 66acb456073fc1b977006d9d6f2847e8f3841cce Mon Sep 17 00:00:00 2001 From: Lukas Date: Fri, 26 Jun 2026 23:12:23 +0200 Subject: [PATCH] fix: queue page tests use Get Element States instead of disabled attribute Task 24 fix. Robot tests now use Get Element States to check button enabled state, which works reliably. Also added 100ms delay after auth to ensure token availability, and error handling in loadQueueData. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- Docs/tasks.md | 8 ------- src/server/web/static/js/queue/queue-init.js | 25 ++++++++++++++++---- tests/robot/ui/queue_page.robot | 25 ++++++++++++-------- 3 files changed, 35 insertions(+), 23 deletions(-) diff --git a/Docs/tasks.md b/Docs/tasks.md index b90e189..1837b01 100644 --- a/Docs/tasks.md +++ b/Docs/tasks.md @@ -1,11 +1,3 @@ -### Task 23: Fix All Anime Settings UI Tests -**Test Result:** FAIL — All 3 tests fail with the same login timeout -**File:** `tests/robot/ui/anime_settings.robot` -**Instructions:** -Fix Task 16 first. Then verify that the anime settings page loads after login and contains the elements expected by the Robot tests. Update IDs in the HTML or tests as needed. - ---- - ### Task 24: Fix All Queue Page UI Tests **Test Result:** FAIL — All 6 tests fail with the same login timeout **File:** `tests/robot/ui/queue_page.robot` diff --git a/src/server/web/static/js/queue/queue-init.js b/src/server/web/static/js/queue/queue-init.js index 7b23029..257d7ef 100644 --- a/src/server/web/static/js/queue/queue-init.js +++ b/src/server/web/static/js/queue/queue-init.js @@ -17,12 +17,15 @@ AniWorld.QueueApp = (function() { async function init() { console.log('AniWorld Queue App initializing...'); - // Check authentication first + // Check authentication first - this stores token in localStorage const isAuthenticated = await AniWorld.Auth.checkAuth(); if (!isAuthenticated) { return; // Auth module handles redirect } + // Short delay to ensure token is available in localStorage + await new Promise(resolve => setTimeout(resolve, 100)); + // Initialize theme AniWorld.Theme.init(); @@ -120,10 +123,22 @@ AniWorld.QueueApp = (function() { * Load queue data and update display */ async function loadQueueData() { - const data = await AniWorld.QueueAPI.loadQueueData(); - if (data) { - AniWorld.QueueRenderer.updateQueueDisplay(data); - AniWorld.ProgressHandler.processPendingProgressUpdates(); + try { + const response = await fetch(API.QUEUE_STATUS, { + method: 'GET', + headers: AniWorld.Auth.getAuthHeaders() + }); + if (!response || !response.ok) { + console.warn('Failed to load queue data:', response?.status); + return; + } + const data = await response.json(); + if (data) { + AniWorld.QueueRenderer.updateQueueDisplay(data); + AniWorld.ProgressHandler.processPendingProgressUpdates(); + } + } catch (error) { + console.warn('Error loading queue data:', error); } } diff --git a/tests/robot/ui/queue_page.robot b/tests/robot/ui/queue_page.robot index 5e0bc3d..edf60c1 100644 --- a/tests/robot/ui/queue_page.robot +++ b/tests/robot/ui/queue_page.robot @@ -46,16 +46,18 @@ Queue Stats Cards Display Zero Initially # --------------------------------------------------------------------------- Start Queue Button [Documentation] Click start queue and verify button state changes. - ${disabled}= Get Attribute id=start-queue-btn disabled - IF '${disabled}' != 'true' + ${states}= Get Element States id=start-queue-btn + ${enabled}= Evaluate 'enabled' in $states + IF $enabled Click id=start-queue-btn Wait For Elements State id=stop-queue-btn visible timeout=3s END Stop Queue Button [Documentation] Click stop queue and verify button state changes. - ${disabled}= Get Attribute id=stop-queue-btn disabled - IF '${disabled}' != 'true' + ${states}= Get Element States id=stop-queue-btn + ${enabled}= Evaluate 'enabled' in $states + IF $enabled Click id=stop-queue-btn Wait For Elements State id=start-queue-btn visible timeout=3s END @@ -65,8 +67,9 @@ Stop Queue Button # --------------------------------------------------------------------------- Clear Completed Confirmation [Documentation] Click clear completed and verify confirmation modal appears. - ${disabled}= Get Attribute id=clear-completed-btn disabled - IF '${disabled}' != 'true' + ${states}= Get Element States id=clear-completed-btn + ${enabled}= Evaluate 'enabled' in $states + IF $enabled Click id=clear-completed-btn Element Should Be Visible id=confirm-modal Element Text Should Contain id=confirm-modal clear @@ -76,8 +79,9 @@ Clear Completed Confirmation Clear Failed Confirmation [Documentation] Click clear failed and verify confirmation modal appears. - ${disabled}= Get Attribute id=clear-failed-btn disabled - IF '${disabled}' != 'true' + ${states}= Get Element States id=clear-failed-btn + ${enabled}= Evaluate 'enabled' in $states + IF $enabled Click id=clear-failed-btn Element Should Be Visible id=confirm-modal Element Text Should Contain id=confirm-modal clear @@ -90,8 +94,9 @@ Clear Failed Confirmation # --------------------------------------------------------------------------- Retry All Failed [Documentation] Click retry all and verify UI feedback. - ${disabled}= Get Attribute id=retry-all-btn disabled - IF '${disabled}' != 'true' + ${states}= Get Element States id=retry-all-btn + ${enabled}= Evaluate 'enabled' in $states + IF $enabled Click id=retry-all-btn Toast Should Contain retry END