From a26af74f9f2c948f941c15586d66f506b7772b19 Mon Sep 17 00:00:00 2001 From: Wieland Lindenthal Date: Tue, 22 Jan 2019 13:54:48 +0100 Subject: [PATCH 1/2] Make global search autocmpleter spec more robust as you cannot trust that WP IDs start at 1 --- spec/features/search_spec.rb | 45 ++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/spec/features/search_spec.rb b/spec/features/search_spec.rb index 3d8de5316c..321147d879 100644 --- a/spec/features/search_spec.rb +++ b/spec/features/search_spec.rb @@ -29,39 +29,40 @@ require 'spec_helper' describe 'Search', type: :feature, js: true do + include ::Components::UIAutocompleteHelpers let(:project) { FactoryBot.create :project } let(:user) { FactoryBot.create :admin } let!(:work_packages) do (1..23).map do |n| - subject = "Subject No. #{n}" - FactoryBot.create :work_package, - subject: subject, - project: project, - created_at: "2016-11-21 #{n}:00".to_datetime, - updated_at: "2016-11-21 #{n}:00".to_datetime + Timecop.freeze("2016-11-21 #{n}:00".to_datetime) do + subject = "Subject No. #{n}" + FactoryBot.create :work_package, + subject: subject, + project: project + end end end - let(:query) { "Subject" } + let(:query) { 'Subject' } + + let(:params) { [project, { q: query }] } def expect_range(a, b) (a..b).each do |n| expect(page.body).to include("No. #{n}") - expect(page.body).to have_selector("a[href*='#{work_package_path(work_packages[n-1].id)}']") + expect(page.body).to have_selector("a[href*='#{work_package_path(work_packages[n - 1].id)}']") end end before do login_as user - visit search_path(project, q: query) + visit search_path(*params) end describe 'autocomplete' do - include ::Components::UIAutocompleteHelpers - - let!(:other_work_package) { FactoryBot.create(:work_package, subject: "Other work package", project: project) } + let!(:other_work_package) { FactoryBot.create(:work_package, subject: 'Other work package', project: project) } it 'provides suggestions' do page.find('#top-menu-search-button').click @@ -69,12 +70,19 @@ describe 'Search', type: :feature, js: true do suggestions = search_autocomplete(page.find('.top-menu-search--input'), query: query, results_selector: '.search-autocomplete--results') + # Suggestions shall show latest WPs first. expect(suggestions).to have_text('No. 23', wait: 10) - expect(suggestions).to_not have_text('No. 13') + # and show maximum 10 suggestions. + expect(suggestions).to_not have_text('No. 10') + # and unrelated work packages shall not get suggested + expect(suggestions).to_not have_text(other_work_package.subject) target_work_package = work_packages.last + + # Expect redirection when WP is selected from results select_autocomplete(page.find('.top-menu-search--input'), query: target_work_package.subject, + select_text: "##{target_work_package.id}", results_selector: '.search-autocomplete--results') expect(current_path).to match /work_packages\/#{target_work_package.id}\// @@ -82,20 +90,17 @@ describe 'Search', type: :feature, js: true do first_wp = work_packages.first + # Typing a work package id shall find that work package suggestions = search_autocomplete(page.find('.top-menu-search--input'), query: first_wp.id.to_s, results_selector: '.search-autocomplete--results') - expect(suggestions).to have_text("No. 1") - - suggestions = search_autocomplete(page.find('.top-menu-search--input'), - query: "1", - results_selector: '.search-autocomplete--results') - expect(suggestions).to have_text("No. 11") + expect(suggestions).to have_text('No. 1') + # Typing a hash sign before an ID shall only suggest that work package and (no hits within the subject) suggestions = search_autocomplete(page.find('.top-menu-search--input'), query: "##{first_wp.id}", results_selector: '.search-autocomplete--results') - expect(suggestions).to_not have_text("No. 11") + expect(suggestions).to have_text("Subject", count: 1) end end From 9b362643b2342dc5ff4f843b83b5b4393b92abaa Mon Sep 17 00:00:00 2001 From: Travis CI User Date: Wed, 30 Jan 2019 16:15:53 +0000 Subject: [PATCH 2/2] update locales from crowdin [ci skip] --- config/locales/crowdin/js-lol.yml | 4 ++-- config/locales/crowdin/lol.yml | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/config/locales/crowdin/js-lol.yml b/config/locales/crowdin/js-lol.yml index 0e083c08a1..530eb24dde 100644 --- a/config/locales/crowdin/js-lol.yml +++ b/config/locales/crowdin/js-lol.yml @@ -691,8 +691,8 @@ lol: days: crwdns107996:0crwdne107996:0 weeks: crwdns107998:0crwdne107998:0 months: crwdns108000:0crwdne108000:0 - label_switch_to_single_select: crwdns111750:0crwdne111750:0 - label_switch_to_multi_select: crwdns111752:0crwdne111752:0 + label_switch_to_single_select: crwdns111942:0crwdne111942:0 + label_switch_to_multi_select: crwdns111944:0crwdne111944:0 toolbar: settings: configure_view: crwdns108002:0crwdne108002:0 diff --git a/config/locales/crowdin/lol.yml b/config/locales/crowdin/lol.yml index e391d0d918..b44c25c9a1 100644 --- a/config/locales/crowdin/lol.yml +++ b/config/locales/crowdin/lol.yml @@ -2583,7 +2583,7 @@ lol: revoke_my_application_confirmation: Do you really want to remove this application? This will revoke %{token_count} active for it. my_registered_applications: Registered OAuth applications - button_remove_widget: crwdns111742:0crwdne111742:0 - label_my_page_block: crwdns111744:0crwdne111744:0 - label_responsible_for_work_packages: crwdns111746:0crwdne111746:0 - label_visible_elements: crwdns111748:0crwdne111748:0 + button_remove_widget: crwdns111934:0crwdne111934:0 + label_my_page_block: crwdns111936:0crwdne111936:0 + label_responsible_for_work_packages: crwdns111938:0crwdne111938:0 + label_visible_elements: crwdns111940:0crwdne111940:0