Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Problem/Motivation
When using the simpletest ui to run tests, pressing the "Clean Environment" button while a test is selected will run the selected tests instead of cleaning the environment.
Steps to reproduce:
- Standard Drupal 8 Install
- Enable Simpletest module (Testing)
- Visit simpletest ui (admin/config/development/testing)
- Select any test or set of tests
Click "Clean Environment" - Note that test(s) start running
This could be changed to minor since the clean environment button is functional without a test selected and the testing interface is not part of normal site development.
Proposed resolution
"Clean Environment" button should be properly identified as triggered element
Remaining tasks
User interface changes
none
API changes
none
Data model changes
none
Comment | File | Size | Author |
---|---|---|---|
#3 | 2554267-3.patch | 1.75 KB | asgorobets |
Comments
Comment #2
othermachines CreditAttribution: othermachines commentedConfirmed (using latest 8.0.x). At first I thought I was imagining things.
Comment #3
asgorobets CreditAttribution: asgorobets at FFW commentedThe issues was a bit tricky to find, but finally got it working.
First of all, there is already a separate submit handler for 'Clean environment' button, it's just not working properly under some circumstances.
Submit handlers attached to $form['clean']['op'] buttons are not executed when ticking at least one checkbox, but they are working fine when no checkboxes are ticked. This happens because Drupal does not identify correctly the triggered element. When ticking at least one checkbox, triggered element is considered the 'Run tests' button as it can't find the element (button) that was clicked in the form, and it has to default to the first button.
Button is missing in the $form because there is an early return happening when constructing $form array, if at least one of the tests is checked, then it will not construct the form again on submit, with this it will lose any evidence of 'clean' fieldset and 'op' button, that is added after this return statement.
In order to mitigate the issue I propose to move the 'clean' fieldset up and place it after the 'actions' element, so it is always rendered, even if the early return happens.
Please see patch attached.
Comment #4
LoMo CreditAttribution: LoMo as a volunteer commentedI marked this is RTBC and made a comment yesterday, but there must have been a glitch since it's gone now.
I did test this, even after running some tests so that there really was an environment to 'clean' (that took a while, since I guess the tests I selected were not the simplest ones). And I verified the problem and that the solution seems to work, as advertised. I think this can be marked RTBC. Nice work, asgorobets. :-)
Comment #5
alexpottPermitted in beta since this is test related code and fixing a bug. Committed 983d2eb and pushed to 8.0.x. Thanks!