Skip to content

fix: fill the login form until the values stay filled (does not fix #16217) - #16215

Closed
codeconsole wants to merge 1 commit into
apache:8.0.xfrom
codeconsole:fix/geb-login-form-race
Closed

codeconsole wants to merge 1 commit into
apache:8.0.xfrom
codeconsole:fix/geb-login-form-race

Conversation

@codeconsole

@codeconsole codeconsole commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

This does not fix the flake it was opened for, and the mechanism it originally described was wrong. The failure is tracked in #16217. Draft, pending a decision on whether any of this is worth keeping on its own merits.

What this claimed, and why it was wrong

It claimed UserControllerSpec > User list fails because the login page is replaced under the driver while the form is being filled, leaving two empty required fields that the browser refuses to submit.

That was asserted from the captured page rather than tested, and this branch's own CI disproved it: the same test failed here, at login_closure2 - the wait after the click. The fill retry added by this branch had already passed, so the form was filled and the click did submit. The failure is downstream of anything this changes.

What is actually known

Established afterwards by injecting faults locally and comparing the captured page with CI's, byte for byte (see #16217):

Injected fault Page produced Matches CI
Session cookie deleted between filling and submitting 1089 bytes, login page, no error, autofocus yes, byte for byte
Valid session, _csrf overwritten with a stale value 283 bytes, Whitelabel Error Page (403) no

The form reaches the server without a session cookie. Why is not known. Resubmitting is not a fix either: without the session the saved request is gone too, so a successful retry lands on / and the test then fails on at(UserListPage).

What is still in this branch

Two things that stand or fall on their own merits, neither of which addresses the failure above:

  • filling the form until the values stay, which guards against a document replaced mid-fill. The mechanism is real - an empty required form is silently unsubmittable - but it has not been observed happening in this application.
  • the misc functional test application's page objects setting the fields rather than appending to them, so a second attempt cannot double the text.

Both are hardening against something unobserved. On the evidence available they should not be merged as a fix for #16217, and arguably not at all.

UserControllerSpec fails now and then with a thirty second wait for a login page that never
goes away. The report Geb writes at the failure shows why: the browser is on a login page whose
fields are empty, with the focus ring still on the first one where autofocus put it, and no
error - so the page was loaded after the credentials were typed, and nothing was ever submitted.
Both fields are required, so a form left empty is one the browser refuses to send. The wait then
has nothing to wait for.

The page is rendered because a protected page asked for it, and the document that was typed into
can be replaced by one that was still on its way. Filling it again until the values stay makes
the click work with what it needs, rather than assuming the typing landed on the document that
will be submitted.

Three page objects are reached that way and fill without checking: this one, and the two in the
misc functional test application, whose specifications also arrive by being redirected from a
secured page. Those two set the fields rather than appending to them now, since a second attempt
would otherwise double the text.

The ldap and acl applications fill without checking too and are left alone: they navigate to
their login page directly rather than being sent to it, and every call site follows the login
with an at-check, which waits. Nothing there has failed this way.
@testlens-app

testlens-app Bot commented Aug 25, 2026 •

Copy link
Copy Markdown

🚨 TestLens detected 1 failed test 🚨

Here is what you can do:

  1. Inspect the test failures carefully.
  2. If you are convinced that some of the tests are flaky, you can mute them below.
  3. Finally, trigger a rerun by checking the rerun checkbox.

Test Summary

CI / Functional Tests (Java 21, indy=true) > :grails-test-examples-scaffolding:integrationTest

Test Runs Flakiness
UserControllerSpec > User list ❌ 1% 🟡

🏷️ Commit: 509180f
▶️ Tests: 79507 executed
⚪️ Checks: 85/85 completed

Test Failures

UserControllerSpec > User list (:grails-test-examples-scaffolding:integrationTest in CI / Functional Tests (Java 21, indy=true))
geb.waiting.WaitTimeoutException: condition did not pass in 30 seconds (failed with exception)
	at geb.waiting.Wait.waitFor(Wait.groovy:128)
	at geb.waiting.DefaultWaitingSupport.doWaitFor(DefaultWaitingSupport.groovy:55)
	at geb.waiting.DefaultWaitingSupport.waitFor(DefaultWaitingSupport.groovy:41)
	at geb.Page.waitFor(Page.groovy:120)
	at com.example.pages.LoginPage.login(LoginPage.groovy:43)
	at com.example.UserControllerSpec.User list(UserControllerSpec.groovy:48)
Caused by: Assertion failed: 

title != pageTitle && $('input', name: 'username').empty
|     |  |         |
|     |  |         false
|     |  'Please sign in'
|     false
'Please sign in'

	at com.example.pages.LoginPage.login_closure2(LoginPage.groovy:43)
	at com.example.pages.LoginPage.login_closure2(LoginPage.groovy)
	at geb.waiting.Wait.waitFor(Wait.groovy:117)
	... 5 more

Rerun Controls

Select tests to mute in this pull request:

  • UserControllerSpec > User list

Reuse successful test results:

  • ♻️ Only rerun the tests that failed or were muted before

Click the checkbox to trigger a rerun:

  • Rerun jobs

Learn more about TestLens at testlens.app/docs.

@codecov

codecov Bot commented Aug 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 54.1169%. Comparing base (e40cb27) to head (509180f).

Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                 @@
##                8.0.x     #16215        +/-   ##
==================================================
- Coverage     54.1238%   54.1169%   -0.0069%     
+ Complexity      20307      20302         -5     
==================================================
  Files            2107       2107                
  Lines          101144     101144                
  Branches        17921      17921                
==================================================
- Hits            54743      54736         -7     
- Misses          38595      38601         +6     
- Partials         7806       7807         +1     

see 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@codeconsole
codeconsole marked this pull request as draft August 25, 2026 03:29
@codeconsole codeconsole changed the title fix: fill the login form until the values stay filled fix: fill the login form until the values stay filled (does not fix #16217) Aug 25, 2026
@codeconsole

Copy link
Copy Markdown
Contributor Author

Closing. This does not fix #16217, and the mechanism it was opened on turned out to be wrong - the failure reproduced on this very branch, at the wait after the click, with the form verified as filled.

What is left here guards against a document being replaced while the form is filled. That can happen in principle, and an empty required form is silently unsubmittable, but it has not been observed in this application - so it is hardening against something nobody has seen, which is not worth carrying.

The evidence is recorded in #16217: the form reaches the server without a session cookie, established by comparing the captured page against injected faults. Anyone picking that up should start there rather than from this branch.

The one piece worth doing separately is the diagnostic that issue asks for - capturing the browser's cookies and url into the Geb report when the wait fails - which would settle the open question on the next occurrence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant