Commit 13d3e75a authored by Nick Kipling's avatar Nick Kipling

Fixes wrong title for type and updated tests

parent 91294fbd
......@@ -9,7 +9,7 @@ module Groups
def index
@packages = ::Packages::GroupPackagesFinder.new(current_user, group)
.execute
.sort_by_attribute(@sort = params[:sort] || 'created_desc')
.sort_by_attribute(@sort = params[:sort] || sort_value_recently_created)
.page(params[:page])
end
......
......@@ -72,7 +72,7 @@ module EE
sort_value_name_desc => sort_title_name,
sort_value_version_desc => sort_title_version,
sort_value_version_asc => sort_title_version,
sort_value_type_desc => sort_value_type_desc,
sort_value_type_desc => sort_title_type,
sort_value_type_asc => sort_title_type,
sort_value_project_name_desc => sort_title_project_name,
sort_value_project_name_asc => sort_title_project_name
......
......@@ -7,7 +7,7 @@
.dropdown.inline.prepend-top-default.append-bottom-default.package-sort-dropdown
.btn-group{ role: 'group' }
.btn-group{ role: 'group' }
%button.dropdown-menu-toggle{ type: 'button', data: { toggle: 'dropdown', display: 'static' }, class: 'btn btn-default' }
%button.dropdown-menu-toggle{ type: 'button', data: { toggle: 'dropdown', display: 'static', 'qa-selector': 'sort-dropdown-button' }, class: 'btn btn-default' }
= sort_title
= icon('chevron-down')
%ul.dropdown-menu.dropdown-menu-right.dropdown-menu-selectable.dropdown-menu-sort
......@@ -32,7 +32,7 @@
.table-section.section-20{ role: 'rowheader' }
= _('Created')
- @packages.each do |package|
.gl-responsive-table-row.package-row
.gl-responsive-table-row{ data: { 'qa-selector': 'package-row' } }
.table-section.section-30
.table-mobile-header{ role: "rowheader" }= _("Name")
.table-mobile-content.flex-truncate-parent
......
......@@ -78,49 +78,57 @@ describe 'Group Packages' do
end
it 'sorts by created date descending' do
visit group_packages_path(group, sort: sort_value_created_date)
visit group_packages_path(group, sort: sort_value_recently_created)
expect(sort_dropdown_button_text).to eq(sort_title_created_date)
expect(first_package).to include(bbb_package.name)
expect(last_package).to include(aaa_package.name)
end
it 'sorts by created date ascending' do
visit group_packages_path(group, sort: sort_value_oldest_created)
expect(sort_dropdown_button_text).to eq(sort_title_created_date)
expect(first_package).to include(aaa_package.name)
expect(last_package).to include(bbb_package.name)
end
it 'sorts by name descending' do
visit group_packages_path(group, sort: sort_value_name_desc)
expect(sort_dropdown_button_text).to eq(sort_title_name)
expect(first_package).to include(bbb_package.name)
expect(last_package).to include(aaa_package.name)
end
it 'sorts by name ascending' do
visit group_packages_path(group, sort: sort_value_name)
expect(sort_dropdown_button_text).to eq(sort_title_name)
expect(first_package).to include(aaa_package.name)
expect(last_package).to include(bbb_package.name)
end
it 'sorts by version descending' do
visit group_packages_path(group, sort: sort_value_version_desc)
expect(sort_dropdown_button_text).to eq(sort_title_version)
expect(first_package).to include(bbb_package.name)
expect(last_package).to include(aaa_package.name)
end
it 'sorts by version ascending' do
visit group_packages_path(group, sort: sort_value_version_asc)
expect(sort_dropdown_button_text).to eq(sort_title_version)
expect(first_package).to include(aaa_package.name)
expect(last_package).to include(bbb_package.name)
end
it 'sorts by project descending' do
visit group_packages_path(group, sort: sort_value_project_name_desc)
expect(sort_dropdown_button_text).to eq(sort_title_project_name)
expect(first_package).to include(bbb_package.name)
expect(last_package).to include(aaa_package.name)
end
it 'sorts by project ascending' do
visit group_packages_path(group, sort: sort_value_project_name_asc)
expect(sort_dropdown_button_text).to eq(sort_title_project_name)
expect(first_package).to include(aaa_package.name)
expect(last_package).to include(bbb_package.name)
end
......@@ -132,12 +140,14 @@ describe 'Group Packages' do
it 'sorts by type descending' do
visit group_packages_path(group, sort: sort_value_type_desc)
expect(sort_dropdown_button_text).to eq(sort_title_type)
expect(first_package).to include(npm_package.name)
expect(last_package).to include(maven_package.name)
end
it 'sorts by type ascending' do
visit group_packages_path(group, sort: sort_value_type_asc)
expect(sort_dropdown_button_text).to eq(sort_title_type)
expect(first_package).to include(maven_package.name)
expect(last_package).to include(npm_package.name)
end
......@@ -148,10 +158,14 @@ describe 'Group Packages' do
end
def first_package
page.all('.table-holder .package-row').first.text
page.all('[data-qa-selector="package-row"]').first.text
end
def last_package
page.all('.table-holder .package-row').last.text
page.all('[data-qa-selector="package-row"]').last.text
end
def sort_dropdown_button_text
page.find('[data-qa-selector="sort-dropdown-button"]').text
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