Problem/Motivation
In #3086794: Search results pages plugins could display results in administrative theme annotation introduced to display search results of help topics in admin theme
Because patches can't mix experimental and stable code this issue should add annotation to \Drupal\help_topics\Plugin\Search\HelpSearch
plugin
Proposed resolution
Add annotation and update introduced test to ensure that search results of help topics displayed in administrative theme
Remaining tasks
- wait for commit of #3086794: Search results pages plugins could display results in administrative theme
- update test and patch
- reveiw and commit
User interface changes
search results of help topics displayed in administrative (configured) theme
API changes
no
Data model changes
no
Release notes snippet
Comment | File | Size | Author |
---|---|---|---|
#37 | 3087879-36.patch | 1.86 KB | andypost |
#18 | interdiff.txt | 1.46 KB | andypost |
#17 | interdiff.txt | 1.63 KB | andypost |
#2 | 3086794-13-follow-up-do-not-test.patch | 487 bytes | andypost |
Comments
Comment #2
andypostComment #3
jhodgdonAssuming that the patch from #13 on
#3086794: Search results pages plugins could display results in administrative theme
gets committed, I have already reviewed and tested this patch, so am +1 on marking this RTBC immediately after that gets committed.
We'll need to retest if a different patch gets committed though.
Comment #4
andypostParent commited, needs work for tests update
Comment #5
jhodgdonParent not actually committed yet, but we can still write tests. Keep in mind the test for this one has to stay in help topics module. Probably could add it to the existing Help Search test, as it would only add a line or two to that test?
Comment #6
andypostYes, just few lines
Comment #7
andypostNow blocker commited to 9.1
Here WIP patch and test extension idea to get how to unify the user permissions and can't recall what label test @TODO was for in comment #2 of #3086794-20: Search results pages plugins could display results in administrative theme
Comment #8
andypostRevert todo to #3086795: "Search help" link in search form is ambiguous and confusing
Comment #10
jhodgdonThis looks very good! I am +1 on RTBC, although I have not tested this manually to verify that help search does stay in the administration theme, so adding a "Needs manual testing" tag. (I believe the test is accurate, but I still think we should test it manually.)
One other idea: I think that when we get to the point of merging Help Topics into Help, we should also remove this separate test class, and add the help search to the base class SearchAdminThemeTest instead? We cannot do that now, because we don't want Experimental Module code mixed with the base code.
If that sounds like a good idea, then we need to add this to the final merge plan on
#3037230: Finalize the merge of Help Topics into Help
and/or make a sub-issue.
Thoughts?
Comment #11
andypostFix namespace(
Comment #12
jhodgdonI'm only +1 on RTBC when the automated tests pass, and when someone does a manual test. Any thoughts on #10?
Comment #14
jhodgdonI just did a manual test, and the patch works as expected: searching Help results are shown in the admin theme.
RTBC assuming that the automated tests pass. We should still figure out about #10.
Comment #16
andypostRefactored test suite to allow contrib Configurable help to reuse the test as well
PS: it looks we can decouple node and user page-plugin tests out of search module later
Comment #17
andypostImprove docs a bit
Comment #18
andypostDo not create extra role if plugin does not require
Comment #19
andypostCS clean-up and fix method name renamed in #16
Comment #20
jhodgdonThe code in this latest patch is exactly the same 1-line change as in the patch I tested manually, so that should still work.
The test code in help_topics module looks good -- very clean.
The additional/modified testing code in the search module is very nice and clearly written. It makes the code more reusable, and also adds tests for what happens if the user does not have permission to use the admin theme and the search plugin is supposed to use the admin theme (in which case it uses the default theme).
The only thing I would change is this documentation on the new method in the base test class:
+ * @return array
+ * Keyed array by $page_id of supported plugin and array of permissions to
+ * access the page content and expected admin theme requirement to allow
+ * the plugin to display results.
+ *
+ * @see \Drupal\search\SearchPageAccessControlHandler::checkAccess()
+ * @see \Drupal\search\Plugin\SearchInterface::usesAdminTheme()
+ */
+ protected function getSearchPagePlugins() {
I think the documentation should be:
Comment #21
andypostFixed #20
Comment #22
jhodgdonThe last line of that documentation needs to be wrapped at 80 characters. Other than that, I think this is RTBC, unless you wanted to refactor the test in some way?
Comment #23
andypostPlugin can implement the interface https://git.drupalcode.org/project/drupal/-/blob/8.8.x/core/modules/sear...
That's why I mentioned it in
most of plugins needs access check to nodes, users, topics
Comment #24
jhodgdonOK, I think this is ready to go. Has been manually tested by me, the code looks good (1 line change), the test is comprehensive and the base test was improved.
Also added follow-up issue as part of roadmap #3144933: Add help_search plugin to the base admin theme test
Comment #25
jhodgdonComment #26
alexpottLet's not call this SearchAdminThemeTest - then you don't need to rename the other class to base class.
Also this get's a bit strange because we're adding the ['access administration pages'] permission but the underlying test adds and removes a role with that permission. I think this test inheritance is making things more complex that it should. I don't really support DRY principles in test code. It often makes it harder to understand what is actually being tested.
Let's create a new account each time with the correct set of permissions. It'll be neater and less code and less to go wrong if this test is extended.
Comment #27
andypostHere's changes to address #26
1) help topics are not stable, so we can't add its search plugin to search test. Renamed to
HelpTopicSearchAdminThemeTest
but we can have a follow-up to incorporate it into base test when topics will be stableMoreover help topics heeds
access administration pages
to display topic but search usingview the administration theme
permission for theme tests. That's why add/remove role required in loopforeach ([TRUE, FALSE] as $admin_theme_access_allowed)
Also contrib (at least configurable help) can re-use the test for its plugin
2) extra permissions are needed when search plugin is of accessible interface (which is mostly entity view access), so removed optimization of test (it was idea to not create/login user as each plugin could have no extra permissions)
Comment #28
andypostAnd the follow-up is #3144933: Add help_search plugin to the base admin theme test
Comment #30
andypostFix permission addition
Test still fails on user search (not accessible now), probably caused by cache.
On sqlite locally I'm getting db locked exception running
core/modules/help_topics/tests/src/Functional/HelpTopicSearchAdminThemeTest.php
Comment #32
jhodgdonThe two errors I see in the test results are supposed to be verifying that the user can see the "more help with searching" links.
That's weird... those links have the exact same permissions as the parent search pages.
While looking at this, by the way, I noticed:
That @todo should be removed -- that issue is done and the label was tested.
#3086795: "Search help" link in search form is ambiguous and confusing
Actually I don't know why we are testing that this link is there in this patch. It is tested in that other issue with a clickLink. I think we can take these lines out of the test:
The point of this test is to verify that if you go to those pages, the admin theme is used or not used. I do not know why these lines are failing in this test, but I don't think we need to have them here and the other test verifies you can click the link.
Comment #33
andypostThe actual issue is that user search gives 403 on visit with new user
Initial idea of testing for "search help" to make sure that it also rendered in admin theme for any search plugin, because route subscriber affects both routes
Comment #34
jhodgdonOh, that's not good.
I agree we need to test that the search help page is rendered in the correct theme.
What I don't think we need to verify is that the search help link is present on the page. We could check that the response code when visiting both search and search help is 200.
Maybe to get around the 403 problem you could make all the needed user accounts in the setUp() function and then clear the cache? And make separate accounts with and without the role access. Cache stuff is annoying in tests often, and isn't that relevant when it comes to equating test results with how things actually behave on a real site.
Comment #35
andypostThen we need to spin-up another follow-up to make test reusable and get rid of todo
Comment #36
jhodgdonCouldn't the test have a similar for loop in the setUp that does something like this:
Then in the main test function, it could reference these users? I think it would still be reusable that way..
Comment #37
andypostThinking a bit more about DRY and tests... it's search module's tests should test how admin_theme option works in integration.
So here's just kernel test to make sure plugin provides interfaces and has expected results
No interdiff because new patch
Comment #38
jhodgdonThat looks like a good course of action. You are right, the Search module is already verifying that search plugins that return TRUE for usesAdminTheme() actually use the admin theme for the search page and the help page. We also already have an issue to add HelpSearch into the existing Search admin test when we get out of Experimental for Help Topics, so we can integrate this plugin into that test then.
Assuming the tests pass, I have already manually tested the code change (see #24, and there has not been a change in the code since then).
So... I am +1 for RTBC assuming the tests pass.
Comment #39
andypostAlso filed follow-up for search module #3155221: Remove outdated todo and link to 3086795
Comment #40
jhodgdonSorry, I forgot to come back here and set this to RTBC. Had already reviewed the code, and manually tested in #24.
Comment #41
alexpottCommitted 33c16bf and pushed to 9.1.x. Thanks!
Changed spelling to american spelling on commit.