0001-Add-system-tests-for-inline-autocomplete.patch

Marius BALTEANU, 2020-12-05 16:50

Download (5.02 KB)

View differences:

test/system/inline_autocomplete_test.rb
1
# frozen_string_literal: true
2

  
3
# Redmine - project management software
4
# Copyright (C) 2006-2020  Jean-Philippe Lang
5
#
6
# This program is free software; you can redistribute it and/or
7
# modify it under the terms of the GNU General Public License
8
# as published by the Free Software Foundation; either version 2
9
# of the License, or (at your option) any later version.
10
#
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
# GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License
17
# along with this program; if not, write to the Free Software
18
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19

  
20
require File.expand_path('../../application_system_test_case', __FILE__)
21

  
22
class InlineAutocompleteSystemTest < ApplicationSystemTestCase
23
  fixtures :projects, :users, :email_addresses, :roles, :members, :member_roles,
24
           :trackers, :projects_trackers, :enabled_modules, :issue_statuses, :issues,
25
           :enumerations, :custom_fields, :custom_values, :custom_fields_trackers,
26
           :watchers, :journals, :journal_details, :versions,
27
           :workflows
28

  
29
  def test_inline_autocomplete_for_issues
30
    log_user('jsmith', 'jsmith')
31
    visit 'issues/new'
32

  
33
    fill_in 'Description', :with => '#'
34

  
35
    within('.tribute-container') do
36
      assert page.has_text? "Bug #12: Closed issue on a locked version"
37
      assert page.has_text? "Bug #1: Cannot print recipes"
38

  
39
      first('li').click
40
    end
41

  
42
    assert_equal find('#issue_description').value, "#12 "
43
  end
44

  
45
  def test_inline_autocomplete_filters_autocomplete_items
46
    log_user('jsmith', 'jsmith')
47
    visit 'issues/new'
48

  
49
    fill_in 'Description', :with => '#Closed'
50

  
51
    within('.tribute-container') do
52
      assert page.has_text? "Bug #12: Closed issue on a locked version"
53
      assert page.has_text? "Bug #11: Closed issue on a closed version"
54
      assert_not page.has_text? "Bug #1: Cannot print recipes"
55
    end
56
  end
57

  
58
  def test_inline_autocomplete_on_issue_edit_description_should_show_autocomplete
59
    log_user('jsmith', 'jsmith')
60
    visit 'issues/1/edit'
61

  
62
    within('#issue-form') do
63
      click_link('Edit', match: :first)
64
      fill_in 'Description', :with => '#'
65
    end
66

  
67
    page.has_css?('.tribute-container li', minimum: 1)
68
  end
69

  
70
  def test_inline_autocomplete_on_issue_edit_notes_should_show_autocomplete
71
    log_user('jsmith', 'jsmith')
72
    visit 'issues/1/edit'
73

  
74
    # Prevent random fails because the element is not yet enabled
75
    find('#issue_notes').click
76
    fill_in 'issue[notes]', :with => '#'
77

  
78
    page.has_css?('.tribute-container li', minimum: 1)
79
  end
80

  
81
  def test_inline_autocomplete_on_issue_custom_field_with_full_text_formatting_should_show_autocomplete
82
    IssueCustomField.create!(
83
      :name => 'Full width field',
84
      :field_format => 'text', :full_width_layout => '1',
85
      :tracker_ids => [1], :is_for_all => true, :text_formatting => 'full'
86
    )
87

  
88
    log_user('jsmith', 'jsmith')
89
    visit 'issues/new'
90

  
91
    fill_in 'Full width field', :with => '#'
92

  
93
    page.has_css?('.tribute-container li', minimum: 1)
94
  end
95

  
96
  def test_inline_autocomplete_on_wiki_should_show_autocomplete
97
    log_user('jsmith', 'jsmith')
98
    visit 'projects/ecookbook/wiki/CookBook_documentation/edit'
99

  
100
    # Prevent random fails because the element is not yet enabled
101
    find('.wiki-edit').click
102
    fill_in 'content[text]', :with => '#'
103

  
104
    page.has_css?('.tribute-container li', minimum: 1)
105
  end
106

  
107
  def test_inline_autocomplete_on_news_description_should_show_autocomplete
108
    log_user('jsmith', 'jsmith')
109
    visit 'projects/ecookbook/news'
110

  
111
    click_link 'Add news'
112

  
113
    # Prevent random fails because the element is not yet enabled
114
    find('.wiki-edit').click
115
    fill_in 'Description', :with => '#'
116

  
117
    page.has_css?('.tribute-container li', minimum: 1)
118
  end
119

  
120
  def test_inline_autocomplete_on_new_message_description_should_show_autocomplete
121
    log_user('jsmith', 'jsmith')
122
    visit 'projects/ecookbook/boards/1'
123

  
124
    click_link 'New message'
125

  
126
    # Prevent random fails because the element is not yet enabled
127
    find('.wiki-edit').click
128
    fill_in 'message[content]', :with => '#'
129

  
130
    page.has_css?('.tribute-container li', minimum: 1)
131
  end
132
end
0
-