diff options
Diffstat (limited to 'spec/lib/sidebars/user_profile')
10 files changed, 138 insertions, 0 deletions
diff --git a/spec/lib/sidebars/user_profile/menus/activity_menu_spec.rb b/spec/lib/sidebars/user_profile/menus/activity_menu_spec.rb new file mode 100644 index 00000000000..6689b8b2da3 --- /dev/null +++ b/spec/lib/sidebars/user_profile/menus/activity_menu_spec.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Sidebars::UserProfile::Menus::ActivityMenu, feature_category: :navigation do + it_behaves_like 'User profile menu', + title: s_('UserProfile|Activity'), + icon: 'history', + active_route: 'users#activity' do + let(:link) { "/users/#{user.username}/activity" } + end +end diff --git a/spec/lib/sidebars/user_profile/menus/contributed_projects_menu_spec.rb b/spec/lib/sidebars/user_profile/menus/contributed_projects_menu_spec.rb new file mode 100644 index 00000000000..2677851247b --- /dev/null +++ b/spec/lib/sidebars/user_profile/menus/contributed_projects_menu_spec.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Sidebars::UserProfile::Menus::ContributedProjectsMenu, feature_category: :navigation do + it_behaves_like 'User profile menu', + title: s_('UserProfile|Contributed projects'), + icon: 'project', + active_route: 'users#contributed' do + let(:link) { "/users/#{user.username}/contributed" } + end +end diff --git a/spec/lib/sidebars/user_profile/menus/followers_menu_spec.rb b/spec/lib/sidebars/user_profile/menus/followers_menu_spec.rb new file mode 100644 index 00000000000..2d3d48f0a8c --- /dev/null +++ b/spec/lib/sidebars/user_profile/menus/followers_menu_spec.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Sidebars::UserProfile::Menus::FollowersMenu, feature_category: :navigation do + it_behaves_like 'User profile menu', + title: s_('UserProfile|Followers'), + icon: 'users', + active_route: 'users#followers' do + let(:link) { "/users/#{user.username}/followers" } + end + + it_behaves_like 'Followers/followees counts', :followers +end diff --git a/spec/lib/sidebars/user_profile/menus/following_menu_spec.rb b/spec/lib/sidebars/user_profile/menus/following_menu_spec.rb new file mode 100644 index 00000000000..8d8db2611e6 --- /dev/null +++ b/spec/lib/sidebars/user_profile/menus/following_menu_spec.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Sidebars::UserProfile::Menus::FollowingMenu, feature_category: :navigation do + it_behaves_like 'User profile menu', + title: s_('UserProfile|Following'), + icon: 'users', + active_route: 'users#following' do + let(:link) { "/users/#{user.username}/following" } + end + + it_behaves_like 'Followers/followees counts', :followees +end diff --git a/spec/lib/sidebars/user_profile/menus/groups_menu_spec.rb b/spec/lib/sidebars/user_profile/menus/groups_menu_spec.rb new file mode 100644 index 00000000000..989cc1ff5ce --- /dev/null +++ b/spec/lib/sidebars/user_profile/menus/groups_menu_spec.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Sidebars::UserProfile::Menus::GroupsMenu, feature_category: :navigation do + it_behaves_like 'User profile menu', + title: s_('UserProfile|Groups'), + icon: 'group', + active_route: 'users#groups' do + let(:link) { "/users/#{user.username}/groups" } + end +end diff --git a/spec/lib/sidebars/user_profile/menus/overview_menu_spec.rb b/spec/lib/sidebars/user_profile/menus/overview_menu_spec.rb new file mode 100644 index 00000000000..7cf86676892 --- /dev/null +++ b/spec/lib/sidebars/user_profile/menus/overview_menu_spec.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Sidebars::UserProfile::Menus::OverviewMenu, feature_category: :navigation do + it_behaves_like 'User profile menu', + title: s_('UserProfile|Overview'), + icon: 'overview', + active_route: 'users#show' do + let(:link) { "/#{user.username}" } + end +end diff --git a/spec/lib/sidebars/user_profile/menus/personal_projects_menu_spec.rb b/spec/lib/sidebars/user_profile/menus/personal_projects_menu_spec.rb new file mode 100644 index 00000000000..3e0bc269a66 --- /dev/null +++ b/spec/lib/sidebars/user_profile/menus/personal_projects_menu_spec.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Sidebars::UserProfile::Menus::PersonalProjectsMenu, feature_category: :navigation do + it_behaves_like 'User profile menu', + title: s_('UserProfile|Personal projects'), + icon: 'project', + active_route: 'users#projects' do + let(:link) { "/users/#{user.username}/projects" } + end +end diff --git a/spec/lib/sidebars/user_profile/menus/snippets_menu_spec.rb b/spec/lib/sidebars/user_profile/menus/snippets_menu_spec.rb new file mode 100644 index 00000000000..b2363706113 --- /dev/null +++ b/spec/lib/sidebars/user_profile/menus/snippets_menu_spec.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Sidebars::UserProfile::Menus::SnippetsMenu, feature_category: :navigation do + it_behaves_like 'User profile menu', + title: s_('UserProfile|Snippets'), + icon: 'snippet', + active_route: 'users#snippets' do + let(:link) { "/users/#{user.username}/snippets" } + end +end diff --git a/spec/lib/sidebars/user_profile/menus/starred_projects_menu_spec.rb b/spec/lib/sidebars/user_profile/menus/starred_projects_menu_spec.rb new file mode 100644 index 00000000000..aa6ad0a74e7 --- /dev/null +++ b/spec/lib/sidebars/user_profile/menus/starred_projects_menu_spec.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Sidebars::UserProfile::Menus::StarredProjectsMenu, feature_category: :navigation do + it_behaves_like 'User profile menu', + title: s_('UserProfile|Starred projects'), + icon: 'star-o', + active_route: 'users#starred' do + let(:link) { "/users/#{user.username}/starred" } + end +end diff --git a/spec/lib/sidebars/user_profile/panel_spec.rb b/spec/lib/sidebars/user_profile/panel_spec.rb new file mode 100644 index 00000000000..c62c7f9fd96 --- /dev/null +++ b/spec/lib/sidebars/user_profile/panel_spec.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +require 'spec_helper' + +RSpec.describe Sidebars::UserProfile::Panel, feature_category: :navigation do + let_it_be(:current_user) { create(:user) } + let_it_be(:user) { create(:user) } + + let(:context) { Sidebars::Context.new(current_user: current_user, container: user) } + + subject { described_class.new(context) } + + it_behaves_like 'a panel with uniquely identifiable menu items' + + it 'implements #aria_label' do + expect(subject.aria_label).to eq(s_('UserProfile|User profile navigation')) + end + + it 'implements #super_sidebar_context_header' do + expect(subject.super_sidebar_context_header).to eq({ + title: user.name, + avatar: user.avatar_url, + avatar_shape: 'circle' + }) + end +end |