Commit 8e151ad7 authored by Gilang Gumilar's avatar Gilang Gumilar

Create insert_before_sub_nav_item helper

parent 36047277
......@@ -35,7 +35,7 @@ describe 'Group navbar' do
before do
stub_licensed_features(cycle_analytics_for_groups: true)
insert_after_sub_nav_item(
insert_before_sub_nav_item(
_('Contribution'),
within: _('Analytics'),
new_sub_nav_item_name: _('Value Stream')
......
......@@ -18,4 +18,15 @@ module NavbarStructureHelper
index = hash[:nav_sub_items].find_index(before_sub_nav_item_name)
hash[:nav_sub_items].insert(index + 1, new_sub_nav_item_name)
end
def insert_before_sub_nav_item(after_sub_nav_item_name, within:, new_sub_nav_item_name:)
expect(structure).to include(a_hash_including(nav_item: within))
hash = structure.find { |h| h[:nav_item] == within }
expect(hash).to have_key(:nav_sub_items)
expect(hash[:nav_sub_items]).to include(after_sub_nav_item_name)
index = hash[:nav_sub_items].find_index(after_sub_nav_item_name)
hash[:nav_sub_items].insert(index, new_sub_nav_item_name)
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment