Commit 8c604c9d31561dc364173626923d568bf76414ba
1 parent
1883e083
Exists in
master
and in
4 other branches
Add specs for notes on wall
Showing
1 changed file
with
86 additions
and
0 deletions
Show diff stats
... | ... | @@ -0,0 +1,86 @@ |
1 | +require 'spec_helper' | |
2 | + | |
3 | +describe "On the project wall", js: true do | |
4 | + let!(:project) { create(:project) } | |
5 | + let!(:commit) { project.commit("bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a") } | |
6 | + | |
7 | + before do | |
8 | + login_as :user | |
9 | + project.add_access(@user, :read, :write) | |
10 | + | |
11 | + visit wall_project_path(project) | |
12 | + end | |
13 | + | |
14 | + subject { page } | |
15 | + | |
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 { within(".js-main-target-form") { should have_button("Add Comment") } } | |
22 | + it { within(".js-main-target-form") { should_not have_link("Cancel") } } | |
23 | + | |
24 | + # notifiactions | |
25 | + it { within(".js-main-target-form") { should have_checked_field("Project team") } } | |
26 | + it { within(".js-main-target-form") { should_not have_checked_field("Commit author") } } | |
27 | + it { within(".js-main-target-form") { should_not have_unchecked_field("Commit author") } } | |
28 | + | |
29 | + describe "without text" do | |
30 | + it { within(".js-main-target-form") { should have_css(".js-note-preview-button", visible: false) } } | |
31 | + end | |
32 | + | |
33 | + describe "with text" do | |
34 | + before do | |
35 | + within(".js-main-target-form") do | |
36 | + fill_in "note[note]", with: "This is awesome" | |
37 | + end | |
38 | + end | |
39 | + | |
40 | + it { within(".js-main-target-form") { should_not have_css(".js-comment-button[disabled]") } } | |
41 | + | |
42 | + it { within(".js-main-target-form") { should have_css(".js-note-preview-button", visible: true) } } | |
43 | + end | |
44 | + | |
45 | + describe "with preview" do | |
46 | + before do | |
47 | + within(".js-main-target-form") do | |
48 | + fill_in "note[note]", with: "This is awesome" | |
49 | + find(".js-note-preview-button").trigger("click") | |
50 | + end | |
51 | + end | |
52 | + | |
53 | + it { within(".js-main-target-form") { should have_css(".js-note-preview", text: "This is awesome", visible: true) } } | |
54 | + | |
55 | + it { within(".js-main-target-form") { should have_css(".js-note-preview-button", visible: false) } } | |
56 | + it { within(".js-main-target-form") { should have_css(".js-note-edit-button", visible: true) } } | |
57 | + end | |
58 | + end | |
59 | + | |
60 | + describe "when posting a note" do | |
61 | + before do | |
62 | + within(".js-main-target-form") do | |
63 | + fill_in "note[note]", with: "This is awsome!" | |
64 | + find(".js-note-preview-button").trigger("click") | |
65 | + click_button "Add Comment" | |
66 | + end | |
67 | + end | |
68 | + | |
69 | + # note added | |
70 | + it { within(".js-main-target-form") { should have_content("This is awsome!") } } | |
71 | + | |
72 | + # reset form | |
73 | + it { within(".js-main-target-form") { should have_no_field("note[note]", with: "This is awesome!") } } | |
74 | + | |
75 | + # return from preview | |
76 | + it { within(".js-main-target-form") { should have_css(".js-note-preview", visible: false) } } | |
77 | + it { within(".js-main-target-form") { should have_css(".js-note-text", visible: true) } } | |
78 | + | |
79 | + | |
80 | + it "should be removable" do | |
81 | + find(".js-note-delete").trigger("click") | |
82 | + | |
83 | + should_not have_css(".note") | |
84 | + end | |
85 | + end | |
86 | +end | ... | ... |