Project

General

Profile

Actions

Defect #40683

closed

InlineAutocompleteSystemTest#test_inline_autocomplete_for_issues_with_double_hash_keep_syntax failure after #40237 fix

Added by Ko Nagase 7 months ago. Updated 4 months ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Text formatting
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Fixed
Affected version:

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"=>""}
      
but after #40237 fix, controller side can receive after # 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

Related to Redmine - Defect #38852: ## issue syntax is not kept when selecting an issue from the inline autocompleteClosedMarius BĂLTEANU

Actions
Actions #1

Updated by Ko Nagase 7 months ago

I attached above diff as 1st patch and another system test stabilization fix on my macOS environment as 2nd patch.

Actions #2

Updated by Ko Nagase 7 months ago

Sorry, I missed to attached wrong one as 1st patch...
I attached it with this comment.

Actions #3

Updated by Go MAEDA 7 months ago

  • Status changed from New to Confirmed
Actions #4

Updated by Go MAEDA 7 months ago

  • Related to Defect #38852: ## issue syntax is not kept when selecting an issue from the inline autocomplete added
Actions #5

Updated by Go MAEDA 4 months ago

  • Status changed from Confirmed to Closed
  • Resolution set to Fixed

Fixed in r23008.

Actions

Also available in: Atom PDF