codeconsole opened a new pull request, #16215:
URL: https://github.com/apache/grails-core/pull/16215

   `UserControllerSpec > User list` fails intermittently — most recently on 
#16209, whose own change is unrelated — with a thirty second wait for a login 
page that never goes away:
   
   ```
   geb.waiting.WaitTimeoutException: condition did not pass in 30 seconds
       at com.example.pages.LoginPage.login(LoginPage.groovy:39)
   
       Caused by: Assertion failed:
       title != pageTitle && $('input', name: 'username').empty
       |         |                                        |
       |         'Please sign in'                          false
       false
   ```
   
   ## What the browser was actually looking at
   
   The Geb report captured at the failure shows a login page with **empty 
fields**, the focus ring still on the first one where `autofocus` put it, and 
**no error** — not `/login?error`, no "Bad credentials" banner.
   
   So that document was loaded *after* the credentials were typed, and nothing 
was ever submitted: both fields carry `required`, and a form left empty is one 
the browser refuses to send. The wait then has nothing to wait for, and burns 
its full timeout.
   
   The two sibling specifications in the same run passed at the same step, 
which is what makes it intermittent.
   
   ## The fix
   
   The page is rendered because a protected page asked for it, so the document 
being typed into can be replaced by one that was still on its way. The form is 
filled again until the values stay:
   
   ```groovy
   waitFor { fillCredentials(username, password) }
   loginButton.click()
   ```
   
   `waitFor` turns each statement into a condition, so the filling itself lives 
in a method the closure calls.
   
   ## Where it is applied, and where it is not
   
   Three page objects are reached by being redirected from a protected page and 
fill without checking: the scaffolding one that failed, and the two in the misc 
functional test application, whose specifications also arrive via a secured 
page. Those two now set the fields rather than appending to them, since a 
second attempt would otherwise double the text.
   
   The ldap and acl applications fill without checking too, and are 
deliberately **left alone**: they navigate to their login page directly rather 
than being redirected to it, and all eleven of their login call sites are 
followed by an `at(...)` check, which waits. Nothing there has failed this way.
   
   ## Verification
   
   `:grails-test-examples-scaffolding:integrationTest` — 4 runs, 12 tests, no 
failures. `group` and `roles` misc applications — 3 tests, no failures.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to