Skip to content

Commit 23e83cd

Browse files
Uzay-GSidharthBansal
authored andcommitted
ADD: system tests for moderation, posts and comments (#7329)
* ADD: barnstar testing * ADD: testing reactions to posts * ADD: comment and note spam tests
1 parent f230e5e commit 23e83cd

File tree

3 files changed

+71
-1
lines changed

3 files changed

+71
-1
lines changed

test/system/comment_test.rb

+14
Original file line numberDiff line numberDiff line change
@@ -235,4 +235,18 @@ def setup
235235
assert_equal( \nComment updated.", message)
236236
end
237237

238+
test "reacting and unreacting to comment" do
239+
note = nodes(:one)
240+
visit note.path
241+
242+
first(".comment #dropdownMenuButton").click()
243+
244+
# click on thumbs up
245+
find("img[src='https://github.githubassets.com/images/icons/emoji/unicode/1f44d.png']").click()
246+
page.assert_selector("button[data-original-title='jeff reacted with thumbs up emoji']")
247+
248+
first("img[src='https://github.githubassets.com/images/icons/emoji/unicode/1f44d.png']").click()
249+
page.assert_no_selector("button[data-original-title='jeff reacted with thumbs up emoji'")
250+
end
251+
238252
end

test/system/moderation_tests.rb

+44
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,48 @@ def setup
6363
find("a#info-ellipsis").click()
6464
page.assert_selector "a[href='/unban/#{banned_page2.author.id}'"
6565
end
66+
67+
test "spamming a comment" do
68+
note = nodes(:one)
69+
visit note.path
70+
71+
accept_confirm("Are you sure? The user will no longer be able to log in or publish, and their content will be hidden except comments.") do
72+
first("a[data-original-title='Mark as spam'").click()
73+
end
74+
75+
page.assert_selector("div.alert-success", text: "Comment has been marked as spam and comment author has been banned. You can undo this on the spam moderation page.")
76+
77+
banned_comment_author = note.comments.first.author
78+
visit "/profile/#{banned_comment_author.name}"
79+
80+
page.assert_selector("div.alert", text: "That user has been banned.")
81+
end
82+
83+
84+
test "spamming and unspamming a page" do
85+
spam_page = nodes(:one)
86+
visit spam_page.path
87+
88+
# spam page
89+
first("span[data-original-title='Tools']").click()
90+
click_on "Spam"
91+
92+
# verify page has been spammed
93+
page.assert_selector("div.alert-success", text: "Item marked as spam and author banned. You can undo this on the spam moderation page.")
94+
visit spam_page.path
95+
page.assert_selector("span", text: "UNPUBLISHED")
96+
97+
# verify page author is banned
98+
visit "/profile/#{spam_page.author.name}"
99+
page.assert_selector("div.alert", text: "That user has been banned.")
100+
101+
# unspam page
102+
visit "/spam"
103+
find("a[href='/moderate/publish/#{spam_page.id}'").click()
104+
105+
# verify page is no longer spammed
106+
page.assert_selector("td", text: "Content published.")
107+
visit spam_page.path
108+
page.assert_no_selector("span", text: "UNPUBLISHED")
109+
end
66110
end

test/system/post_test.rb

+13-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def setup
99
visit '/'
1010

1111
find(".nav-link.loginToggle").click()
12-
fill_in("username-login", with: "jeff")
12+
fill_in("username-login", with: "palpatine")
1313
fill_in("password-signup", with: "secretive")
1414

1515
find(".login-modal-form #login-button").click()
@@ -228,4 +228,16 @@ def assert_page_does_not_reload(message = "page should not reload")
228228
assert_equal( \nContent deleted.", message )
229229
end
230230

231+
test "awarding barnstar functions correctly" do
232+
note = nodes(:one)
233+
visit note.path
234+
235+
find("span[data-original-title='Tools']").click()
236+
find("input[value='Give']").click()
237+
238+
page.assert_selector("div.alert-success", text: "You awarded the basic barnstar to #{note.author.name}")
239+
page.assert_selector("p", text: "#{note.author.name} was awarded the Basic Barnstar by palpatine for their work in this research note.")
240+
page.assert_selector(".comment-body p", text: "@palpatine awards a barnstar to #{note.author.name} for their awesome contribution!")
241+
end
242+
231243
end

0 commit comments

Comments
 (0)