-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DEV: Add system specs for reaction notifications
- Loading branch information
1 parent
23551cd
commit 3e486fb
Showing
2 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# frozen_string_literal: true | ||
|
||
Fabricator(:one_reaction_notification, from: :notification) do | ||
transient :acting_user | ||
notification_type Notification.types[:reaction] | ||
post | ||
topic { |attrs| attrs[:post].topic } | ||
data do |attrs| | ||
acting_user = attrs[:acting_user] || Fabricate(:user) | ||
{ | ||
topic_title: attrs[:topic].title, | ||
original_post_id: attrs[:post].id, | ||
original_post_type: attrs[:post].post_type, | ||
original_username: acting_user.username, | ||
revision_number: nil, | ||
display_username: acting_user.username, | ||
}.to_json | ||
end | ||
end | ||
|
||
Fabricator(:multiple_reactions_notification, from: :one_reaction_notification) do | ||
transient :acting_user_2 | ||
transient :count | ||
data do |attrs| | ||
acting_user = attrs[:acting_user] || Fabricate(:user) | ||
acting_user_2 = attrs[:acting_user_2] || Fabricate(:user) | ||
{ | ||
topic_title: attrs[:topic].title, | ||
original_post_id: attrs[:post].id, | ||
original_post_type: attrs[:post].post_type, | ||
original_username: acting_user_2.username, | ||
revision_number: nil, | ||
display_username: acting_user_2.username, | ||
previous_notification_id: 2019, | ||
username2: acting_user.username, | ||
count: attrs[:count] || 2, | ||
}.to_json | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# frozen_string_literal: true | ||
|
||
describe "Reactions | Notifications", type: :system, js: true do | ||
fab!(:current_user) { Fabricate(:user) } | ||
fab!(:acting_user_1) { Fabricate(:user) } | ||
fab!(:acting_user_2) { Fabricate(:user) } | ||
|
||
fab!(:one_reaction_notification) do | ||
Fabricate(:one_reaction_notification, user: current_user, acting_user: acting_user_1) | ||
end | ||
|
||
fab!(:two_reactions_notification) do | ||
Fabricate( | ||
:multiple_reactions_notification, | ||
user: current_user, | ||
count: 2, | ||
acting_user: acting_user_1, | ||
acting_user_2: acting_user_2, | ||
) | ||
end | ||
|
||
fab!(:three_reactions_notification) do | ||
Fabricate( | ||
:multiple_reactions_notification, | ||
user: current_user, | ||
count: 3, | ||
acting_user: acting_user_1, | ||
acting_user_2: acting_user_2, | ||
) | ||
end | ||
|
||
let(:user_menu) { PageObjects::Components::UserMenu.new } | ||
|
||
before do | ||
SiteSetting.discourse_reactions_enabled = true | ||
sign_in(current_user) | ||
end | ||
|
||
it "renders reactions notifications correctly in the user menu" do | ||
visit("/") | ||
|
||
user_menu.open | ||
|
||
expect(page).to have_css( | ||
"#quick-access-all-notifications .notification.reaction .item-label", | ||
count: 3, | ||
) | ||
|
||
labels = page.all("#quick-access-all-notifications .notification.reaction .item-label") | ||
expect(labels[0]).to have_text( | ||
I18n.t( | ||
"js.notifications.reaction_multiple_users", | ||
username: acting_user_2.username, | ||
count: 2, | ||
), | ||
) | ||
expect(labels[1]).to have_text( | ||
I18n.t( | ||
"js.notifications.reaction_2_users", | ||
username: acting_user_2.username, | ||
username2: acting_user_1.username, | ||
), | ||
) | ||
expect(labels[2]).to have_text(acting_user_1.username) | ||
end | ||
end |