Commit 61fce0ec authored by Jacques Erasmus's avatar Jacques Erasmus Committed by Mark Lapierre

Update QA specs for lock button

parent 9d603896
......@@ -87,6 +87,9 @@ export default {
deleteModalTitle() {
return sprintf(__('Delete %{name}'), { name: this.name });
},
lockBtnQASelector() {
return this.canLock ? 'lock_button' : 'disabled_lock_button';
},
},
};
</script>
......@@ -102,7 +105,7 @@ export default {
:is-locked="isLocked"
:can-lock="canLock"
data-testid="lock"
data-qa-selector="lock_button"
:data-qa-selector="lockBtnQASelector"
/>
<gl-button v-gl-modal="replaceModalId" data-testid="replace">
{{ $options.i18n.replace }}
......
......@@ -16,10 +16,16 @@ module QA
element :link_file_owner
end
# These two lock button elements can be removed when the refactor_blob_viewer feature flag is removed
view 'ee/app/helpers/ee/lock_helper.rb' do
element :lock_button
element :disabled_lock_button
end
view 'app/assets/javascripts/repository/components/blob_button_group.vue' do
element :lock_button, /data-qa-selector="lockBtnQASelector"/ # rubocop:disable QA/ElementWithPattern
element :disabled_lock_button, /data-qa-selector="lockBtnQASelector"/ # rubocop:disable QA/ElementWithPattern
end
end
end
......
......@@ -97,6 +97,76 @@ module QA
expect_no_error_on_push as_user: user_two
end
context 'when refactor_blob_viewer is enabled', :requires_admin do
before do
Runtime::Feature.enable(:refactor_blob_viewer, project: project)
end
it 'locks a directory and tries to push as a second user', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/557' do
push branch: project.default_branch, file: 'directory/file', as_user: user_one
sign_out_and_sign_in_as user: user_one
go_to_directory
click_lock
expect_error_on_push for_file: 'directory/file', as_user: user_two
expect_no_error_on_push for_file: 'directory/file', as_user: user_one
end
it 'locks a file and tries to push as a second user', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/558' do
sign_out_and_sign_in_as user: user_one
go_to_file
click_lock
expect_error_on_push as_user: user_two
expect_no_error_on_push as_user: user_one
end
it 'checks file locked by other user to be disabled', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/556' do
go_to_file
click_lock
sign_out_and_sign_in_as user: user_one
go_to_file
Page::File::Show.perform do |show|
expect(show).to have_lock_button_disabled
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/quality/testcases/-/issues/1852' do
push branch: 'test', as_user: user_one
merge_request = Resource::MergeRequest.fabricate_via_api! do |merge_request|
merge_request.project = project
merge_request.source_branch = 'test'
merge_request.target_branch = project.default_branch
merge_request.no_preparation = true
end
go_to_file
click_lock
sign_out_and_sign_in_as user: user_one
try_to_merge merge_request: merge_request
Page::MergeRequest::Show.perform(&:wait_for_merge_request_error_message)
expect(page).to have_text("locked by #{admin_username}")
end
it 'locks a file and unlocks in list', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/555' do
sign_out_and_sign_in_as user: user_one
go_to_file
click_lock
project.visit!
Page::Project::Menu.perform(&:go_to_repository_locked_files)
EE::Page::Project::PathLocks::Index.perform do |list|
expect(list).to have_file_with_title 'file'
list.unlock_file 'file'
end
expect_no_error_on_push as_user: user_two
end
end
def try_to_merge(merge_request:)
merge_request.visit!
Page::MergeRequest::Show.perform do |show|
......
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