diff options
-rw-r--r-- | components/index.html | 2 | ||||
-rw-r--r-- | internal/handlers/handlers_test.go | 14 | ||||
-rw-r--r-- | internal/handlers/main.go | 2 |
3 files changed, 12 insertions, 6 deletions
diff --git a/components/index.html b/components/index.html index c8cf327..fb294f5 100644 --- a/components/index.html +++ b/components/index.html @@ -10,7 +10,7 @@ </head> <body> <div id="ancestor"> - <div class="question-text"> + <div class="question-text" data-testid="question"> {{.Text}} </div> <div id="feedback"></div> diff --git a/internal/handlers/handlers_test.go b/internal/handlers/handlers_test.go index a74be30..1ddaad3 100644 --- a/internal/handlers/handlers_test.go +++ b/internal/handlers/handlers_test.go @@ -42,12 +42,18 @@ func TestQuestionFlow(t *testing.T) { }) assert.NoError(err, "Page content did not load") - // Verify question text exists - questionText, err := page.Locator("[data-testid='question']").TextContent() + // Verify question text exists and contains expected content + questionLocator := page.Locator("[data-testid='question']") + visible, err := questionLocator.IsVisible() + if err != nil || !visible { + assert.FailNow("Question text not visible", err) + } + + questionText, err := questionLocator.TextContent() if err != nil { - assert.FailNow("Question text not found", err) + assert.FailNow("Failed to get question text", err) } - assert.Contains(questionText, "Zweifel", "Question text mismatch") + assert.Contains(questionText, "Zweifel", "Question text should contain 'Zweifel'") // Set reasonable timeout for light site page.SetDefaultTimeout(2000) diff --git a/internal/handlers/main.go b/internal/handlers/main.go index 3b44d49..5e1b8ae 100644 --- a/internal/handlers/main.go +++ b/internal/handlers/main.go @@ -113,7 +113,7 @@ func (h *Handlers) MainPage(w http.ResponseWriter, r *http.Request) { } testQuestion := &models.Question{ ID: 1, - Text: "___ du keine Zweifel daran?", + Text: "___ du keine Zweifel daran? (Test Question)", Option1: "Haben", Option2: "Hast", Option3: "Hat", |