mirror of
https://github.com/discourse/discourse.git
synced 2025-06-05 08:07:17 +08:00
UX: add gift emoji styling for new features (#24523)
When admin has unseen new feature, gift emoji is added to a link. In addition, `/new-features` path was changed to `/whats-new`
This commit is contained in:

committed by
GitHub

parent
856ccb34e1
commit
dc2a0854b0
@ -164,7 +164,7 @@ RSpec.describe Admin::DashboardController do
|
||||
before { sign_in(admin) }
|
||||
|
||||
it "is empty by default" do
|
||||
get "/admin/dashboard/new-features.json"
|
||||
get "/admin/dashboard/whats-new.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = response.parsed_body
|
||||
expect(json["new_features"]).to eq(nil)
|
||||
@ -172,7 +172,7 @@ RSpec.describe Admin::DashboardController do
|
||||
|
||||
it "fails gracefully for invalid JSON" do
|
||||
Discourse.redis.set("new_features", "INVALID JSON")
|
||||
get "/admin/dashboard/new-features.json"
|
||||
get "/admin/dashboard/whats-new.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = response.parsed_body
|
||||
expect(json["new_features"]).to eq(nil)
|
||||
@ -181,7 +181,7 @@ RSpec.describe Admin::DashboardController do
|
||||
it "includes new features when available" do
|
||||
populate_new_features
|
||||
|
||||
get "/admin/dashboard/new-features.json"
|
||||
get "/admin/dashboard/whats-new.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = response.parsed_body
|
||||
|
||||
@ -195,7 +195,7 @@ RSpec.describe Admin::DashboardController do
|
||||
populate_new_features
|
||||
DiscourseUpdates.mark_new_features_as_seen(admin.id)
|
||||
|
||||
get "/admin/dashboard/new-features.json"
|
||||
get "/admin/dashboard/whats-new.json"
|
||||
expect(response.status).to eq(200)
|
||||
json = response.parsed_body
|
||||
|
||||
@ -209,7 +209,7 @@ RSpec.describe Admin::DashboardController do
|
||||
|
||||
expect(DiscourseUpdates.get_last_viewed_feature_date(admin.id)).to eq(nil)
|
||||
|
||||
get "/admin/dashboard/new-features.json"
|
||||
get "/admin/dashboard/whats-new.json"
|
||||
expect(response.status).to eq(200)
|
||||
expect(DiscourseUpdates.get_last_viewed_feature_date(admin.id)).to be_within_one_second_of(
|
||||
date2,
|
||||
@ -218,15 +218,33 @@ RSpec.describe Admin::DashboardController do
|
||||
date2 = 10.minutes.ago
|
||||
populate_new_features(date1, date2)
|
||||
|
||||
get "/admin/dashboard/new-features.json"
|
||||
get "/admin/dashboard/whats-new.json"
|
||||
expect(response.status).to eq(200)
|
||||
expect(DiscourseUpdates.get_last_viewed_feature_date(admin.id)).to be_within_one_second_of(
|
||||
date2,
|
||||
)
|
||||
end
|
||||
|
||||
it "marks new features as seen" do
|
||||
date1 = 30.minutes.ago
|
||||
date2 = 20.minutes.ago
|
||||
populate_new_features(date1, date2)
|
||||
|
||||
expect(DiscourseUpdates.new_features_last_seen(admin.id)).to eq(nil)
|
||||
expect(DiscourseUpdates.has_unseen_features?(admin.id)).to eq(true)
|
||||
|
||||
get "/admin/dashboard/whats-new.json"
|
||||
expect(response.status).to eq(200)
|
||||
|
||||
expect(DiscourseUpdates.new_features_last_seen(admin.id)).not_to eq(nil)
|
||||
expect(DiscourseUpdates.has_unseen_features?(admin.id)).to eq(false)
|
||||
|
||||
expect(DiscourseUpdates.new_features_last_seen(moderator.id)).to eq(nil)
|
||||
expect(DiscourseUpdates.has_unseen_features?(moderator.id)).to eq(true)
|
||||
end
|
||||
|
||||
it "doesn't error when there are no new features" do
|
||||
get "/admin/dashboard/new-features.json"
|
||||
get "/admin/dashboard/whats-new.json"
|
||||
expect(response.status).to eq(200)
|
||||
end
|
||||
end
|
||||
@ -237,7 +255,7 @@ RSpec.describe Admin::DashboardController do
|
||||
it "includes new features when available" do
|
||||
populate_new_features
|
||||
|
||||
get "/admin/dashboard/new-features.json"
|
||||
get "/admin/dashboard/whats-new.json"
|
||||
|
||||
json = response.parsed_body
|
||||
|
||||
@ -252,7 +270,7 @@ RSpec.describe Admin::DashboardController do
|
||||
|
||||
expect(DiscourseUpdates.get_last_viewed_feature_date(moderator.id)).to eq(nil)
|
||||
|
||||
get "/admin/dashboard/new-features.json"
|
||||
get "/admin/dashboard/whats-new.json"
|
||||
expect(response.status).to eq(200)
|
||||
expect(DiscourseUpdates.get_last_viewed_feature_date(moderator.id)).to eq(nil)
|
||||
end
|
||||
@ -262,49 +280,7 @@ RSpec.describe Admin::DashboardController do
|
||||
before { sign_in(user) }
|
||||
|
||||
it "denies access with a 404 response" do
|
||||
get "/admin/dashboard/new-features.json"
|
||||
|
||||
expect(response.status).to eq(404)
|
||||
expect(response.parsed_body["errors"]).to include(I18n.t("not_found"))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "#mark_new_features_as_seen" do
|
||||
after { DiscourseUpdates.clean_state }
|
||||
|
||||
context "when logged in as an admin" do
|
||||
before { sign_in(admin) }
|
||||
|
||||
it "resets last seen for a given user" do
|
||||
populate_new_features
|
||||
put "/admin/dashboard/mark-new-features-as-seen.json"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(DiscourseUpdates.new_features_last_seen(admin.id)).not_to eq(nil)
|
||||
expect(DiscourseUpdates.has_unseen_features?(admin.id)).to eq(false)
|
||||
end
|
||||
end
|
||||
|
||||
context "when logged in as a moderator" do
|
||||
before { sign_in(moderator) }
|
||||
|
||||
it "resets last seen for moderator" do
|
||||
populate_new_features
|
||||
|
||||
put "/admin/dashboard/mark-new-features-as-seen.json"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(DiscourseUpdates.new_features_last_seen(moderator.id)).not_to eq(nil)
|
||||
expect(DiscourseUpdates.has_unseen_features?(moderator.id)).to eq(false)
|
||||
end
|
||||
end
|
||||
|
||||
context "when logged in as a non-staff user" do
|
||||
before { sign_in(user) }
|
||||
|
||||
it "prevents marking new feature as seen with a 404 response" do
|
||||
put "/admin/dashboard/mark-new-features-as-seen.json"
|
||||
get "/admin/dashboard/whats-new.json"
|
||||
|
||||
expect(response.status).to eq(404)
|
||||
expect(response.parsed_body["errors"]).to include(I18n.t("not_found"))
|
||||
|
Reference in New Issue
Block a user