diff options
author | Grail Finder (aider) <wohilas@gmail.com> | 2025-03-29 16:39:00 +0300 |
---|---|---|
committer | Grail Finder (aider) <wohilas@gmail.com> | 2025-03-29 16:39:00 +0300 |
commit | f7dce5201282b3e05400b1a8d06496dbd318ab34 (patch) | |
tree | 1848e104c752a8fc3605365db75f68f1d7389cc6 | |
parent | 09d83897d50226f3fe7f287ca5a78068e0a3b2b2 (diff) |
test: improve question flow test robustness
-rw-r--r-- | internal/handlers/handlers_test.go | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/internal/handlers/handlers_test.go b/internal/handlers/handlers_test.go index 33c7297..ef973c9 100644 --- a/internal/handlers/handlers_test.go +++ b/internal/handlers/handlers_test.go @@ -28,18 +28,35 @@ func TestQuestionFlow(t *testing.T) { assert.NoError(err) // Test 1: Load page and verify question - _, err = page.Goto(serverURL) - assert.NoError(err) + _, err = page.Goto(serverURL, playwright.PageGotoOptions{ + WaitUntil: playwright.WaitUntilStateNetworkidle, + Timeout: playwright.Float(10000), + }) + assert.NoError(err, "Failed to load page") + + // Wait for question to appear + err = page.Locator(".question-text").WaitFor(playwright.LocatorWaitForOptions{ + State: playwright.WaitForSelectorStateVisible, + Timeout: playwright.Float(5000), + }) + assert.NoError(err, "Question text did not appear") questionText, err := page.Locator(".question-text").TextContent() - assert.NoError(err) - assert.Contains(questionText, "Zweifel") + assert.NoError(err, "Failed to get question text") + assert.Contains(questionText, "Zweifel", "Question text mismatch") - // Verify all options are present + // Verify all options are present and clickable options := []string{"Haben", "Hast", "Hat", "Habt"} for _, opt := range options { - _, err := page.Locator("button:has-text('" + opt + "')").TextContent() - assert.NoError(err) + locator := page.Locator("button:has-text('" + opt + "')") + err := locator.WaitFor(playwright.LocatorWaitForOptions{ + State: playwright.WaitForSelectorStateVisible, + Timeout: playwright.Float(3000), + }) + assert.NoError(err, "Option button '%s' not found", opt) + visible, err := locator.IsVisible() + assert.NoError(err, "Failed to check visibility for '%s'", opt) + assert.True(visible, "Option button '%s' not visible", opt) } // Test 2: Click correct answer |