blob: 7541baed467a60c97e33ae7dcbed9d48b446200d (
plain)
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
|
# frozen_string_literal: true
module QA
module Page
module Project
module WebIDE
class Edit < Page::Base
include Page::Component::DropdownFilter
view 'app/assets/javascripts/ide/components/activity_bar.vue' do
element :commit_mode_tab
end
view 'app/assets/javascripts/ide/components/ide_tree.vue' do
element :new_file
end
view 'app/assets/javascripts/ide/components/ide_tree_list.vue' do
element :file_list
end
view 'app/assets/javascripts/ide/components/new_dropdown/modal.vue' do
element :full_file_path
element :new_file_modal
element :template_list
end
view 'app/assets/javascripts/ide/components/file_templates/bar.vue' do
element :file_templates_bar
element :file_template_dropdown
end
view 'app/assets/javascripts/ide/components/file_templates/dropdown.vue' do
element :dropdown_filter_input
end
view 'app/assets/javascripts/ide/components/commit_sidebar/actions.vue' do
element :commit_to_current_branch_radio
end
view 'app/assets/javascripts/ide/components/commit_sidebar/form.vue' do
element :begin_commit_button
element :commit_button
end
view 'app/assets/javascripts/ide/components/commit_sidebar/new_merge_request_option.vue' do
element :start_new_mr_checkbox
end
def has_file?(file_name)
within_element(:file_list) do
page.has_content? file_name
end
end
def create_new_file_from_template(file_name, template)
click_element :new_file
# Wait for the modal animation to complete before clicking on the file name
wait_for_animated_element(:new_file_modal)
within_element(:template_list) do
click_on file_name
rescue Capybara::ElementNotFound
raise ElementNotFound, %Q(Couldn't find file template named "#{file_name}". Please confirm that it is a valid option.)
end
# Wait for the modal to fade out too
has_no_element?(:new_file_modal)
wait(reload: false) do
within_element(:file_templates_bar) do
click_element :file_template_dropdown
fill_element :dropdown_filter_input, template
begin
click_on template
rescue Capybara::ElementNotFound
raise ElementNotFound, %Q(Couldn't find template "#{template}" for #{file_name}. Please confirm that it exists in the list of templates.)
end
end
end
end
def commit_changes
# Clicking :begin_commit_button the first time switches from the
# edit to the commit view
click_element :begin_commit_button
active_element? :commit_mode_tab
# We need to click :begin_commit_button again
click_element :begin_commit_button
# After clicking :begin_commit_button the 2nd time there is an
# animation that hides :begin_commit_button and shows :commit_button
#
# Wait for the animation to complete before clicking :commit_button
# otherwise the click will quietly do nothing.
wait(reload: false) do
has_no_element?(:begin_commit_button) &&
has_element?(:commit_button)
end
# At this point we're ready to commit and the button should be
# labelled "Stage & Commit"
#
# Click :commit_button and keep retrying just in case part of the
# animation is still in process even when the buttons have the
# expected visibility.
commit_success_msg_shown = retry_until do
click_element :commit_to_current_branch_radio
click_element :commit_button
wait(reload: false) do
has_text?('Your changes have been committed')
end
end
raise "The changes do not appear to have been committed successfully." unless commit_success_msg_shown
end
end
end
end
end
end
|