Defect #40683
closedInlineAutocompleteSystemTest#test_inline_autocomplete_for_issues_with_double_hash_keep_syntax failure after #40237 fix
0%
Description
After #40237 (Error in autocomplete (`ActionController::BadRequest (Invalid query parameters: invalid %-encoding (%)`)
) patch was merged, following #38852 (## issue syntax is not kept when selecting an issue from the inline autocomplete
) patch's system test seems to start failing.
def test_inline_autocomplete_for_issues_with_double_hash_keep_syntax
log_user('admin', 'admin')
visit 'projects/ecookbook/issues/new'
fill_in 'Description', :with => '##Closed'
within('.tribute-container') do
assert page.has_text? 'Bug #12: Closed issue on a locked version'
assert page.has_text? 'Bug #11: Closed issue on a closed version'
assert page.has_text? 'Bug #8: Closed issue'
:
Before #40237 fix, controller side couldn't receive after #
parameter in the url,
- JavaScript sends url:
/issues/auto_complete?project_id=ecookbook&q=#Close
- Controller receives url/params:
Started GET "/issues/auto_complete?project_id=ecookbook&q=" for 127.0.0.1 at 2024-05-12 22:41:35 +0900 Processing by AutoCompletesController#issues as */* Parameters: {"project_id"=>"ecookbook", "q"=>""}
#
parameter in the url.
- JavaScript sends url:
/issues/auto_complete?project_id=ecookbook&q=%23Close
- Controller receives url/params:
Started GET "/issues/auto_complete?project_id=ecookbook&q=%23Close" for 127.0.0.1 at 2024-05-12 22:41:54 +0900 Processing by AutoCompletesController#issues as */* Parameters: {"project_id"=>"ecookbook", "q"=>"#Close"}
Then, querying #Close
returns nothing (empty array) because there is no issues which include whole words.
https://www.redmine.org/projects/redmine/repository/svn/entry/trunk/app/controllers/auto_completes_controller.rb#L32
:
if q.present?
if q =~ /\A#?(\d+)\z/
issues << scope.find_by(:id => $1.to_i)
end
issues += scope.like(q).order(:id => :desc).limit(10).to_a
issues.compact!
else
issues += scope.order(:id => :desc).limit(10).to_a
end
:
I think that just system test side input/output adjustment is enough (to pass above regexp (/\A#?(\d+)\z/
) part code), but I am not sure whether this is correct solution, so someone reviewing this is helpful.
--- a/test/system/inline_autocomplete_test.rb
+++ b/test/system/inline_autocomplete_test.rb
@@ -47,12 +47,10 @@ class InlineAutocompleteSystemTest < ApplicationSystemTestCase
log_user('admin', 'admin')
visit 'projects/ecookbook/issues/new'
- fill_in 'Description', :with => '##Closed'
+ fill_in 'Description', :with => '##12'
within('.tribute-container') do
assert page.has_text? 'Bug #12: Closed issue on a locked version'
- assert page.has_text? 'Bug #11: Closed issue on a closed version'
- assert page.has_text? 'Bug #8: Closed issue'
first('li').click
end
Files
Related issues
Updated by Ko Nagase 6 months ago
- File 0001-Upgrade-webdrivers.patch 0001-Upgrade-webdrivers.patch added
- File 0002-Stabilize-inline-autocomplete-system-test.patch 0002-Stabilize-inline-autocomplete-system-test.patch added
I attached above diff as 1st patch and another system test stabilization fix on my macOS environment as 2nd patch.
Updated by Ko Nagase 6 months ago
- File 0001-Fix-double-hash-keep-syntax-test-for-inline-autocomp.patch 0001-Fix-double-hash-keep-syntax-test-for-inline-autocomp.patch added
Sorry, I missed to attached wrong one as 1st patch...
I attached it with this comment.
Updated by Go MAEDA 6 months ago
- Related to Defect #38852: ## issue syntax is not kept when selecting an issue from the inline autocomplete added