Closed (fixed)
Project:
Drupal core
Version:
9.3.x-dev
Component:
Olivero theme
Priority:
Major
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
30 Sep 2020 at 13:57 UTC
Updated:
14 Jul 2021 at 20:09 UTC
Jump to comment: Most recent
Comments
Comment #2
mherchelComment #3
markdorisonAre there any examples we can point to in other themes of the type of tests we are looking to create?
Comment #4
markdorisonI reviewed the other themes in core and I am not seeing examples of tests. Maybe they live elsewhere in the codebase?
Comment #5
mherchelNo examples here, but @berdir left some ideas on what to test at https://www.drupal.org/project/drupal/issues/3111409#comment-13849159
Comment #6
mherchelComment #8
brianperryStarted looking at this during the FLDC sprint, but admittedly didn't get too far. Planning on continuing to chip away at this one.
Comment #9
brianperryPushed a commit up to the issue fork that adds coverage for olivero_preprocess_block
I changed the tests to use Olivero as a default theme, rather than manually enabling it. One side effect of that is that I also needed to use the minimal install profile during the set up phase. With other approaches I kept seeing unmet dependency messages, even when adding the dependencies during setup. Could be an opportunity to optimize these tests.
I also couldn't think of a way to cover this:
Isn't clear to me what the impact that this has on the resulting page.
Comment #11
brianperryComment #12
brianperryComment #13
brianperryHad previously discussed with @mherchel about treating this as a meta issue and creating individual issues for the line items listed in the summary. I realized that would be difficult to manage since additional tests will want the set up changes in this merge request. So I think for the MidCamp sprint we're better off coordinating and all working off of the existing feature branch.
I did create #3205434: Add Nightwatch Test Coverage for Olivero for Nightwatch tests, which can be addressed separately.
Comment #14
mglamanI'm taking olivero_form_alter
Comment #15
mtiftComment #16
mglamanComment #17
mglamanComment #18
mglamanComment #19
brianperryComment #20
mtiftComment #21
mradcliffeI'm going to pick up preprocess_input_test from, @mtift here at midcamp 2021.
Comment #22
mradcliffePreprocess input test is done pending review.
Comment #23
cathwaldron commentedI am working on writing the test for number 6 as part of MidCamp 21 contribution day.
Comment #24
brianperryComment #25
brianperryGreat progress on this issue at the MidCamp sprint today. We now have tests for the first 5 theme functions, and as noted above coverage for the last function is in progress.
The test I wrote for olivero_preprocess_block is a phpunit functional test, while everything written today are unit tests. Not sure if we want to change that. There are a few things covered in there that seem like they might be a little harder to handle in a unit test.
Comment #26
cathwaldron commentedI am done for the day, thank you @mradcliffe for mentoring and helping me today.
This is my first contribution to the Drupal project. Hooray!!!
Comment #28
capysara commentedThe previous comment doesn't include a test for the portion of the preprocess that adds user.compact because it doesn't seem to be executing. Can anyone clarify if this actually is necessary? If not, should it be removed? Otherwise, it still needs a test.
Comment #29
brianperryComment #30
brianperryAt this point, I think we just need one last holistic review to make sure all of the tests still pass, and we didn't miss something coverage wise. Would be a good issue for someone with testing experience looking to pick something up during DrupalCon contribution.
Comment #31
mtiftI'm not sure about the answers to the "unresolved" issues above, but I cleaned up a few minor coding standard things and confirmed that all of the tests pass. This looks good to me.
Comment #32
brianperry@mradcliffe mentioned on slack that he thought olivero_preprocess_input might be missing some coverage. Taking a quick look at the code, this block is the only thing that looks like it might not be covered.
I think we're good on the form-element lines. I don't think we have something covering $variables['autocomplete_message'] or the form-boolean--type section for checkbox and radio.
Between that and @mtift's review and updates I can't think of anything that would still be missing here.
Comment #33
brianperryAdded coverage as outlined in #32. Also removed the WIP status from the MR. As far as I'm concerned this is complete and ready for the real deal review.
Comment #34
mtiftAll of the tests pass, the code coverage seems sufficient, and the test code makes sense to me.
Comment #36
alexpottI'd have hoped that the test coverage would pick up this...
I think this should be
if (isset($form['actions']['submit']) && (count($form['actions'])) <= 2) {. It's possible to have actions without a submit - here's an example - http://grep.xnddx.ru/node/30840640 - this contrib module will do interesting things with olivero enabled.I think we should consider whether unit tests of form alters and preprocess functions are the best way to go. The tests are deeply coupled to the implementations. If the underlying form altering mechanism were to change what we'd want is a test that proves the effects are still working.
Comment #37
mherchelSetting back to needs work per #36
Comment #38
brianperry> I think we should consider whether unit tests of form alters and preprocess functions are the best way to go. The tests are deeply coupled to the implementations. If the underlying form altering mechanism were to change what we'd want is a test that proves the effects are still working.
Had some follow up discussion in slack and clarified that functional tests are the more appropriate way to cover the hooks we're testing here. So the work required here would be refactoring the unit tests added here to be functional tests. I believe olivero_preprocess_block was initially covered as a functional test, so that should be set.
We should also address the specific case identified in #36 along the way.
Comment #39
mglamanPerforming some late night hacking on this.
Comment #40
mglamanMade a Nightwatch test to cover the form alters for search. I started on something for comments, but it's a bear to setup in Nightwatch and should be a BrowserTestBase – the main goal is testing the comment count displayed as part of OliveroPreprocessFieldCommentTest
Comment #41
brianperryComment #42
mglamanolivero_form_alter is almost covered. We need functional tests to convert the Unit tests for all of the button class manipulation.
Comment #43
mglamanClaiming olivero_preprocess_field__comment :)
Comment #44
brianperryComment #45
brianperryPushed up coverage for olivero_preprocess_input. It doesn't cover datetime-local, month, and week input types - there were no examples in the form_test module (or anywhere else in core that I could find) and I wasn't able to easily create examples. I'm hoping the fact that this does cover date and time inputs is good enough.
This also does not cover the rendering of an autocomplete loading message
It looks like there isn't anything in the theme that actually renders this message. Planning on creating a follow up issue for this.
Next step for me is that I'm going to walk through all the tests again, provide some review and close any remaining gaps that I can.
Comment #46
brianperryReviewed Nightwatch coverage for:
* olivero_preprocess_block - this is a BrowserTestBase test, but is a functional test that passes. Planning on creating a follow up ticket to convert this to Nightwatch, and hoping that the existing test coverage is good enough for stable.
* olivero_theme_suggestions_form_alter - confirmed that it is covered by oliveroSearchFormTest.js
* olivero_form_alter - reviewed the existing test and added remaining coverage for the submit button class.
That just leaves olivero_preprocess_field__comment. Similar to form_alter I'm planning on next reviewing the existing test and trying to fill in any coverage gaps if necessary.
Comment #47
brianperryPushed updates to oliveroComentTest.js that should cover what remains for comments.
From my perspective all that remains at this point is resolving the issue related to $form['actions'] referenced in https://www.drupal.org/project/drupal/issues/3174107#comment-14091227 and adding test coverage for it.
Comment #48
brianperryFrom my perspective all of the unit tests are now replaced by Nightwatch tests and this is ready to be reviewed again. olivero_preprocess_block is still covered by a BrowserTestBase test. I'll create a follow up issue for that as it would be nice to have all tests in one place at this point.
You can run all of Olivero's tests with:
Comment #49
mherchelLooks like the latest test failure is unrelated, but I can't figure out how to re-queue it on a Gitlab MR
Comment #50
brianperry@mherchel It looks like this re-queued somehow and everything passed.
Comment #51
mherchelThere's a merge conflict. I tried to fix this myself, but I still can't figure out how to push code when using this new workflow.
Comment #52
brianperry@mherchel thanks for the heads up. Rebased against 9.2.x to resolve the merge conflict.
Comment #53
mtiftComment #54
brianperryUpdated the variable name as suggested and confirmed locally that the Nightwatch tests still pass.
Comment #55
mherchelWe're getting a nightwatch error:
Comment #56
brianperryLooks like some of the selectors changed since the search test was added. Side effect of code standards cleanup perhaps?
Pushed up updates for the failing test and ran the Olivero suite locally to confirm that everything passes.
Comment #57
mtiftI think this is ready to go. Great work, @brianperry!
Comment #58
alexpottThere's a tiny thing to update in the .theme code changes - after that this looks really good.
Comment #60
ravi.shankar commentedMade changes as per comment #58.
Comment #61
mtiftThe latest change looks good. Back to RTBC.
Comment #62
mherchelTest failures were unrelated. The latest tests pass. Thank you so much everyone!
Comment #63
alexpottUnfortunately this test fail is caused by this MR for some reason.
Comment #64
alexpottI've pushed a fix to the branch but unfortunately this is a completely unrelated issue and is only happening because of the dependencies added to olivero_test. I've created #3218660: help_topics module can break during module uninstall to fix and add a proper test for the fix.
Comment #65
alexpottUpdated the MR with the proper fix from #3218660: help_topics module can break during module uninstall - it'll prove that the fix works but, unfortunately, I think that that one is going to have to land first :(
Comment #66
larowlanTook another look at the MR, whilst I don't particularly like using nightwatch, if that's what people are comfortable with, so be it.
I was at first questioning a lot of the changes as out of scope, but after reading the comments realise this includes #3218660: help_topics module can break during module uninstall which we should postpone this issue on.
I'll take a look at that now.
Comment #67
mglaman+1, the changes look good since we moved from unit tests to functional tests. I believe the Nightwatch tests work to cover interactions and modifications.
Comment #68
mglamanComment #69
alexpottCommitted e182007 and pushed to 9.3.x. Thanks!
Comment #71
joseph.olstadthis commit appears to have caused automated testing to fail for php 8.0.
Comment #72
joseph.olstadhttps://www.drupal.org/pift-ci-job/2107053
this is holding up test jobs from other issues
Comment #75
alexpottI've created a new MR against 9.3.x because one of the new tests is failing there...
Comment #76
mherchelThe code that is failing is looking for region attribute on the menu.
$this->assertSession()->elementExists('css', 'ul[region="primary_menu"]');We don't need this region attribute. It's only used to pass down the name of the region from
olivero_preprocess_block()to other preprocess functions such asolivero_preprocess_menu().Because we don't need the attribute, we actually removed it in #3173022: Figure out a clean way to manage the style of Olivero's menu block in the sidebar region -- apparently in 9.3.x only, which is why it was passing against 9.2.x.
We test that the template suggestion for the primary navigation is working by looking for the
.primary-navselector, so we don't need to change the line. We can safely remove it IMO.Comment #77
mherchelI'm still having trouble with this new workflow on my local, but I was able to remove the line using GitLab's WebIDE.
Hopefully tests pass!
Comment #78
mglamanI'm going to flip this back to RTBC. Removed the failing assertion which isn't true in the 9.3.x branch
Comment #79
alexpott2nd time lucky! Committed e595a45 and pushed to 9.3.x. Thanks!