Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
While much of the test coverage outlined in #3174107: Add additional testing coverage for Olivero can be covered with PHPUnit functional tests, at least one outstanding browser test would be better served by Nightwatch. Having working Nightwatch tests will also open up our options for additional JS testing in the future.
Proposed resolution
A baseline Olivero test should do the following:
- Install Olivero
- Test scrolling
- Verify the default menu behavior
- Test again, but with mobile menu always turned on
Remaining tasks
- Write supporting code to install Olivero in advance of Nightwatch tests
- Create initial Nightwatch test.
- Ensure tests run as part of DrupalCI process.
Additional tests that can be written
Issue fork drupal-3205434
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
brianperryNot positive how to handle #3191077: Olivero narrow/mobile menu constrains tabbing in one direction only., but thinking is that this issue should focus on just getting one simple Nightwatch test through so this can be merged and the test for #3191077: Olivero narrow/mobile menu constrains tabbing in one direction only. can be written. It wouldn't be possible to incorporate the test for that here because it would fail unless we also included the patch for that issue.
We'll have to have a similar discussion if we come up with other Nightwatch tests during the MidCamp sprint.
Comment #7
benjifisherThe current version of the merge request installs the
standard
profile. I think we prefer to test with one of the smaller profiles:minimal
,testing
, ornightwatch_testing
.I did some manual testing, installing Drupal with the
minimal
andtesting
profiles.I installed Drupal with the
testing
profile, then tried to install Olivero. I got the messageAfter installing the
block
module, I was able to install Olivero and set it as the default theme.Then I added
drupal:block
as a dependency inolivero.info.yml
and reinstalled Drupal with thetesting
profile. Now, when I visit the Appearance page, I see the messageThe text "Extend page" is a link to
/admin/modules
.That seems like better behavior, so I think we should add
block
as a dependency. Maybe that should be a separate issue.With both the
testing
andminimal
profiles, an anonymous user sees the Login block on the home page, not the home page we see with thestandard
profile.I see that the usual home page comes from a template included when Views renders the home page. If we enable
views
as well asblock
, then that view has the path/node
, which is the default front page with thestandard
profile. That suggests two ways to get the tests to pass with theminimal
profile. Both require enabling theblock
andviews
modules./node
instead of/
.system.site.page.front
to "/node", as in thestandard
profile.I tried (1), and the first few assertions passed. The test fails to find
#block-olivero-main-menu
. I think that comes fromstandard.links.menu.yml
in thestandard
profile.Comment #8
benjifisherI am not sure what the right way is to add a Home link to the page. One option is to create a test module that copies
standard.links.menu.yml
, then enable that module in the test setup. We could add that test module tocore/modules/system/tests/modules
. Another option is to enable themenu_link_content
module and then create a menu link entity.Comment #9
benjifisherAnother way to make sure the Main menu is not empty is to add something like this to the install script:
I have updated the MR with this option.
Comment #10
mherchelI haven't tested this yet, but I'm so excited. I have a feature request.
When you add a link to the main menu, can you add a submenu below it? The submenus contain complicated functionality that differs between mobile and desktop, and it'd be great to add tests for those.
Comment #11
mherchelComment #12
benjifisherCreating links the way I did, with
Drupal::service('plugin.manager.menu.link')
, is awkward. If you want more than one, then I think a test module is the right way to do it.I added
olivero_test
undercore/modules/system/tests/modules
, defining two menu links. If there is a better place for the test module, then it should be easy to move.You should be able to experiment locally by installing Drupal with the
minimal
profile, then enabling theviews
andolivero_test
modules. Remember to visit/node
instead of/
.I think that is all I will have time to do today.
I am leaving the status at NW. Now that we have a second menu item, we should use it in the tests.
Comment #13
mherchelThanks for the help @benjifisher!
Comment #14
mherchelAdding child issue #3206015: Olivero: Additional wide menu Nightwatch tests
Comment #15
mherchelComment #16
mradcliffeI'm working/helping out reviewing and debugging nightwatch tests at MidCamp contribution day.
We looked at jsCookieTest.js as a pattern to using browser.execute() to make the navigation trap test.
Comment #17
mherchelComment #18
mherchelThis is ready for review IMO
Comment #19
mherchelThanks for the review @mradcliffe! Changes are made and pushed :)
Comment #20
mherchelGood catch. Resolved!
Comment #21
benjifisherThe integration of Nightwatch tests with the Drupal testbot seems to be incomplete. The message "Build Successful" on the latest test seems to mean that one of the Nightwatch tests failed.
Look at the console output and jump to the bottom of the page. The
oliveroMobileMenuTest
test fails, and it fails when I run it locally. I will leave a comment on the MR.Comment #22
benjifisherOn second thought, I will not comment on the MR. I thought I saw where the problem was, but I was wrong.
When I run the test locally, sometimes it passes and sometimes it does not. When it fails, it is always on Line 37, the bottom line of this snippet:
The pause does not make a difference: the test tries for 5s (5000 ms) before giving up, if I read the test results correctly.
I am afraid that I do not know nearly enough about Nightwatch to help explain why a test fails sporadically.
Comment #23
mherchelYeah, the "Build Successful" message was confusing me too.
Comment #24
benjifisherI pulled the latest version and ran the test several times. It passed 7 times, then failed on the 8'th try.
Comment #25
mherchelwell 💩. I was just about to post here that it passed the tests on Drupal CI. I will see if I get it to fail on my local.
Comment #26
mherchelI'm also able to get this to successfully fail on my local
Comment #28
mherchel@justafish helped work through some of the random test failures! I think we're good now.
Comment #29
mherchelPushed some more slight refactors based on what I learned from @justafish. This should be good to go
Comment #30
brianperryTests pass repeatedly locally, pass linting, and use just the right amount of emoji.
Comment #31
alexpottCommitted ff49ffc and pushed to 9.2.x. Thanks!
Exciting to see new Nightwatch tests in core. This seems a great start for Olivero JS test coverage.