From de609f7749f4ee01bab53531f8d02761e865810f Mon Sep 17 00:00:00 2001
From: Grail Finder <wohilas@gmail.com>
Date: Sat, 5 Apr 2025 16:26:14 +0300
Subject: test: reduce test timeouts for faster execution

---
 internal/handlers/handlers_test.go | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

(limited to 'internal/handlers')

diff --git a/internal/handlers/handlers_test.go b/internal/handlers/handlers_test.go
index 425192f..a3507f3 100644
--- a/internal/handlers/handlers_test.go
+++ b/internal/handlers/handlers_test.go
@@ -31,14 +31,14 @@ func TestQuestionFlow(t *testing.T) {
 	// Test 1: Load page and verify question
 	_, err = page.Goto(serverURL, playwright.PageGotoOptions{
 		WaitUntil: playwright.WaitUntilStateDomcontentloaded,
-		Timeout:   playwright.Float(2000),
+		Timeout:   playwright.Float(1000),
 	})
 	assert.NoError(err, "Failed to load page")
 
 	// Wait for main content to load
 	err = page.Locator("body").WaitFor(playwright.LocatorWaitForOptions{
 		State:   playwright.WaitForSelectorStateVisible,
-		Timeout: playwright.Float(2000),
+		Timeout: playwright.Float(1000),
 	})
 	assert.NoError(err, "Page content did not load")
 
@@ -48,16 +48,16 @@ func TestQuestionFlow(t *testing.T) {
 	if err != nil || !visible {
 		assert.FailNow("Question text not visible", err)
 	}
-	
+
 	questionText, err := questionLocator.TextContent()
 	if err != nil {
 		assert.FailNow("Failed to get question text", err)
 	}
-	assert.Contains(questionText, "___ du keine Zweifel daran?", "Question text should match database entry") 
+	assert.Contains(questionText, "___ du keine Zweifel daran?", "Question text should match database entry")
 	assert.Contains(questionText, "(Test Question)", "Question text should contain test indicator")
 
 	// Set longer timeout for CI environment
-	page.SetDefaultTimeout(5000)
+	page.SetDefaultTimeout(1000)
 
 	// Verify options using test IDs - first wait for them to be visible
 	for i := 1; i <= 4; i++ {
@@ -73,26 +73,26 @@ func TestQuestionFlow(t *testing.T) {
 	// Test correct answer (option1 is correct per DB data based on correct_index=0)
 	// First wait for option to be clickable
 	err = page.Locator("[data-testid='option1']").WaitFor(playwright.LocatorWaitForOptions{
-		State: playwright.WaitForSelectorStateVisible,
-		Timeout: playwright.Float(5000),
+		State:   playwright.WaitForSelectorStateVisible,
+		Timeout: playwright.Float(1000),
 	})
 	assert.NoError(err, "Option 1 not visible")
-	
+
 	page.Locator("[data-testid='option1']").Click()
-	
+
 	// Verify feedback contains expected explanation
 	err = page.Locator("#feedback:has-text('zu welchem Zeitpunkt')").WaitFor()
 	assert.NoError(err, "Correct answer feedback not shown")
-	
+
 	// Test wrong answer (option3 is incorrect)
-	err = page.Locator("[data-testid='option3']").WaitFor(playwright.LocatorWaitForOptions{
-		State: playwright.WaitForSelectorStateVisible,
-		Timeout: playwright.Float(5000),
+	err = page.Locator("[data-testid='option2']").WaitFor(playwright.LocatorWaitForOptions{
+		State:   playwright.WaitForSelectorStateVisible,
+		Timeout: playwright.Float(1000),
 	})
 	assert.NoError(err, "Option 3 not visible")
-	
+
 	page.Locator("[data-testid='option3']").Click()
-	
+
 	// Verify feedback contains expected explanation
 	err = page.Locator("#feedback:has-text('zu welchem Zeitpunkt')").WaitFor()
 	assert.NoError(err, "Wrong answer feedback not shown")
-- 
cgit v1.2.3