summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrail Finder (aider) <wohilas@gmail.com>2025-04-05 15:55:42 +0300
committerGrail Finder (aider) <wohilas@gmail.com>2025-04-05 15:55:42 +0300
commite7e0bc7113ffe38273848c79e77b6c90dfaa93f4 (patch)
tree7cd61f7cd139000ca7cdaba66312d458de3ee041
parent5862de4e0cbe43ee273461043a230fa16ac049cc (diff)
test: update question flow test assertions and feedback structure
-rw-r--r--components/index.html9
-rw-r--r--internal/handlers/handlers_test.go9
2 files changed, 14 insertions, 4 deletions
diff --git a/components/index.html b/components/index.html
index fb294f5..b51c0e3 100644
--- a/components/index.html
+++ b/components/index.html
@@ -13,7 +13,14 @@
<div class="question-text" data-testid="question">
{{.Text}}
</div>
- <div id="feedback"></div>
+ <div id="feedback" data-testid="feedback" class="{{if .Correct}}correct-feedback{{else}}error-feedback{{end}}">
+ {{if .Correct}}
+ <div class="correct-answer">Correct!</div>
+ {{else}}
+ <div class="wrong-answer">Try Again</div>
+ {{end}}
+ <div class="explanation">{{.Explanation}}</div>
+ </div>
<div id="options">
<button
data-testid="option1"
diff --git a/internal/handlers/handlers_test.go b/internal/handlers/handlers_test.go
index be5607f..9de63b4 100644
--- a/internal/handlers/handlers_test.go
+++ b/internal/handlers/handlers_test.go
@@ -53,7 +53,8 @@ func TestQuestionFlow(t *testing.T) {
if err != nil {
assert.FailNow("Failed to get question text", err)
}
- assert.Contains(questionText, "___ hast du heute Zeit?", "Question text should contain the actual question text from DB")
+ assert.Contains(questionText, "___ hast du heute Zeit?", "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)
@@ -74,7 +75,8 @@ func TestQuestionFlow(t *testing.T) {
assert.NoError(err)
// Wait for feedback to update and verify
- err = page.Locator("[data-testid='feedback']:has-text('zu welchem Zeitpunkt')").WaitFor()
+ // Check for success styling and explanation
+ err = page.Locator(".correct-feedback:has-text('Wann: zu welchem Zeitpunkt')").WaitFor()
assert.NoError(err, "Correct answer feedback not shown")
// Test wrong answer
@@ -82,7 +84,8 @@ func TestQuestionFlow(t *testing.T) {
assert.NoError(err)
// Wait for feedback to update and verify - using actual explanation from DB
- err = page.Locator("[data-testid='feedback']:has-text('Wann: zu welchem Zeitpunkt')").WaitFor()
+ // Check for error styling and explanation
+ err = page.Locator(".error-feedback:has-text('Wann: zu welchem Zeitpunkt')").WaitFor()
assert.NoError(err, "Wrong answer feedback not shown")
}