Commit 86e368a8af35fb0f09369630a226c80dc16ae5ec
1 parent
c7a64311
Exists in
master
and in
4 other branches
Reduce notes_on_merge_requests_spec time from 3 min to 1min
Showing
1 changed file
with
41 additions
and
55 deletions
Show diff stats
spec/features/notes_on_merge_requests_spec.rb
| @@ -14,15 +14,11 @@ describe "On a merge request", js: true do | @@ -14,15 +14,11 @@ describe "On a merge request", js: true do | ||
| 14 | subject { page } | 14 | subject { page } |
| 15 | 15 | ||
| 16 | describe "the note form" do | 16 | describe "the note form" do |
| 17 | - # main target form creation | ||
| 18 | - it { should have_css(".js-main-target-form", visible: true, count: 1) } | ||
| 19 | - | ||
| 20 | - # button initalization | ||
| 21 | - it { find(".js-main-target-form input[type=submit]").value.should == "Add Comment" } | ||
| 22 | - it { within(".js-main-target-form") { should_not have_link("Cancel") } } | ||
| 23 | - | ||
| 24 | - describe "without text" do | ||
| 25 | - it { within(".js-main-target-form") { should have_css(".js-note-preview-button", visible: false) } } | 17 | + it 'should be valid' do |
| 18 | + should have_css(".js-main-target-form", visible: true, count: 1) | ||
| 19 | + find(".js-main-target-form input[type=submit]").value.should == "Add Comment" | ||
| 20 | + within(".js-main-target-form") { should_not have_link("Cancel") } | ||
| 21 | + within(".js-main-target-form") { should have_css(".js-note-preview-button", visible: false) } | ||
| 26 | end | 22 | end |
| 27 | 23 | ||
| 28 | describe "with text" do | 24 | describe "with text" do |
| @@ -32,9 +28,10 @@ describe "On a merge request", js: true do | @@ -32,9 +28,10 @@ describe "On a merge request", js: true do | ||
| 32 | end | 28 | end |
| 33 | end | 29 | end |
| 34 | 30 | ||
| 35 | - it { within(".js-main-target-form") { should_not have_css(".js-comment-button[disabled]") } } | ||
| 36 | - | ||
| 37 | - it { within(".js-main-target-form") { should have_css(".js-note-preview-button", visible: true) } } | 31 | + it 'should have enable submit button and preview button' do |
| 32 | + within(".js-main-target-form") { should_not have_css(".js-comment-button[disabled]") } | ||
| 33 | + within(".js-main-target-form") { should have_css(".js-note-preview-button", visible: true) } | ||
| 34 | + end | ||
| 38 | end | 35 | end |
| 39 | 36 | ||
| 40 | describe "with preview" do | 37 | describe "with preview" do |
| @@ -45,10 +42,11 @@ describe "On a merge request", js: true do | @@ -45,10 +42,11 @@ describe "On a merge request", js: true do | ||
| 45 | end | 42 | end |
| 46 | end | 43 | end |
| 47 | 44 | ||
| 48 | - it { within(".js-main-target-form") { should have_css(".js-note-preview", text: "This is awesome", visible: true) } } | ||
| 49 | - | ||
| 50 | - it { within(".js-main-target-form") { should have_css(".js-note-preview-button", visible: false) } } | ||
| 51 | - it { within(".js-main-target-form") { should have_css(".js-note-edit-button", visible: true) } } | 45 | + it 'should have text and visible edit button' do |
| 46 | + within(".js-main-target-form") { should have_css(".js-note-preview", text: "This is awesome", visible: true) } | ||
| 47 | + within(".js-main-target-form") { should have_css(".js-note-preview-button", visible: false) } | ||
| 48 | + within(".js-main-target-form") { should have_css(".js-note-edit-button", visible: true) } | ||
| 49 | + end | ||
| 52 | end | 50 | end |
| 53 | end | 51 | end |
| 54 | 52 | ||
| @@ -61,27 +59,20 @@ describe "On a merge request", js: true do | @@ -61,27 +59,20 @@ describe "On a merge request", js: true do | ||
| 61 | end | 59 | end |
| 62 | end | 60 | end |
| 63 | 61 | ||
| 64 | - # note added | ||
| 65 | - it { should have_content("This is awsome!") } | ||
| 66 | - | ||
| 67 | - # reset form | ||
| 68 | - it { within(".js-main-target-form") { should have_no_field("note[note]", with: "This is awesome!") } } | ||
| 69 | - | ||
| 70 | - # return from preview | ||
| 71 | - it { within(".js-main-target-form") { should have_css(".js-note-preview", visible: false) } } | ||
| 72 | - it { within(".js-main-target-form") { should have_css(".js-note-text", visible: true) } } | ||
| 73 | - | 62 | + it 'should be added and form reset' do |
| 63 | + should have_content("This is awsome!") | ||
| 64 | + within(".js-main-target-form") { should have_no_field("note[note]", with: "This is awesome!") } | ||
| 65 | + within(".js-main-target-form") { should have_css(".js-note-preview", visible: false) } | ||
| 66 | + within(".js-main-target-form") { should have_css(".js-note-text", visible: true) } | ||
| 67 | + end | ||
| 74 | 68 | ||
| 75 | it "should be removable" do | 69 | it "should be removable" do |
| 76 | find(".js-note-delete").trigger("click") | 70 | find(".js-note-delete").trigger("click") |
| 77 | - | ||
| 78 | should_not have_css(".note") | 71 | should_not have_css(".note") |
| 79 | end | 72 | end |
| 80 | end | 73 | end |
| 81 | end | 74 | end |
| 82 | 75 | ||
| 83 | - | ||
| 84 | - | ||
| 85 | describe "On a merge request diff", js: true, focus: true do | 76 | describe "On a merge request diff", js: true, focus: true do |
| 86 | let!(:project) { create(:project_with_code) } | 77 | let!(:project) { create(:project_with_code) } |
| 87 | let!(:merge_request) { create(:merge_request_with_diffs, project: project) } | 78 | let!(:merge_request) { create(:merge_request_with_diffs, project: project) } |
| @@ -89,12 +80,7 @@ describe "On a merge request diff", js: true, focus: true do | @@ -89,12 +80,7 @@ describe "On a merge request diff", js: true, focus: true do | ||
| 89 | before do | 80 | before do |
| 90 | login_as :user | 81 | login_as :user |
| 91 | project.team << [@user, :master] | 82 | project.team << [@user, :master] |
| 92 | - | ||
| 93 | visit diffs_project_merge_request_path(project, merge_request) | 83 | visit diffs_project_merge_request_path(project, merge_request) |
| 94 | - | ||
| 95 | - within '.diffs-tab' do | ||
| 96 | - click_link("Diff") | ||
| 97 | - end | ||
| 98 | end | 84 | end |
| 99 | 85 | ||
| 100 | subject { page } | 86 | subject { page } |
| @@ -111,15 +97,15 @@ describe "On a merge request diff", js: true, focus: true do | @@ -111,15 +97,15 @@ describe "On a merge request diff", js: true, focus: true do | ||
| 111 | end | 97 | end |
| 112 | 98 | ||
| 113 | describe "the note form" do | 99 | describe "the note form" do |
| 114 | - # set up hidden fields correctly | ||
| 115 | - it { within(".js-temp-notes-holder") { find("#note_noteable_type").value.should == "MergeRequest" } } | ||
| 116 | - it { within(".js-temp-notes-holder") { find("#note_noteable_id").value.should == merge_request.id.to_s } } | ||
| 117 | - it { within(".js-temp-notes-holder") { find("#note_commit_id").value.should == "" } } | ||
| 118 | - it { within(".js-temp-notes-holder") { find("#note_line_code").value.should == "4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185" } } | ||
| 119 | - | ||
| 120 | - # buttons | ||
| 121 | - it { should have_button("Add Comment") } | ||
| 122 | - it { should have_css(".js-close-discussion-note-form", text: "Cancel") } | 100 | + it 'should be valid' do |
| 101 | + within(".js-temp-notes-holder") { find("#note_noteable_type").value.should == "MergeRequest" } | ||
| 102 | + within(".js-temp-notes-holder") { find("#note_noteable_id").value.should == merge_request.id.to_s } | ||
| 103 | + within(".js-temp-notes-holder") { find("#note_commit_id").value.should == "" } | ||
| 104 | + within(".js-temp-notes-holder") { find("#note_line_code").value.should == "4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185" } | ||
| 105 | + | ||
| 106 | + should have_button("Add Comment") | ||
| 107 | + should have_css(".js-close-discussion-note-form", text: "Cancel") | ||
| 108 | + end | ||
| 123 | 109 | ||
| 124 | it "shouldn't add a second form for same row" do | 110 | it "shouldn't add a second form for same row" do |
| 125 | find("#4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185.line_holder .js-add-diff-note-button").trigger("click") | 111 | find("#4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185.line_holder .js-add-diff-note-button").trigger("click") |
| @@ -175,11 +161,12 @@ describe "On a merge request diff", js: true, focus: true do | @@ -175,11 +161,12 @@ describe "On a merge request diff", js: true, focus: true do | ||
| 175 | # removed form after submit | 161 | # removed form after submit |
| 176 | it { should have_no_css("#342e16cbbd482ac2047dc679b2749d248cc1428f_18_17.line_holder + .js-temp-notes-holder") } | 162 | it { should have_no_css("#342e16cbbd482ac2047dc679b2749d248cc1428f_18_17.line_holder + .js-temp-notes-holder") } |
| 177 | 163 | ||
| 178 | - # added discussion | ||
| 179 | - it { should have_content("Another comment on line 17") } | ||
| 180 | - it { should have_css("#342e16cbbd482ac2047dc679b2749d248cc1428f_18_17.line_holder + .notes_holder") } | ||
| 181 | - it { should have_css("#342e16cbbd482ac2047dc679b2749d248cc1428f_18_17.line_holder + .notes_holder .note", count: 1) } | ||
| 182 | - it { should have_link("Reply") } | 164 | + it 'should be added as discussion' do |
| 165 | + should have_content("Another comment on line 17") | ||
| 166 | + should have_css("#342e16cbbd482ac2047dc679b2749d248cc1428f_18_17.line_holder + .notes_holder") | ||
| 167 | + should have_css("#342e16cbbd482ac2047dc679b2749d248cc1428f_18_17.line_holder + .notes_holder .note", count: 1) | ||
| 168 | + should have_link("Reply") | ||
| 169 | + end | ||
| 183 | 170 | ||
| 184 | it "should remove last note of a discussion" do | 171 | it "should remove last note of a discussion" do |
| 185 | within("#342e16cbbd482ac2047dc679b2749d248cc1428f_18_17.line_holder + .notes_holder") do | 172 | within("#342e16cbbd482ac2047dc679b2749d248cc1428f_18_17.line_holder + .notes_holder") do |
| @@ -209,13 +196,12 @@ describe "On a merge request diff", js: true, focus: true do | @@ -209,13 +196,12 @@ describe "On a merge request diff", js: true, focus: true do | ||
| 209 | end | 196 | end |
| 210 | end | 197 | end |
| 211 | 198 | ||
| 212 | - # inserted note | ||
| 213 | - it { should have_content("An additional comment in reply") } | ||
| 214 | - it { within("#4735dfc552ad7bf15ca468adc3cad9d05b624490_184_184.line_holder + .notes_holder") { should have_css(".note", count: 2) } } | ||
| 215 | - | ||
| 216 | - # removed form after reply | ||
| 217 | - it { within("#4735dfc552ad7bf15ca468adc3cad9d05b624490_184_184.line_holder + .notes_holder") { should have_no_css("form") } } | ||
| 218 | - it { within("#4735dfc552ad7bf15ca468adc3cad9d05b624490_184_184.line_holder + .notes_holder") { should have_link("Reply") } } | 199 | + it 'should be inserted and form removed from reply' do |
| 200 | + should have_content("An additional comment in reply") | ||
| 201 | + within("#4735dfc552ad7bf15ca468adc3cad9d05b624490_184_184.line_holder + .notes_holder") { should have_css(".note", count: 2) } | ||
| 202 | + within("#4735dfc552ad7bf15ca468adc3cad9d05b624490_184_184.line_holder + .notes_holder") { should have_no_css("form") } | ||
| 203 | + within("#4735dfc552ad7bf15ca468adc3cad9d05b624490_184_184.line_holder + .notes_holder") { should have_link("Reply") } | ||
| 204 | + end | ||
| 219 | end | 205 | end |
| 220 | end | 206 | end |
| 221 | 207 |