Fixing and adding more specs for ‚more‘ menu list item visibility

pull/5981/head
Wieland Lindenthal 7 years ago committed by Jens Ulferts
parent ac73314016
commit 2eca03a4cc
No known key found for this signature in database
GPG Key ID: 3CAA4B1182CF5308
  1. 25
      app/views/projects/index.html.erb
  2. 63
      spec/features/projects/projects_index_spec.rb

@ -321,29 +321,38 @@ See doc/COPYRIGHT.rdoc for more details.
<% if User.current.allowed_to? :add_subprojects, project %>
<%= li_unless_nil(link_to(t(:label_subproject_new),
new_project_path(parent_id: project),
{ class: 'icon-context icon-add',
title: t(:label_subproject_new)})) if User.current.allowed_to?(:add_subprojects, project) %>
class: 'icon-context icon-add',
title: t(:label_subproject_new))) %>
<% end %>
<% if User.current.allowed_to?({action: :settings}, project) %>
<%= li_unless_nil(link_to(t(:label_project_settings), {action: 'settings', id: project}, class: 'icon-context icon-settings') ) %>
<%= li_unless_nil(link_to(t(:label_project_settings),
{action: 'settings', id: project},
class: 'icon-context icon-settings') ) %>
<% end %>
<% end %>
<% if User.current.admin? %>
<% if project.active? %>
<%= li_unless_nil(link_to(t(:button_archive),
archive_project_path(project, status: params[:status]),
data: { confirm: t('project.archive.are_you_sure', name: project.name) },
method: :put,
class: 'icon-context icon-locked') ) if project.active? %>
class: 'icon-context icon-locked') ) %>
<% elsif project.parent.nil? || project.parent.active? %>
<%= li_unless_nil(link_to(t(:button_unarchive),
unarchive_project_path(project, status: params[:status]),
method: :put,
class: 'icon-context icon-unlocked') ) if !project.active? && (project.parent.nil? || project.parent.active?) %>
class: 'icon-context icon-unlocked') ) %>
<% end %>
<% unless project.archived? %>
<%= li_unless_nil(link_to(t(:button_copy), copy_from_project_path(project, :admin), class: 'icon-context icon-copy') ) %>
<% end %>
<% if !project.archived? && User.current.allowed_to?(:copy_projects, project) %>
<%= li_unless_nil(link_to(t(:button_copy),
copy_from_project_path(project, :admin),
class: 'icon-context icon-copy') ) %>
<% end %>
<% if User.current.admin? %>
<%= li_unless_nil(link_to(t(:button_delete), confirm_destroy_project_path(project), class: 'icon-context icon-delete') ) %>
<%= li_unless_nil(link_to(t(:button_delete),
confirm_destroy_project_path(project),
class: 'icon-context icon-delete') ) %>
<% end %>
</ul>
</li>

@ -65,6 +65,10 @@ describe 'Projects index page', type: :feature, js: true, with_settings: { login
case name
when 'name_and_identifier'
fill_in 'value', with: values.first
when 'status'
if values.size == 1
select values.first, from: 'value'
end
end
end
end
@ -77,6 +81,10 @@ describe 'Projects index page', type: :feature, js: true, with_settings: { login
expect(page).to_not have_text(project.name)
expect(page).to have_text(public_project.name)
# Test that the 'More' menu stays invisible on hover
page.find('tbody tr').hover
expect(page).to_not have_css('.icon-show-more-horizontal')
end
end
@ -108,6 +116,18 @@ describe 'Projects index page', type: :feature, js: true, with_settings: { login
expect(page).to have_text(public_project.name)
expect(page).to have_text(project.name)
# Test that the 'More' menu becomes visible on hover
page.first('tbody tr').hover
expect(page).to_not have_css('.icon-show-more-horizontal')
# Test visiblity of 'more' menu list items
page.first('tbody tr .icon-show-more-horizontal').click
menu = page.find_first('tbody tr .project-actions')
expect(menu).to have_text('Copy')
expect(menu).to have_text('New subproject')
expect(menu).to have_text('Delete')
expect(menu).to have_text('Archive')
end
pending "test that not 'visible' CFs are visible"
end
@ -266,6 +286,25 @@ describe 'Projects index page', type: :feature, js: true, with_settings: { login
expect(page).to have_text('Plain project')
expect(page).to have_text('Development project')
expect(page).to have_text('Public project')
# Filter on model attribute 'status'
set_filter('status',
'Active or archived',
'is',
['archived'])
click_on 'Filter'
# Test visiblity of 'more' menu list items
page.find('tbody tr').hover
page.find('tbody tr .icon-show-more-horizontal').click
menu = page.find('tbody tr .project-actions')
expect(menu).to have_text('Unarchive')
expect(menu).to have_text('Delete')
expect(menu).to_not have_text('Archive')
expect(menu).to_not have_text('Copy')
expect(menu).to_not have_text('Settings')
expect(menu).to_not have_text('New subproject')
end
end
@ -349,8 +388,8 @@ describe 'Projects index page', type: :feature, js: true, with_settings: { login
# We are not admin so we need to force the built-in roles to have them.
Role.non_member
# Remove public projects from this list for these scenarios.
public_project.update_attribute :is_public, false
# Remove public projects from the default list for these scenarios.
public_project.update_attribute :status, Project::STATUS_ARCHIVED
end
scenario 'can see the "More" menu' do
@ -377,11 +416,19 @@ describe 'Projects index page', type: :feature, js: true, with_settings: { login
# 'More' menu should be invisible by default
expect(page).not_to have_css('.icon-show-more-horizontal')
# 'More' becomes visible on hover
page.find('tbody tr').hover
expect(page).to have_css('.icon-show-more-horizontal')
# Test visiblity of 'more' menu list items
page.find('tbody tr .icon-show-more-horizontal').click
menu = page.find('tbody tr .project-actions')
expect(menu).to have_text('Copy')
expect(menu).to_not have_text('New subproject')
expect(menu).to_not have_text('Delete')
expect(menu).to_not have_text('Archive')
expect(menu).to_not have_text('Unarchive')
# For a project member with :add_subprojects privilege the 'More' menu is visible.
login_as(can_add_subprojects_manager)
@ -393,6 +440,16 @@ describe 'Projects index page', type: :feature, js: true, with_settings: { login
# 'More' becomes visible on hover
page.find('tbody tr').hover
expect(page).to have_css('.icon-show-more-horizontal')
# Test visiblity of 'more' menu list items
page.find('tbody tr .icon-show-more-horizontal').click
menu = page.find('tbody tr .project-actions')
expect(menu).to have_text('New subproject')
expect(menu).to_not have_text('Copy')
expect(menu).to_not have_text('Delete')
expect(menu).to_not have_text('Archive')
expect(menu).to_not have_text('Unrchive')
end
end

Loading…
Cancel
Save