Add e2e test for menu

This commit is contained in:
Bob den Otter
2019-03-31 12:43:05 +02:00
parent 5f7dddac5d
commit f52aef138c
5 changed files with 17 additions and 5 deletions

View File

@@ -5,7 +5,7 @@ main:
- label: Home
title: This is the <b>first<b> menu item.
link: homepage
class: first
class: homepage
- label: About
link: blocks/about
submenu:
@@ -23,7 +23,7 @@ main:
link: pages/
- label: The Bolt site
link: https://bolt.cm
class: last
class: bolt-site
title: Visit the excellent Bolt website!
foo: bar

View File

@@ -24,7 +24,7 @@
{{- item.label -}}
</a>
{% if item.submenu is defined and withsubmenus %}
{% if item.submenu and withsubmenus %}
<ul class="menu submenu vertical">
{% for submenu in item.submenu %}
{{ display_menu_item(submenu, loop) }}

View File

@@ -37,12 +37,12 @@ class FrontendMenuBuilder
$this->fieldRepository = $fieldRepository;
}
public function getMenu(string $name = ''): ?DeepCollection
public function getMenu(?string $name = null): ?DeepCollection
{
/** @var DeepCollection $menuConfig */
$menuConfig = $this->config->get('menu');
if ($name === '' && is_iterable($menuConfig)) {
if (! $name && is_iterable($menuConfig)) {
$menu = $menuConfig->first();
} elseif ($name !== '' && isset($menuConfig[$name])) {
$menu = $menuConfig[$name];

View File

@@ -0,0 +1,7 @@
Feature: Frontend menu
@wip
Scenario: As a user I want to see the menu in the frontend
When I visit the "homepage" page
Then there is element "menu_first" with text "Home"
And there is element "menu_last" with text "The Bolt site"
And there are "eq 4" "menu_sub" elements

View File

@@ -11,6 +11,11 @@ class HomepagePage extends BasePage {
this.search_input = $('#searchform-inline input[name="searchTerm"');
this.search_button = $('#searchform-inline button');
// Attributes for testing the menu
this.menu_first = $('ul.menu li.first');
this.menu_sub = $$('ul.menu li.has-submenu li');
this.menu_last = $('ul.menu li.last a.bolt-site');
}
}