note.rb 3.82 KB
Newer Older
Nihad Abbasov's avatar
Nihad Abbasov committed
1 2 3
module SharedNote
  include Spinach::DSL

4
  step 'I delete a comment' do
Robert Speicher's avatar
Robert Speicher committed
5 6 7 8
    page.within('.notes') do
      find('.note').hover
      find(".js-note-delete").click
    end
9 10
  end

11
  step 'I haven\'t written any comment text' do
12
    page.within(".js-main-target-form") do
13 14 15 16
      fill_in "note[note]", with: ""
    end
  end

17
  step 'I leave a comment like "XML attached"' do
18
    page.within(".js-main-target-form") do
19 20 21
      fill_in "note[note]", with: "XML attached"
      click_button "Add Comment"
    end
Nihad Abbasov's avatar
Nihad Abbasov committed
22 23
  end

24
  step 'I preview a comment text like "Bug fixed :smile:"' do
25
    page.within(".js-main-target-form") do
26
      fill_in "note[note]", with: "Bug fixed :smile:"
27
      find('.js-md-preview-button').click
28
    end
Nihad Abbasov's avatar
Nihad Abbasov committed
29 30
  end

31
  step 'I submit the comment' do
32
    page.within(".js-main-target-form") do
33 34 35 36
      click_button "Add Comment"
    end
  end

Vinnie Okada's avatar
Vinnie Okada committed
37
  step 'I write a comment like ":+1: Nice"' do
38
    page.within(".js-main-target-form") do
Vinnie Okada's avatar
Vinnie Okada committed
39
      fill_in 'note[note]', with: ':+1: Nice'
40 41 42
    end
  end

43
  step 'I should not see a comment saying "XML attached"' do
44
    expect(page).not_to have_css(".note")
45 46
  end

47
  step 'I should not see the cancel comment button' do
48
    page.within(".js-main-target-form") do
49 50 51 52
      should_not have_link("Cancel")
    end
  end

53
  step 'I should not see the comment preview' do
54
    page.within(".js-main-target-form") do
Vinnie Okada's avatar
Vinnie Okada committed
55
      expect(find('.js-md-preview')).not_to be_visible
56 57 58
    end
  end

Vinnie Okada's avatar
Vinnie Okada committed
59
  step 'The comment preview tab should say there is nothing to do' do
60
    page.within(".js-main-target-form") do
Vinnie Okada's avatar
Vinnie Okada committed
61 62
      find('.js-md-preview-button').click
      expect(find('.js-md-preview')).to have_content('Nothing to preview.')
63 64 65
    end
  end

66
  step 'I should not see the comment text field' do
67
    page.within(".js-main-target-form") do
68
      expect(find('.js-note-text')).not_to be_visible
69 70 71
    end
  end

72
  step 'I should see a comment saying "XML attached"' do
73
    page.within(".note") do
74
      expect(page).to have_content("XML attached")
75 76 77
    end
  end

78
  step 'I should see an empty comment text field' do
79
    page.within(".js-main-target-form") do
80
      expect(page).to have_field("note[note]", with: "")
81 82 83
    end
  end

Vinnie Okada's avatar
Vinnie Okada committed
84
  step 'I should see the comment write tab' do
85
    page.within(".js-main-target-form") do
Vinnie Okada's avatar
Vinnie Okada committed
86
      expect(page).to have_css('.js-md-write-button', visible: true)
87 88 89
    end
  end

Vinnie Okada's avatar
Vinnie Okada committed
90
  step 'The comment preview tab should be display rendered Markdown' do
91
    page.within(".js-main-target-form") do
Vinnie Okada's avatar
Vinnie Okada committed
92
      find('.js-md-preview-button').click
Vinnie Okada's avatar
Vinnie Okada committed
93
      expect(find('.js-md-preview')).to have_css('img.emoji', visible: true)
94 95 96
    end
  end

Vinnie Okada's avatar
Vinnie Okada committed
97
  step 'I should see the comment preview' do
98
    page.within(".js-main-target-form") do
Vinnie Okada's avatar
Vinnie Okada committed
99
      expect(page).to have_css('.js-md-preview', visible: true)
100 101
    end
  end
102

103
  step 'I should see comment "XML attached"' do
104
    page.within(".note") do
105
      expect(page).to have_content("XML attached")
106 107
    end
  end
108

109
  step 'I should see no notes at all' do
110
    expect(page).to_not have_css('.note')
111 112
  end

113 114 115
  # Markdown

  step 'I leave a comment with a header containing "Comment with a header"' do
116
    page.within(".js-main-target-form") do
117 118 119 120 121 122 123
      fill_in "note[note]", with: "# Comment with a header"
      click_button "Add Comment"
      sleep 0.05
    end
  end

  step 'The comment with the header should not have an ID' do
124
    page.within(".note-body > .note-text") do
125 126
      expect(page).to     have_content("Comment with a header")
      expect(page).not_to have_css("#comment-with-a-header")
127 128
    end
  end
129

130
  step 'I edit the last comment with a +1' do
Robert Speicher's avatar
Robert Speicher committed
131 132 133 134
    page.within(".notes") do
      find(".note").hover
      find('.js-note-edit').click
    end
135

136
    page.within(".current-note-edit-form") do
137 138 139 140 141 142
      fill_in 'note[note]', with: '+1 Awesome!'
      click_button 'Save Comment'
    end
  end

  step 'I should see +1 in the description' do
143
    page.within(".note") do
144
      expect(page).to have_content("+1 Awesome!")
145 146
    end
  end
Nihad Abbasov's avatar
Nihad Abbasov committed
147
end