2021-09-04 01:27:46 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2023-03-04 22:38:38 +05:30
|
|
|
RSpec.describe 'top nav responsive', :js, feature_category: :navigation do
|
2021-09-04 01:27:46 +05:30
|
|
|
include MobileHelpers
|
2023-06-20 00:43:36 +05:30
|
|
|
include Features::InviteMembersModalHelpers
|
2021-09-04 01:27:46 +05:30
|
|
|
|
|
|
|
let_it_be(:user) { create(:user) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
|
|
|
|
resize_screen_xs
|
|
|
|
end
|
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
context 'when outside groups and projects' do
|
|
|
|
before do
|
|
|
|
visit explore_projects_path
|
|
|
|
end
|
2021-09-04 01:27:46 +05:30
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
context 'when menu is closed' do
|
|
|
|
it 'has page content and hides responsive menu', :aggregate_failures do
|
2023-05-27 22:25:52 +05:30
|
|
|
expect(page).to have_css('.page-title', text: 'Explore projects')
|
2023-06-20 00:43:36 +05:30
|
|
|
expect(page).to have_link('Homepage', id: 'logo')
|
2023-04-23 21:23:45 +05:30
|
|
|
|
|
|
|
expect(page).to have_no_css('.top-nav-responsive')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when menu is opened' do
|
|
|
|
before do
|
|
|
|
click_button('Menu')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'hides everything and shows responsive menu', :aggregate_failures do
|
2023-05-27 22:25:52 +05:30
|
|
|
expect(page).to have_no_css('.page-title', text: 'Explore projects')
|
2023-06-20 00:43:36 +05:30
|
|
|
expect(page).to have_no_link('Homepage', id: 'logo')
|
2023-04-23 21:23:45 +05:30
|
|
|
|
|
|
|
within '.top-nav-responsive' do
|
|
|
|
expect(page).to have_link(nil, href: search_path)
|
|
|
|
expect(page).to have_button('Projects')
|
|
|
|
expect(page).to have_button('Groups')
|
2023-05-27 22:25:52 +05:30
|
|
|
expect(page).to have_link('Your work', href: dashboard_projects_path)
|
|
|
|
expect(page).to have_link('Explore', href: explore_projects_path)
|
2023-04-23 21:23:45 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'has new dropdown', :aggregate_failures do
|
|
|
|
create_new_button.click
|
|
|
|
|
|
|
|
expect(page).to have_link('New project', href: new_project_path)
|
|
|
|
expect(page).to have_link('New group', href: new_group_path)
|
|
|
|
expect(page).to have_link('New snippet', href: new_snippet_path)
|
|
|
|
end
|
2021-09-04 01:27:46 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
context 'when inside a project' do
|
|
|
|
let_it_be(:project) { create(:project).tap { |record| record.add_owner(user) } }
|
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
before do
|
2023-04-23 21:23:45 +05:30
|
|
|
visit project_path(project)
|
2021-09-04 01:27:46 +05:30
|
|
|
end
|
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
it 'the add menu contains invite members dropdown option and opens invite modal' do
|
2023-04-23 21:23:45 +05:30
|
|
|
invite_members_from_menu
|
2021-09-04 01:27:46 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
page.within invite_modal_selector do
|
|
|
|
expect(page).to have_content("You're inviting members to the #{project.name} project")
|
|
|
|
end
|
2023-04-23 21:23:45 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when inside a group' do
|
|
|
|
let_it_be(:group) { create(:group).tap { |record| record.add_owner(user) } }
|
|
|
|
|
|
|
|
before do
|
|
|
|
visit group_path(group)
|
2021-09-04 01:27:46 +05:30
|
|
|
end
|
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
it 'the add menu contains invite members dropdown option and opens invite modal' do
|
2023-04-23 21:23:45 +05:30
|
|
|
invite_members_from_menu
|
2021-09-04 01:27:46 +05:30
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
page.within invite_modal_selector do
|
|
|
|
expect(page).to have_content("You're inviting members to the #{group.name} group")
|
|
|
|
end
|
2021-09-04 01:27:46 +05:30
|
|
|
end
|
|
|
|
end
|
2023-04-23 21:23:45 +05:30
|
|
|
|
|
|
|
def invite_members_from_menu
|
|
|
|
click_button('Menu')
|
|
|
|
create_new_button.click
|
|
|
|
|
2023-05-27 22:25:52 +05:30
|
|
|
click_button('Invite members')
|
2023-04-23 21:23:45 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def create_new_button
|
|
|
|
find('[data-testid="plus-icon"]')
|
|
|
|
end
|
2021-09-04 01:27:46 +05:30
|
|
|
end
|