diff options
author | Rémy Coutable <remy@rymai.me> | 2018-08-30 18:18:01 +0300 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2018-08-30 18:18:01 +0300 |
commit | d004c768417ef95a4aecb58c6c241ceed1a73d8f (patch) | |
tree | 7dafc633b9592911af9657d22e0298e912a56c77 /spec/features/issues | |
parent | 418d35d97491af3921e8f5cca2734b0063c143a9 (diff) |
Reorganize issues and merge request feature specs in the same folder
Signed-off-by: Rémy Coutable <remy@rymai.me>
Diffstat (limited to 'spec/features/issues')
-rw-r--r-- | spec/features/issues/rss_spec.rb | 32 | ||||
-rw-r--r-- | spec/features/issues/user_comments_on_issue_spec.rb | 84 | ||||
-rw-r--r-- | spec/features/issues/user_creates_issue_spec.rb | 90 | ||||
-rw-r--r-- | spec/features/issues/user_edits_issue_spec.rb | 25 | ||||
-rw-r--r-- | spec/features/issues/user_sorts_issues_spec.rb | 63 | ||||
-rw-r--r-- | spec/features/issues/user_toggles_subscription_spec.rb | 28 | ||||
-rw-r--r-- | spec/features/issues/user_views_issue_spec.rb | 50 | ||||
-rw-r--r-- | spec/features/issues/user_views_issues_spec.rb | 116 |
8 files changed, 488 insertions, 0 deletions
diff --git a/spec/features/issues/rss_spec.rb b/spec/features/issues/rss_spec.rb new file mode 100644 index 00000000000..0e1383cd607 --- /dev/null +++ b/spec/features/issues/rss_spec.rb @@ -0,0 +1,32 @@ +require 'spec_helper' + +describe 'Project Issues RSS' do + let(:project) { create(:project, visibility_level: Gitlab::VisibilityLevel::PUBLIC) } + let(:path) { project_issues_path(project) } + + before do + create(:issue, project: project) + end + + context 'when signed in' do + let(:user) { create(:user) } + + before do + project.add_developer(user) + sign_in(user) + visit path + end + + it_behaves_like "it has an RSS button with current_user's feed token" + it_behaves_like "an autodiscoverable RSS feed with current_user's feed token" + end + + context 'when signed out' do + before do + visit path + end + + it_behaves_like "it has an RSS button without a feed token" + it_behaves_like "an autodiscoverable RSS feed without a feed token" + end +end diff --git a/spec/features/issues/user_comments_on_issue_spec.rb b/spec/features/issues/user_comments_on_issue_spec.rb new file mode 100644 index 00000000000..ba5b80ed04b --- /dev/null +++ b/spec/features/issues/user_comments_on_issue_spec.rb @@ -0,0 +1,84 @@ +require "spec_helper" + +describe "User comments on issue", :js do + include Spec::Support::Helpers::Features::NotesHelpers + + let(:project) { create(:project_empty_repo, :public) } + let(:issue) { create(:issue, project: project) } + let(:user) { create(:user) } + + before do + project.add_guest(user) + sign_in(user) + + visit(project_issue_path(project, issue)) + end + + context "when adding comments" do + it "adds comment" do + content = "XML attached" + target_form = ".js-main-target-form" + + add_note(content) + + page.within(".note") do + expect(page).to have_content(content) + end + + page.within(target_form) do + find(".error-alert", visible: false) + end + end + + it "adds comment with code block" do + code_block_content = "Command [1]: /usr/local/bin/git , see [text](doc/text)" + comment = "```\n#{code_block_content}\n```" + + add_note(comment) + + wait_for_requests + + expect(page.find('pre code').text).to eq code_block_content + end + end + + context "when editing comments" do + it "edits comment" do + add_note("# Comment with a header") + + page.within(".note-body > .note-text") do + expect(page).to have_content("Comment with a header").and have_no_css("#comment-with-a-header") + end + + page.within(".main-notes-list") do + note = find(".note") + + note.hover + note.find(".js-note-edit").click + end + + expect(page).to have_css(".current-note-edit-form textarea") + + comment = "+1 Awesome!" + + page.within(".current-note-edit-form") do + fill_in("note[note]", with: comment) + find('textarea').send_keys [:control, :shift, 'p'] + expect(page).to have_selector('.current-note-edit-form .md-preview-holder') + expect(page.find('.current-note-edit-form .md-preview-holder p')).to have_content(comment) + end + + expect(page).to have_selector('.new-note .note-textarea') + + page.within(".current-note-edit-form") do + click_button("Save comment") + end + + wait_for_requests + + page.within(".note") do + expect(page).to have_content(comment) + end + end + end +end diff --git a/spec/features/issues/user_creates_issue_spec.rb b/spec/features/issues/user_creates_issue_spec.rb new file mode 100644 index 00000000000..5e8662100c5 --- /dev/null +++ b/spec/features/issues/user_creates_issue_spec.rb @@ -0,0 +1,90 @@ +require "spec_helper" + +describe "User creates issue" do + let(:project) { create(:project_empty_repo, :public) } + let(:user) { create(:user) } + + context "when signed in as guest" do + before do + project.add_guest(user) + sign_in(user) + + visit(new_project_issue_path(project)) + end + + it "creates issue" do + page.within(".issue-form") do + expect(page).to have_no_content("Assign to") + .and have_no_content("Labels") + .and have_no_content("Milestone") + + expect(page.find('#issue_title')['placeholder']).to eq 'Title' + expect(page.find('#issue_description')['placeholder']).to eq 'Write a comment or drag your files here…' + end + + issue_title = "500 error on profile" + + fill_in("Title", with: issue_title) + click_button("Submit issue") + + expect(page).to have_content(issue_title) + .and have_content(user.name) + .and have_content(project.name) + end + end + + context "when signed in as developer", :js do + before do + project.add_developer(user) + sign_in(user) + + visit(new_project_issue_path(project)) + end + + context "when previewing" do + it "previews content" do + form = first(".gfm-form") + textarea = first(".gfm-form textarea") + + page.within(form) do + click_link("Preview") + + preview = find(".js-md-preview") # this element is findable only when the "Preview" link is clicked. + + expect(preview).to have_content("Nothing to preview.") + + click_link("Write") + fill_in("Description", with: "Bug fixed :smile:") + click_link("Preview") + + expect(preview).to have_css("gl-emoji") + expect(textarea).not_to be_visible + end + end + end + + context "with labels" do + LABEL_TITLES = %w(bug feature enhancement).freeze + + before do + LABEL_TITLES.each do |title| + create(:label, project: project, title: title) + end + end + + it "creates issue" do + issue_title = "500 error on profile" + + fill_in("Title", with: issue_title) + click_button("Label") + click_link(LABEL_TITLES.first) + click_button("Submit issue") + + expect(page).to have_content(issue_title) + .and have_content(user.name) + .and have_content(project.name) + .and have_content(LABEL_TITLES.first) + end + end + end +end diff --git a/spec/features/issues/user_edits_issue_spec.rb b/spec/features/issues/user_edits_issue_spec.rb new file mode 100644 index 00000000000..1d9c3abc20f --- /dev/null +++ b/spec/features/issues/user_edits_issue_spec.rb @@ -0,0 +1,25 @@ +require "spec_helper" + +describe "User edits issue", :js do + set(:project) { create(:project_empty_repo, :public) } + set(:user) { create(:user) } + set(:issue) { create(:issue, project: project, author: user) } + + before do + project.add_developer(user) + sign_in(user) + + visit(edit_project_issue_path(project, issue)) + end + + it "previews content" do + form = first(".gfm-form") + + page.within(form) do + fill_in("Description", with: "Bug fixed :smile:") + click_link("Preview") + end + + expect(form).to have_link("Write") + end +end diff --git a/spec/features/issues/user_sorts_issues_spec.rb b/spec/features/issues/user_sorts_issues_spec.rb new file mode 100644 index 00000000000..7d261ec7dae --- /dev/null +++ b/spec/features/issues/user_sorts_issues_spec.rb @@ -0,0 +1,63 @@ +require "spec_helper" + +describe "User sorts issues" do + set(:user) { create(:user) } + set(:group) { create(:group) } + set(:project) { create(:project_empty_repo, :public, group: group) } + set(:issue1) { create(:issue, project: project) } + set(:issue2) { create(:issue, project: project) } + set(:issue3) { create(:issue, project: project) } + + before do + create_list(:award_emoji, 2, :upvote, awardable: issue1) + create_list(:award_emoji, 2, :downvote, awardable: issue2) + create(:award_emoji, :downvote, awardable: issue1) + create(:award_emoji, :upvote, awardable: issue2) + + sign_in(user) + + visit(project_issues_path(project)) + end + + it 'keeps the sort option' do + find('button.dropdown-toggle').click + + page.within('.content ul.dropdown-menu.dropdown-menu-right li') do + click_link('Milestone') + end + + visit(issues_dashboard_path(assignee_id: user.id)) + + expect(find('.issues-filters a.is-active')).to have_content('Milestone') + + visit(project_issues_path(project)) + + expect(find('.issues-filters a.is-active')).to have_content('Milestone') + + visit(issues_group_path(group)) + + expect(find('.issues-filters a.is-active')).to have_content('Milestone') + end + + it "sorts by popularity" do + find("button.dropdown-toggle").click + + page.within(".content ul.dropdown-menu.dropdown-menu-right li") do + click_link("Popularity") + end + + page.within(".issues-list") do + page.within("li.issue:nth-child(1)") do + expect(page).to have_content(issue1.title) + end + + page.within("li.issue:nth-child(2)") do + expect(page).to have_content(issue2.title) + end + + page.within("li.issue:nth-child(3)") do + expect(page).to have_content(issue3.title) + end + end + end +end diff --git a/spec/features/issues/user_toggles_subscription_spec.rb b/spec/features/issues/user_toggles_subscription_spec.rb new file mode 100644 index 00000000000..c2b2a193682 --- /dev/null +++ b/spec/features/issues/user_toggles_subscription_spec.rb @@ -0,0 +1,28 @@ +require "spec_helper" + +describe "User toggles subscription", :js do + let(:project) { create(:project_empty_repo, :public) } + let(:user) { create(:user) } + let(:issue) { create(:issue, project: project, author: user) } + + before do + project.add_developer(user) + sign_in(user) + + visit(project_issue_path(project, issue)) + end + + it "unsubscribes from issue" do + subscription_button = find(".js-issuable-subscribe-button") + + # Check we're subscribed. + expect(subscription_button).to have_css("button.is-checked") + + # Toggle subscription. + find(".js-issuable-subscribe-button button").click + wait_for_requests + + # Check we're unsubscribed. + expect(subscription_button).to have_css("button:not(.is-checked)") + end +end diff --git a/spec/features/issues/user_views_issue_spec.rb b/spec/features/issues/user_views_issue_spec.rb new file mode 100644 index 00000000000..117e5986f29 --- /dev/null +++ b/spec/features/issues/user_views_issue_spec.rb @@ -0,0 +1,50 @@ +require "spec_helper" + +describe "User views issue" do + set(:project) { create(:project_empty_repo, :public) } + set(:user) { create(:user) } + set(:issue) { create(:issue, project: project, description: "# Description header", author: user) } + + before do + project.add_developer(user) + sign_in(user) + + visit(project_issue_path(project, issue)) + end + + it { expect(page).to have_header_with_correct_id_and_link(1, "Description header", "description-header") } + + it 'shows the merge request and issue actions', :aggregate_failures do + expect(page).to have_link('New issue') + expect(page).to have_button('Create merge request') + expect(page).to have_link('Close issue') + end + + context 'when the project is archived' do + let(:project) { create(:project, :public, :archived) } + + it 'hides the merge request and issue actions', :aggregate_failures do + expect(page).not_to have_link('New issue') + expect(page).not_to have_button('Create merge request') + expect(page).not_to have_link('Close issue') + end + end + + describe 'user status' do + subject { visit(project_issue_path(project, issue)) } + + describe 'showing status of the author of the issue' do + it_behaves_like 'showing user status' do + let(:user_with_status) { issue.author } + end + end + + describe 'showing status of a user who commented on an issue', :js do + let!(:note) { create(:note, noteable: issue, project: project, author: user_with_status) } + + it_behaves_like 'showing user status' do + let(:user_with_status) { create(:user) } + end + end + end +end diff --git a/spec/features/issues/user_views_issues_spec.rb b/spec/features/issues/user_views_issues_spec.rb new file mode 100644 index 00000000000..58afb4efb86 --- /dev/null +++ b/spec/features/issues/user_views_issues_spec.rb @@ -0,0 +1,116 @@ +require "spec_helper" + +describe "User views issues" do + let!(:closed_issue) { create(:closed_issue, project: project) } + let!(:open_issue1) { create(:issue, project: project) } + let!(:open_issue2) { create(:issue, project: project) } + set(:user) { create(:user) } + + shared_examples "opens issue from list" do + it "opens issue" do + click_link(issue.title) + + expect(page).to have_content(issue.title) + end + end + + shared_examples "open issues" do + context "open issues" do + let(:label) { create(:label, project: project, title: "bug") } + + before do + open_issue1.labels << label + + visit(project_issues_path(project, state: :opened)) + end + + it "shows open issues" do + expect(page).to have_content(project.name) + .and have_content(open_issue1.title) + .and have_content(open_issue2.title) + .and have_no_content(closed_issue.title) + .and have_no_selector(".js-new-board-list") + end + + it "opens issues by label" do + page.within(".issues-list") do + click_link(label.title) + end + + expect(page).to have_content(open_issue1.title) + .and have_no_content(open_issue2.title) + .and have_no_content(closed_issue.title) + end + + include_examples "opens issue from list" do + let(:issue) { open_issue1 } + end + end + end + + shared_examples "closed issues" do + context "closed issues" do + before do + visit(project_issues_path(project, state: :closed)) + end + + it "shows closed issues" do + expect(page).to have_content(project.name) + .and have_content(closed_issue.title) + .and have_no_content(open_issue1.title) + .and have_no_content(open_issue2.title) + .and have_no_selector(".js-new-board-list") + end + + include_examples "opens issue from list" do + let(:issue) { closed_issue } + end + end + end + + shared_examples "all issues" do + context "all issues" do + before do + visit(project_issues_path(project, state: :all)) + end + + it "shows all issues" do + expect(page).to have_content(project.name) + .and have_content(closed_issue.title) + .and have_content(open_issue1.title) + .and have_content(open_issue2.title) + .and have_no_selector(".js-new-board-list") + end + + include_examples "opens issue from list" do + let(:issue) { closed_issue } + end + end + end + + %w[internal public].each do |visibility| + shared_examples "#{visibility} project" do + context "when project is #{visibility}" do + let(:project) { create(:project_empty_repo, :"#{visibility}") } + + include_examples "open issues" + include_examples "closed issues" + include_examples "all issues" + end + end + end + + context "when signed in as developer" do + before do + project.add_developer(user) + sign_in(user) + end + + include_examples "public project" + include_examples "internal project" + end + + context "when not signed in" do + include_examples "public project" + end +end |