1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
|
# frozen_string_literal: true
module QA
module Page
module Component
module Note
extend QA::Page::PageConcern
def self.included(base)
super
base.view 'app/assets/javascripts/diffs/components/diff_file_header.vue' do
element 'toggle-comments-button'
end
base.view 'app/assets/javascripts/notes/components/comment_form.vue' do
element 'comment-field'
end
base.view 'app/assets/javascripts/notes/components/comment_type_dropdown.vue' do
element 'comment-button'
element 'discussion-menu-item'
end
base.view 'app/assets/javascripts/notes/components/discussion_actions.vue' do
element 'discussion-reply-tab'
element 'resolve-discussion-button'
end
base.view 'app/assets/javascripts/notes/components/discussion_filter.vue' do
element 'discussion-preferences-dropdown'
element 'filter-menu-item'
end
base.view 'app/assets/javascripts/notes/components/discussion_filter_note.vue' do
element 'discussion-filter-container'
end
base.view 'app/assets/javascripts/notes/components/noteable_discussion.vue' do
element 'discussion-content'
end
base.view 'app/assets/javascripts/notes/components/noteable_note.vue' do
element 'noteable-note-container'
end
base.view 'app/assets/javascripts/notes/components/note_actions.vue' do
element 'note-edit-button'
end
base.view 'app/assets/javascripts/notes/components/note_form.vue' do
element 'reply-field'
element 'reply-comment-button'
end
base.view 'app/assets/javascripts/notes/components/note_header.vue' do
element 'system-note-content'
end
base.view 'app/assets/javascripts/notes/components/toggle_replies_widget.vue' do
element 'expand-replies-button'
element 'collapse-replies-button'
end
end
def collapse_replies
click_element 'collapse-replies-button'
end
# Attachment option should be an absolute path
def comment(text, attachment: nil, filter: :all_activities)
method("select_#{filter}_filter").call
fill_element 'comment-field', "#{text}\n"
unless attachment.nil?
QA::Page::Component::Dropzone.new(self, '.new-note')
.attach_file(attachment)
end
click_element 'comment-button'
end
def edit_comment(text)
click_element 'note-edit-button'
fill_element 'reply-field', text
click_element 'reply-comment-button'
end
def expand_replies
click_element 'expand-replies-button'
end
def has_comment?(comment_text)
has_element?(
'noteable-note-container',
text: comment_text,
wait: QA::Support::Repeater::DEFAULT_MAX_WAIT_TIME
)
end
def has_system_note?(note_text)
has_element?('system-note-content', text: note_text, wait: QA::Support::Repeater::DEFAULT_MAX_WAIT_TIME)
end
def noteable_note_item
find_element('noteable-note-container')
end
def reply_to_discussion(position, reply_text)
type_reply_to_discussion(position, reply_text)
click_element 'reply-comment-button'
end
def resolve_discussion_at_index(index)
within_element_by_index('discussion-content', index) do
click_element 'resolve-discussion-button'
end
end
def select_all_activities_filter
select_filter_with_text('Show all activity')
wait_until do
has_no_element?('discussion-filter-container') && has_element?('comment-field')
end
end
def select_comments_only_filter
select_filter_with_text('Show comments only')
wait_until do
has_no_element?('discussion-filter-container') && has_no_element?('system-note-content')
end
end
def select_history_only_filter
select_filter_with_text('Show history only')
wait_until do
has_element?('discussion-filter-container') && has_no_element?('noteable-note-container')
end
end
def start_discussion(text)
fill_element 'comment-field', text
within_element('comment-button') { click_button(class: 'gl-new-dropdown-toggle') }
click_element 'discussion-menu-item'
click_element 'comment-button'
has_comment?(text)
end
def toggle_comments(position)
all_elements('toggle-comments-button', minimum: position)[position - 1].click
end
def type_reply_to_discussion(position, reply_text)
all_elements('discussion-reply-tab', minimum: position)[position - 1].click
fill_element 'reply-field', reply_text
end
private
def select_filter_with_text(text)
retry_on_exception do
click_element('issue-title')
click_element 'discussion-preferences-dropdown'
find_element('filter-menu-item', text: text).click
wait_for_requests
end
end
end
end
end
end
|