summaryrefslogtreecommitdiff
path: root/internal/handlers
diff options
context:
space:
mode:
Diffstat (limited to 'internal/handlers')
-rw-r--r--internal/handlers/handlers_test.go15
-rw-r--r--internal/handlers/main.go6
2 files changed, 14 insertions, 7 deletions
diff --git a/internal/handlers/handlers_test.go b/internal/handlers/handlers_test.go
index d177239..a74be30 100644
--- a/internal/handlers/handlers_test.go
+++ b/internal/handlers/handlers_test.go
@@ -35,15 +35,18 @@ func TestQuestionFlow(t *testing.T) {
})
assert.NoError(err, "Failed to load page")
- // Wait for question to appear
- err = page.Locator(".question-text").WaitFor(playwright.LocatorWaitForOptions{
+ // Wait for main content to load
+ err = page.Locator("body").WaitFor(playwright.LocatorWaitForOptions{
State: playwright.WaitForSelectorStateVisible,
- Timeout: playwright.Float(1000),
+ Timeout: playwright.Float(2000),
})
- assert.NoError(err, "Question text did not appear")
+ assert.NoError(err, "Page content did not load")
- questionText, err := page.Locator(".question-text").TextContent()
- assert.NoError(err, "Failed to get question text")
+ // Verify question text exists
+ questionText, err := page.Locator("[data-testid='question']").TextContent()
+ if err != nil {
+ assert.FailNow("Question text not found", err)
+ }
assert.Contains(questionText, "Zweifel", "Question text mismatch")
// Set reasonable timeout for light site
diff --git a/internal/handlers/main.go b/internal/handlers/main.go
index c4222f4..7e3bfa0 100644
--- a/internal/handlers/main.go
+++ b/internal/handlers/main.go
@@ -75,5 +75,9 @@ func (h *Handlers) MainPage(w http.ResponseWriter, r *http.Request) {
Option4: "Habt",
CorrectIndex: 1,
}
- tmpl.ExecuteTemplate(w, "main", testQuestion)
+ err = tmpl.ExecuteTemplate(w, "main", testQuestion)
+ if err != nil {
+ h.log.Error("failed to render template", "error", err)
+ abortWithError(w, "Failed to render page")
+ }
}