Commit e827bfe8 authored by Mark Lapierre's avatar Mark Lapierre Committed by Sanad Liaquat

Make Web IDE commit check more reliable

- When commiting via the Web IDE, check that the commit is complete
  by waiting for the IDE to return to Edit mode and for the commit SHA
  to change. This should be more reliable than checking for text that
  only appears for a moment.
- Adds/updates QA selectors
parent becb7685
...@@ -44,6 +44,7 @@ export default { ...@@ -44,6 +44,7 @@ export default {
:aria-label="s__('IDE|Edit')" :aria-label="s__('IDE|Edit')"
data-container="body" data-container="body"
data-placement="right" data-placement="right"
data-qa-selector="edit_mode_tab"
type="button" type="button"
class="ide-sidebar-link js-ide-edit-mode" class="ide-sidebar-link js-ide-edit-mode"
@click.prevent="changedActivityView($event, $options.leftSidebarViews.edit.name)" @click.prevent="changedActivityView($event, $options.leftSidebarViews.edit.name)"
...@@ -78,8 +79,9 @@ export default { ...@@ -78,8 +79,9 @@ export default {
:aria-label="s__('IDE|Commit')" :aria-label="s__('IDE|Commit')"
data-container="body" data-container="body"
data-placement="right" data-placement="right"
data-qa-selector="commit_mode_tab"
type="button" type="button"
class="ide-sidebar-link js-ide-commit-mode qa-commit-mode-tab" class="ide-sidebar-link js-ide-commit-mode"
@click.prevent="changedActivityView($event, $options.leftSidebarViews.commit.name)" @click.prevent="changedActivityView($event, $options.leftSidebarViews.commit.name)"
> >
<gl-icon name="commit" /> <gl-icon name="commit" />
......
...@@ -103,6 +103,7 @@ export default { ...@@ -103,6 +103,7 @@ export default {
:title="lastCommit.message" :title="lastCommit.message"
:href="getCommitPath(lastCommit.short_id)" :href="getCommitPath(lastCommit.short_id)"
class="commit-sha" class="commit-sha"
data-qa-selector="commit_sha_content"
>{{ lastCommit.short_id }}</a >{{ lastCommit.short_id }}</a
> >
by by
......
...@@ -275,7 +275,8 @@ module QA ...@@ -275,7 +275,8 @@ module QA
end end
def click_open_in_web_ide def click_open_in_web_ide
click_element :open_in_web_ide_button click_element(:open_in_web_ide_button)
wait_for_requests
end end
end end
end end
......
...@@ -10,6 +10,11 @@ module QA ...@@ -10,6 +10,11 @@ module QA
view 'app/assets/javascripts/ide/components/activity_bar.vue' do view 'app/assets/javascripts/ide/components/activity_bar.vue' do
element :commit_mode_tab element :commit_mode_tab
element :edit_mode_tab
end
view 'app/assets/javascripts/ide/components/ide_status_bar.vue' do
element :commit_sha_content
end end
view 'app/assets/javascripts/ide/components/ide_tree.vue' do view 'app/assets/javascripts/ide/components/ide_tree.vue' do
...@@ -104,11 +109,19 @@ module QA ...@@ -104,11 +109,19 @@ module QA
end end
end end
def commit_sha
return unless has_element?(:commit_sha_content, wait: 0)
find_element(:commit_sha_content).text
end
def commit_changes(open_merge_request: false) def commit_changes(open_merge_request: false)
# Clicking :begin_commit_button switches from the # Clicking :begin_commit_button switches from the
# edit to the commit view # edit to the commit view
click_element :begin_commit_button click_element(:begin_commit_button)
active_element? :commit_mode_tab active_element?(:commit_mode_tab)
original_commit = commit_sha
# After clicking :begin_commit_button, there is an animation # After clicking :begin_commit_button, there is an animation
# that hides :begin_commit_button and shows :commit_button # that hides :begin_commit_button and shows :commit_button
...@@ -126,16 +139,17 @@ module QA ...@@ -126,16 +139,17 @@ module QA
# Click :commit_button and keep retrying just in case part of the # Click :commit_button and keep retrying just in case part of the
# animation is still in process even when the buttons have the # animation is still in process even when the buttons have the
# expected visibility. # expected visibility.
commit_success_msg_shown = retry_until(sleep_interval: 5) do commit_success = retry_until(sleep_interval: 5) do
click_element(:commit_to_current_branch_radio) if has_element?(:commit_to_current_branch_radio) click_element(:commit_to_current_branch_radio) if has_element?(:commit_to_current_branch_radio)
click_element(:commit_button) if has_element?(:commit_button) click_element(:commit_button) if has_element?(:commit_button)
wait_until(reload: false) do # If this is the first commit, the commit SHA only appears after reloading
has_text?('Your changes have been committed') wait_until(reload: true) do
active_element?(:edit_mode_tab) && commit_sha != original_commit
end end
end end
raise "The changes do not appear to have been committed successfully." unless commit_success_msg_shown raise "The changes do not appear to have been committed successfully." unless commit_success
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment