diff options
-rw-r--r-- | .gitlab/merge_request_templates/Database changes.md | 22 | ||||
-rw-r--r-- | .gitlab/merge_request_templates/Documentation.md | 14 | ||||
-rw-r--r-- | app/views/projects/commit/_change.html.haml | 2 | ||||
-rw-r--r-- | changelogs/unreleased/close-revert-and-cherry-pick-modal-on-escape-keypress.yml | 5 | ||||
-rw-r--r-- | qa/qa.rb | 10 | ||||
-rw-r--r-- | qa/qa/factory/resource/file.rb | 34 | ||||
-rw-r--r-- | qa/qa/page/file/form.rb | 40 | ||||
-rw-r--r-- | qa/qa/page/file/shared/commit_message.rb | 19 | ||||
-rw-r--r-- | qa/qa/page/file/show.rb | 30 | ||||
-rw-r--r-- | qa/qa/page/project/show.rb | 8 | ||||
-rw-r--r-- | qa/qa/page/view.rb | 4 | ||||
-rw-r--r-- | qa/qa/specs/features/project/file_spec.rb | 54 | ||||
-rw-r--r-- | spec/features/merge_request/user_sees_check_out_branch_modal_spec.rb | 4 | ||||
-rw-r--r-- | spec/features/merge_request/user_sees_cherry_pick_modal_spec.rb (renamed from spec/features/merge_request/user_cherry_picks_spec.rb) | 22 | ||||
-rw-r--r-- | spec/features/user_sees_revert_modal_spec.rb | 25 |
15 files changed, 268 insertions, 25 deletions
diff --git a/.gitlab/merge_request_templates/Database changes.md b/.gitlab/merge_request_templates/Database changes.md index d14d52e1b6b..e636ec313df 100644 --- a/.gitlab/merge_request_templates/Database changes.md +++ b/.gitlab/merge_request_templates/Database changes.md @@ -34,17 +34,17 @@ When removing columns, tables, indexes or other structures: ## General checklist - [ ] [Changelog entry](https://docs.gitlab.com/ee/development/changelog.html) added, if necessary -- [ ] [Documentation created/updated](https://docs.gitlab.com/ee/development/doc_styleguide.html) -- [ ] API support added -- [ ] Tests added for this feature/bug -- Conform by the [code review guidelines](https://docs.gitlab.com/ee/development/code_review.html) - - [ ] Has been reviewed by a Backend maintainer - - [ ] Has been reviewed by a Database specialist -- [ ] Conform by the [merge request performance guides](https://docs.gitlab.com/ee/development/merge_request_performance_guidelines.html) -- [ ] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ee/blob/master/CONTRIBUTING.md#style-guides) +- [ ] [Documentation created/updated](https://docs.gitlab.com/ee/development/documentation/index.html#contributing-to-docs) +- [ ] [API support added](https://docs.gitlab.com/ee/development/api_styleguide.html) +- [ ] [Tests added for this feature/bug](https://docs.gitlab.com/ee/development/testing_guide/index.html) +- Conforms to the [code review guidelines](https://docs.gitlab.com/ee/development/code_review.html) + - [ ] Has been reviewed by a Backend [maintainer](https://about.gitlab.com/handbook/engineering/#maintainer) + - [ ] Has been reviewed by a Database [specialist](https://about.gitlab.com/team/structure/#specialist) +- [ ] Conforms to the [merge request performance guidelines](https://docs.gitlab.com/ee/development/merge_request_performance_guidelines.html) +- [ ] Conforms to the [style guides](https://gitlab.com/gitlab-org/gitlab-ee/blob/master/CONTRIBUTING.md#style-guides) - [ ] If you have multiple commits, please combine them into a few logically organized commits by [squashing them](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits) -- [ ] Internationalization required/considered -- [ ] If paid feature, have we considered GitLab.com plan and how it works for groups and is there a design for promoting it to users who aren't on the correct plan -- [ ] End-to-end tests pass (`package-and-qa` manual pipeline job) +- [ ] [Internationalization required/considered](https://docs.gitlab.com/ee/development/i18n/index.html) +- [ ] For a paid feature, have we considered GitLab.com plans, how it works for groups, and is there a design for promoting it to users who aren't on the correct plan? +- [ ] [End-to-end tests](https://docs.gitlab.com/ee/development/testing_guide/end_to_end_tests.html#testing-code-in-merge-requests) pass (`package-and-qa` manual pipeline job) /label ~database diff --git a/.gitlab/merge_request_templates/Documentation.md b/.gitlab/merge_request_templates/Documentation.md index da38a703c3c..531035b3766 100644 --- a/.gitlab/merge_request_templates/Documentation.md +++ b/.gitlab/merge_request_templates/Documentation.md @@ -1,4 +1,4 @@ -<!--See the general Documentation guidelines https://docs.gitlab.com/ce/development/writing_documentation.html --> +<!--See the general Documentation guidelines https://docs.gitlab.com/ee/development/documentation/index.html --> ## What does this MR do? @@ -13,17 +13,17 @@ Closes ## Moving docs to a new location? Read the guidelines: -https://docs.gitlab.com/ce/development/writing_documentation.html#changing-document-location +https://docs.gitlab.com/ee/development/documentation/#changing-document-location - [ ] Make sure the old link is not removed and has its contents replaced with a link to the new location. - [ ] Make sure internal links pointing to the document in question are not broken. -- [ ] Search and replace any links referring to old docs in GitLab Rails app, - specifically under the `app/views/` and `ee/app/views` (for GitLab EE) directories. -- [ ] Make sure to add [`redirect_from`](https://docs.gitlab.com/ce/development/writing_documentation.html#redirections-for-pages-with-disqus-comments) +- [ ] Search and replace any links referring to the old docs in the GitLab Rails app, + specifically under the `app/views/` and `ee/app/views` (for GitLab EE) directories. +- [ ] Make sure to add [`redirect_from`](https://docs.gitlab.com/ee/development/documentation/index.html#redirections-for-pages-with-disqus-comments) to the new document if there are any Disqus comments on the old document thread. -- [ ] If working on CE and the `ee-compat-check` jobs fails, submit an MR to EE - with the changes as well (https://docs.gitlab.com/ce/development/writing_documentation.html#cherry-picking-from-ce-to-ee). +- [ ] If working on CE and the `ee-compat-check` jobs fails, [submit an MR to EE + with the changes](https://docs.gitlab.com/ee/development/documentation/index.html#cherry-picking-from-ce-to-ee) as well. - [ ] Ping one of the technical writers for review. /label ~Documentation diff --git a/app/views/projects/commit/_change.html.haml b/app/views/projects/commit/_change.html.haml index 3d97e93c9e9..14a7e84394a 100644 --- a/app/views/projects/commit/_change.html.haml +++ b/app/views/projects/commit/_change.html.haml @@ -11,7 +11,7 @@ - branch_label = s_('ChangeTypeActionLabel|Pick into branch') - title = commit.merged_merge_request(current_user) ? _('Cherry-pick this merge request') : _('Cherry-pick this commit') -.modal{ id: "modal-#{type}-commit" } +.modal{ id: "modal-#{type}-commit", tabindex: -1 } .modal-dialog .modal-content .modal-header diff --git a/changelogs/unreleased/close-revert-and-cherry-pick-modal-on-escape-keypress.yml b/changelogs/unreleased/close-revert-and-cherry-pick-modal-on-escape-keypress.yml new file mode 100644 index 00000000000..49648cdfcfc --- /dev/null +++ b/changelogs/unreleased/close-revert-and-cherry-pick-modal-on-escape-keypress.yml @@ -0,0 +1,5 @@ +--- +title: Close revert and cherry pick modal on escape keypress +merge_request: 20341 +author: George Tsiolis +type: changed @@ -53,6 +53,7 @@ module QA autoload :User, 'qa/factory/resource/user' autoload :ProjectMilestone, 'qa/factory/resource/project_milestone' autoload :Wiki, 'qa/factory/resource/wiki' + autoload :File, 'qa/factory/resource/file' autoload :Fork, 'qa/factory/resource/fork' end @@ -136,6 +137,15 @@ module QA autoload :Show, 'qa/page/group/show' end + module File + autoload :Form, 'qa/page/file/form' + autoload :Show, 'qa/page/file/show' + + module Shared + autoload :CommitMessage, 'qa/page/file/shared/commit_message' + end + end + module Project autoload :New, 'qa/page/project/new' autoload :Show, 'qa/page/project/show' diff --git a/qa/qa/factory/resource/file.rb b/qa/qa/factory/resource/file.rb new file mode 100644 index 00000000000..2016d10ddae --- /dev/null +++ b/qa/qa/factory/resource/file.rb @@ -0,0 +1,34 @@ +module QA + module Factory + module Resource + class File < Factory::Base + attr_accessor :name, + :content, + :commit_message + + dependency Factory::Resource::Project, as: :project do |project| + project.name = 'project-with-new-file' + end + + def initialize + @name = 'QA Test - File name' + @content = 'QA Test - File content' + @commit_message = 'QA Test - Commit message' + end + + def fabricate! + project.visit! + + Page::Project::Show.act { go_to_new_file! } + + Page::File::Form.perform do |page| + page.add_name(@name) + page.add_content(@content) + page.add_commit_message(@commit_message) + page.commit_changes + end + end + end + end + end +end diff --git a/qa/qa/page/file/form.rb b/qa/qa/page/file/form.rb new file mode 100644 index 00000000000..f6e502f500b --- /dev/null +++ b/qa/qa/page/file/form.rb @@ -0,0 +1,40 @@ +module QA + module Page + module File + class Form < Page::Base + include Shared::CommitMessage + + view 'app/views/projects/blob/_editor.html.haml' do + element :file_name, "text_field_tag 'file_name'" + element :editor, '#editor' + end + + view 'app/views/projects/_commit_button.html.haml' do + element :commit_changes, "button_tag 'Commit changes'" + end + + def add_name(name) + fill_in 'file_name', with: name + end + + def add_content(content) + text_area.set content + end + + def remove_content + text_area.send_keys([:command, 'a'], :backspace) + end + + def commit_changes + click_on 'Commit changes' + end + + private + + def text_area + find('#editor>textarea', visible: false) + end + end + end + end +end diff --git a/qa/qa/page/file/shared/commit_message.rb b/qa/qa/page/file/shared/commit_message.rb new file mode 100644 index 00000000000..5af1a55e2ef --- /dev/null +++ b/qa/qa/page/file/shared/commit_message.rb @@ -0,0 +1,19 @@ +module QA + module Page + module File + module Shared + module CommitMessage + def self.included(base) + base.view 'app/views/shared/_commit_message_container.html.haml' do + element :commit_message, "text_area_tag 'commit_message'" + end + end + + def add_commit_message(message) + fill_in 'commit_message', with: message + end + end + end + end + end +end diff --git a/qa/qa/page/file/show.rb b/qa/qa/page/file/show.rb new file mode 100644 index 00000000000..99f5924b67f --- /dev/null +++ b/qa/qa/page/file/show.rb @@ -0,0 +1,30 @@ +module QA + module Page + module File + class Show < Page::Base + include Shared::CommitMessage + + view 'app/helpers/blob_helper.rb' do + element :edit_button, "_('Edit')" + element :delete_button, /label:\s+"Delete"/ + end + + view 'app/views/projects/blob/_remove.html.haml' do + element :delete_file_button, "button_tag 'Delete file'" + end + + def click_edit + click_on 'Edit' + end + + def click_delete + click_on 'Delete' + end + + def click_delete_file + click_on 'Delete file' + end + end + end + end +end diff --git a/qa/qa/page/project/show.rb b/qa/qa/page/project/show.rb index 88861d5772d..1d3dad4cda0 100644 --- a/qa/qa/page/project/show.rb +++ b/qa/qa/page/project/show.rb @@ -31,10 +31,18 @@ module QA element :tree_holder, '.tree-holder' end + view 'app/presenters/project_presenter.rb' do + element :new_file_button, "label: _('New file')," + end + def project_name find('.qa-project-name').text end + def go_to_new_file! + click_on 'New file' + end + def switch_to_branch(branch_name) find_element(:branches_select).click diff --git a/qa/qa/page/view.rb b/qa/qa/page/view.rb index 6635e1ce039..b2a2da4dbf3 100644 --- a/qa/qa/page/view.rb +++ b/qa/qa/page/view.rb @@ -9,7 +9,7 @@ module QA end def pathname - @pathname ||= Pathname.new(File.join(__dir__, '../../../', @path)) + @pathname ||= Pathname.new(::File.join(__dir__, '../../../', @path)) .cleanpath.expand_path end @@ -23,7 +23,7 @@ module QA # elements' existence. # @missing ||= @elements.dup.tap do |elements| - File.foreach(pathname.to_s) do |line| + ::File.foreach(pathname.to_s) do |line| elements.reject! { |element| element.matches?(line) } end end diff --git a/qa/qa/specs/features/project/file_spec.rb b/qa/qa/specs/features/project/file_spec.rb new file mode 100644 index 00000000000..5659784cd5c --- /dev/null +++ b/qa/qa/specs/features/project/file_spec.rb @@ -0,0 +1,54 @@ +module QA + describe 'File Functionality', :core do + it 'lets a user create, edit and delete a file via WebUI' do + Runtime::Browser.visit(:gitlab, Page::Main::Login) + Page::Main::Login.act { sign_in_using_credentials } + + # Create + file_name = 'QA Test - File name' + file_content = 'QA Test - File content' + commit_message_for_create = 'QA Test - Create new file' + + Factory::Resource::File.fabricate! do |file| + file.name = file_name + file.content = file_content + file.commit_message = commit_message_for_create + end + + expect(page).to have_content('The file has been successfully created.') + expect(page).to have_content(file_name) + expect(page).to have_content(file_content) + expect(page).to have_content(commit_message_for_create) + + # Edit + updated_file_content = 'QA Test - Updated file content' + commit_message_for_update = 'QA Test - Update file' + + Page::File::Show.act { click_edit } + + Page::File::Form.act do + remove_content + add_content(updated_file_content) + add_commit_message(commit_message_for_update) + commit_changes + end + + expect(page).to have_content('Your changes have been successfully committed.') + expect(page).to have_content(updated_file_content) + expect(page).to have_content(commit_message_for_update) + + # Delete + commit_message_for_delete = 'QA Test - Delete file' + + Page::File::Show.act do + click_delete + add_commit_message(commit_message_for_delete) + click_delete_file + end + + expect(page).to have_content('The file has been successfully deleted.') + expect(page).to have_content(commit_message_for_delete) + expect(page).to have_no_content(file_name) + end + end +end diff --git a/spec/features/merge_request/user_sees_check_out_branch_modal_spec.rb b/spec/features/merge_request/user_sees_check_out_branch_modal_spec.rb index c40c720d168..86086a58f18 100644 --- a/spec/features/merge_request/user_sees_check_out_branch_modal_spec.rb +++ b/spec/features/merge_request/user_sees_check_out_branch_modal_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -describe 'Merge request > User sees Check out branch modal', :js do +describe 'Merge request > User sees check out branch modal', :js do let(:project) { create(:project, :public, :repository) } let(:user) { project.creator } let(:merge_request) { create(:merge_request, source_project: project) } @@ -16,7 +16,7 @@ describe 'Merge request > User sees Check out branch modal', :js do expect(page).to have_content('Check out, review, and merge locally') end - it 'closes the check out branch model with Escape keypress' do + it 'closes the check out branch modal with escape keypress' do find('#modal_merge_info').send_keys(:escape) expect(page).not_to have_content('Check out, review, and merge locally') diff --git a/spec/features/merge_request/user_cherry_picks_spec.rb b/spec/features/merge_request/user_sees_cherry_pick_modal_spec.rb index c6ec3f08cc5..aa499493dbe 100644 --- a/spec/features/merge_request/user_cherry_picks_spec.rb +++ b/spec/features/merge_request/user_sees_cherry_pick_modal_spec.rb @@ -21,7 +21,7 @@ describe 'Merge request > User cherry-picks', :js do end # Fast-forward merge, or merged before GitLab 8.5. - context 'Without a merge commit' do + context 'without a merge commit' do before do merge_request.merge_commit_sha = nil merge_request.save @@ -34,7 +34,7 @@ describe 'Merge request > User cherry-picks', :js do end end - context 'With a merge commit' do + context 'with a merge commit' do it 'shows a Cherry-pick button' do visit project_merge_request_path(project, merge_request) @@ -49,5 +49,23 @@ describe 'Merge request > User cherry-picks', :js do expect(page).not_to have_link 'Cherry-pick' end end + + context 'and seeing the cherry-pick modal' do + before do + visit project_merge_request_path(project, merge_request) + + click_link('Cherry-pick') + end + + it 'shows the cherry-pick modal' do + expect(page).to have_content('Cherry-pick this merge request') + end + + it 'closes the cherry-pick modal with escape keypress' do + find('#modal-cherry-pick-commit').send_keys(:escape) + + expect(page).not_to have_content('Start a new merge request with these changes') + end + end end end diff --git a/spec/features/user_sees_revert_modal_spec.rb b/spec/features/user_sees_revert_modal_spec.rb new file mode 100644 index 00000000000..11a9e470f76 --- /dev/null +++ b/spec/features/user_sees_revert_modal_spec.rb @@ -0,0 +1,25 @@ +require 'rails_helper' + +describe 'Merge request > User sees revert modal', :js do + let(:project) { create(:project, :public, :repository) } + let(:user) { project.creator } + let(:merge_request) { create(:merge_request, source_project: project) } + + before do + sign_in(user) + visit(project_merge_request_path(project, merge_request)) + click_button('Merge') + visit(merge_request_path(merge_request)) + click_link('Revert') + end + + it 'shows the revert modal' do + expect(page).to have_content('Revert this merge request') + end + + it 'closes the revert modal with escape keypress' do + find('#modal-revert-commit').send_keys(:escape) + + expect(page).not_to have_content('Revert this merge request') + end +end |