Commit f58a23e6 authored by Mark Lapierre's avatar Mark Lapierre Committed by Anastasia McDonald

Update file locking test for new confirm modal

- Updates the file page object to handle the current gitlab-ui-based
confirmation modal.
- Fixes a case of exception handling used as flow control.
parent 90a9b8d3
...@@ -39,7 +39,13 @@ export default { ...@@ -39,7 +39,13 @@ export default {
}, },
computed: { computed: {
primaryAction() { primaryAction() {
return { text: this.primaryText, attributes: { variant: this.primaryVariant } }; return {
text: this.primaryText,
attributes: {
variant: this.primaryVariant,
'data-qa-selector': 'confirm_ok_button',
},
};
}, },
cancelAction() { cancelAction() {
return this.hideCancel ? null : this.$options.cancelAction; return this.hideCancel ? null : this.$options.cancelAction;
......
...@@ -96,7 +96,10 @@ export default { ...@@ -96,7 +96,10 @@ export default {
modal-id="lock-file-modal" modal-id="lock-file-modal"
:visible="isModalVisible" :visible="isModalVisible"
:title="$options.i18n.modalTitle" :title="$options.i18n.modalTitle"
:action-primary="{ text: $options.i18n.actionPrimary }" :action-primary="{
text: $options.i18n.actionPrimary,
attributes: { variant: 'confirm', 'data-qa-selector': 'confirm_ok_button' },
}"
:action-cancel="{ text: $options.i18n.actionCancel }" :action-cancel="{ text: $options.i18n.actionCancel }"
@primary="handleModalPrimary" @primary="handleModalPrimary"
@hide="hideModal" @hide="hideModal"
......
...@@ -11,6 +11,8 @@ module QA ...@@ -11,6 +11,8 @@ module QA
super super
base.class_eval do base.class_eval do
include QA::Page::Component::ConfirmModal
view 'ee/app/views/projects/blob/_owners.html.haml' do view 'ee/app/views/projects/blob/_owners.html.haml' do
element :file_owner_content element :file_owner_content
element :link_file_owner element :link_file_owner
...@@ -30,31 +32,25 @@ module QA ...@@ -30,31 +32,25 @@ module QA
end end
def lock def lock
accept_confirm do click_element(:lock_button)
click_element :lock_button click_confirmation_ok_button
end
begin unless has_element?(:lock_button, text: 'Unlock')
has_element? :lock_button, text: 'Unlock'
rescue StandardError
raise QA::Page::Base::ElementNotFound, %q(Button did not show expected state) raise QA::Page::Base::ElementNotFound, %q(Button did not show expected state)
end end
end end
def unlock def unlock
accept_confirm do click_element(:lock_button)
click_element :lock_button click_confirmation_ok_button
end
begin unless has_element?(:lock_button, text: 'Lock')
has_element? :lock_button, text: 'Lock'
rescue StandardError
raise QA::Page::Base::ElementNotFound, %q(Button did not show expected state) raise QA::Page::Base::ElementNotFound, %q(Button did not show expected state)
end end
end end
def has_lock_button_disabled? def has_lock_button_disabled?
has_element? :disabled_lock_button has_element?(:disabled_lock_button)
end end
end end
end end
......
...@@ -8,10 +8,14 @@ module QA ...@@ -8,10 +8,14 @@ module QA
def self.included(base) def self.included(base)
super super
base.view 'app/assets/javascripts/lib/utils/confirm_via_gl_modal/confirm_modal.vue' do
element :confirm_ok_button
end
end end
def fill_confirmation_text(text) def fill_confirmation_text(text)
fill_element :confirm_input, text fill_element(:confirm_input, text)
end end
def wait_for_confirm_button_enabled def wait_for_confirm_button_enabled
...@@ -22,7 +26,11 @@ module QA ...@@ -22,7 +26,11 @@ module QA
def confirm_transfer def confirm_transfer
wait_for_confirm_button_enabled wait_for_confirm_button_enabled
click_element :confirm_button click_element(:confirm_button)
end
def click_confirmation_ok_button
click_element(:confirm_ok_button)
end end
end end
end end
......
# frozen_string_literal: true # frozen_string_literal: true
module QA module QA
RSpec.describe 'Create', quarantine: { issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/349898', type: :stale } do RSpec.describe 'Create' do
describe 'File Locking' do describe 'File Locking' do
let(:user_one) { Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_username_1, Runtime::Env.gitlab_qa_password_1) } let(:user_one) { Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_username_1, Runtime::Env.gitlab_qa_password_1) }
let(:user_two) { Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_username_2, Runtime::Env.gitlab_qa_password_2) } let(:user_two) { Resource::User.fabricate_or_use(Runtime::Env.gitlab_qa_username_2, Runtime::Env.gitlab_qa_password_2) }
...@@ -133,7 +133,7 @@ module QA ...@@ -133,7 +133,7 @@ module QA
end end
end end
it 'creates a merge request and fails to merge', quarantine: { issue: 'https://gitlab.com/gitlab-org/gitlab/issues/40125', type: :bug }, testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/348316' do it 'creates a merge request and fails to merge', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/348316' do
push branch: 'test', as_user: user_one push branch: 'test', as_user: user_one
merge_request = Resource::MergeRequest.fabricate_via_api! do |merge_request| merge_request = Resource::MergeRequest.fabricate_via_api! do |merge_request|
......
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