diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2018-09-11 17:54:13 +0300 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2018-09-11 17:54:13 +0300 |
commit | b21625a9783e75365a309a8e48b06a1494fc3680 (patch) | |
tree | 8566e2c9bf735e4d61dca17c2db6bf8f637c66df /spec/features | |
parent | 44931bd23d4e750b1bd690adaaa2fd2b40154117 (diff) | |
parent | 8d19f4b4a610d4c26c685c5069b91c6636590c76 (diff) |
Merge branch '50835-add-filtering-sorting-for-labels-on-labels-page' into 'master'
Add sorting for labels on labels page
See merge request gitlab-org/gitlab-ce!21642
Diffstat (limited to 'spec/features')
-rw-r--r-- | spec/features/groups/labels/sort_labels_spec.rb | 48 | ||||
-rw-r--r-- | spec/features/projects/labels/sort_labels_spec.rb | 48 |
2 files changed, 96 insertions, 0 deletions
diff --git a/spec/features/groups/labels/sort_labels_spec.rb b/spec/features/groups/labels/sort_labels_spec.rb new file mode 100644 index 00000000000..2aea4d77675 --- /dev/null +++ b/spec/features/groups/labels/sort_labels_spec.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'Sort labels', :js do + let(:user) { create(:user) } + let(:group) { create(:group) } + let!(:label1) { create(:group_label, title: 'Foo', description: 'Lorem ipsum', group: group) } + let!(:label2) { create(:group_label, title: 'Bar', description: 'Fusce consequat', group: group) } + + before do + group.add_maintainer(user) + sign_in(user) + + visit group_labels_path(group) + end + + it 'sorts by title by default' do + expect(page).to have_button('Name') + + # assert default sorting + within '.other-labels' do + expect(page.all('.label-list-item').first.text).to include('Bar') + expect(page.all('.label-list-item').last.text).to include('Foo') + end + end + + it 'sorts by date' do + click_button 'Name' + + sort_options = find('ul.dropdown-menu-sort li').all('a').collect(&:text) + + expect(sort_options[0]).to eq('Name') + expect(sort_options[1]).to eq('Name, descending') + expect(sort_options[2]).to eq('Last created') + expect(sort_options[3]).to eq('Oldest created') + expect(sort_options[4]).to eq('Last updated') + expect(sort_options[5]).to eq('Oldest updated') + + click_link 'Name, descending' + + # assert default sorting + within '.other-labels' do + expect(page.all('.label-list-item').first.text).to include('Foo') + expect(page.all('.label-list-item').last.text).to include('Bar') + end + end +end diff --git a/spec/features/projects/labels/sort_labels_spec.rb b/spec/features/projects/labels/sort_labels_spec.rb new file mode 100644 index 00000000000..01c3f251173 --- /dev/null +++ b/spec/features/projects/labels/sort_labels_spec.rb @@ -0,0 +1,48 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'Sort labels', :js do + let(:user) { create(:user) } + let(:project) { create(:project) } + let!(:label1) { create(:label, title: 'Foo', description: 'Lorem ipsum', project: project) } + let!(:label2) { create(:label, title: 'Bar', description: 'Fusce consequat', project: project) } + + before do + project.add_maintainer(user) + sign_in(user) + + visit project_labels_path(project) + end + + it 'sorts by title by default' do + expect(page).to have_button('Name') + + # assert default sorting + within '.other-labels' do + expect(page.all('.label-list-item').first.text).to include('Bar') + expect(page.all('.label-list-item').last.text).to include('Foo') + end + end + + it 'sorts by date' do + click_button 'Name' + + sort_options = find('ul.dropdown-menu-sort li').all('a').collect(&:text) + + expect(sort_options[0]).to eq('Name') + expect(sort_options[1]).to eq('Name, descending') + expect(sort_options[2]).to eq('Last created') + expect(sort_options[3]).to eq('Oldest created') + expect(sort_options[4]).to eq('Last updated') + expect(sort_options[5]).to eq('Oldest updated') + + click_link 'Name, descending' + + # assert default sorting + within '.other-labels' do + expect(page.all('.label-list-item').first.text).to include('Foo') + expect(page.all('.label-list-item').last.text).to include('Bar') + end + end +end |