In #2068063: Change "Save and keep un-/published" buttons to a "Published" checkbox and an included "Save" button the text of the node edit 'save' button will be simplified, from the current varying 'save and publish', 'save and unpublish', 'save and keep published' and ''save and keep unpublished'. The new version will have a simple 'published' checkbox for users who have the autority to alter the status, and a consistent 'save' button. This change will be done at core 8.4 but it is not going to be back-ported to 8.3 - see comment #220 for details.
The Scheduler tests have many ocurrences of the text of a button to click. This will need to be changed so that the tests continue to pass. The change will be made to core 8.4.x (sometime) but not at 8.3.x. We want our tests to pass at both 8.4 and 8.3 hence we need to develop ways to cope with this.
The above four text strings are used in 13 of Scheduler's 22 test files:
- SchedulerApiTest
- SchedulerBasicTest
- SchedulerDefaultTimeTest
- SchedulerMetaInformationTest
- SchedulerMultilingualTest
- SchedulerPastDatesTest
- SchedulerPermissionsTest
- SchedulerRequiredTest
- SchedulerRulesActionsTest
- SchedulerRulesConditionsTest
- SchedulerRulesEventsTest
- SchedulerTokenReplaceTest
- SchedulerValidationTest
Possible solutions
The fixes will vary from file to file. The two main ideas are:
- Alter the test to run as a user without 'administer content' permission. Then they will always get the consistent 'save' button in both 8.3 and 8.4
- Look for the 'published status' checkbox on the page, via xpath, and use this for conditional coding
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | 2873108-12.save-button-change-detect-checkbox.patch | 10.22 KB | jonathan1055 |
| #5 | 2873108-5.save-button-change-adminuser-to-scheduleruser.patch | 13.61 KB | jonathan1055 |
| #3 | 2873108-3.save-button-in-tests.patch | 7.7 KB | jonathan1055 |
Comments
Comment #2
jonathan1055 commentedListed the files affected and some possible solutions.
Comment #3
jonathan1055 commentedPatch for the first two test files: APItest and BasicTest. The change here is to run the tests via a normal scheduler user not an admin user. This means that the 'save and publish' button will not be shown in 8.3 or in 8.4, either now or after the core change has been made. This required a little alteration to the test files, for example re-setting the 'sticky' value using
$node->set('sticky', FALSE)instead of via the edit page. This is fine, as it does not affect the validity of the tests.Comment #5
jonathan1055 commentedFive test files (DefaultTime, MetaInformation, PastDates, Required and Token) can be sorted by changing from adminUser to schedulerUser and adjusting the button text.
Comment #7
jonathan1055 commentedThe failure is not related to this patch, as the committed codebase started to fail (but was OK at last commit). Just to check, here is a patch which puts back the change to API test .info.yml
Comment #9
jonathan1055 commentedOK, so the failure was not caused by the change yesterday. Maybe something in core 8.3 and 8.4 has changed, because the tests still pass OK at 8.2 (all run at 7:40 GMT this morning 30 April)
See #2874410: Tests with assertFieldById fail to find field at 8.3 and 8.4, ok at 8.2
Comment #12
jonathan1055 commentedHa, the test took so long to start, I had already committed the code.
The tests for Multilingual, Permissions and Validation need to be run with a user who has admin permissions, as they change the published state. Hence these three use xpath to see if a 'status' checkbox exists, and use alternative button text.
Comment #15
jonathan1055 commentedI think this can now be marked as fixed. We cannot be totally sure until the change in #2068063: Change "Save and keep un-/published" buttons to a "Published" checkbox and an included "Save" button has been committed, but I have checked that our tests all pass in an environment where 2068063-247.patch has been applied.
Comment #16
jonathan1055 commented