A platform for community discussion. Free, open, simple.
FIX: Rewind was not dismissing when clicking callout (#36518)
Martin Brennanb466c5ec953c
diff --git a/plugins/discourse-rewind/assets/javascripts/discourse/connectors/before-panel-body/rewind-callout.gjs b/plugins/discourse-rewind/assets/javascripts/discourse/connectors/before-panel-body/rewind-callout.gjsindex 1da387fa66e..a2e000d0be6 100644--- a/plugins/discourse-rewind/assets/javascripts/discourse/connectors/before-panel-body/rewind-callout.gjs+++ b/plugins/discourse-rewind/assets/javascripts/discourse/connectors/before-panel-body/rewind-callout.gjs@@ -25,13 +25,10 @@ export default class RewindCallout extends Component {@service router;@service currentUser;- store = new KeyValueStore("discourse_rewind_" + this.fetchYear);+ store = new KeyValueStore("discourse_rewind_" + fetchRewindYear());get showCallout() {- return (- this.currentUser?.is_rewind_active &&- (this.currentUser?.is_development_env || !this.dismissed)- );+ return this.currentUser?.is_rewind_active && !this.dismissed;}get dismissed() {diff --git a/plugins/discourse-rewind/plugin.rb b/plugins/discourse-rewind/plugin.rbindex 8dd26f0399c..f7a5e7ce659 100644--- a/plugins/discourse-rewind/plugin.rb+++ b/plugins/discourse-rewind/plugin.rb@@ -45,8 +45,6 @@ after_initialize doRails.env.development? || Date.today.month == 1 || Date.today.month == 12end- add_to_serializer(:current_user, :is_development_env) { Rails.env.development? }-Discourse::Application.routes.append doget "u/:username/preferences/rewind" => "users#preferences",:constraints => {diff --git a/plugins/discourse-rewind/spec/system/rewind_callout_spec.rb b/plugins/discourse-rewind/spec/system/rewind_callout_spec.rbnew file mode 100644index 00000000000..7c9c7331477--- /dev/null+++ b/plugins/discourse-rewind/spec/system/rewind_callout_spec.rb@@ -0,0 +1,47 @@+# frozen_string_literal: true++describe "DiscourseRewind | rewind avatar decoration and callout", type: :system do+ fab!(:current_user, :user)++ before do+ SiteSetting.discourse_rewind_enabled = true+ sign_in(current_user)+ end++ context "when in december" do+ before { freeze_time DateTime.parse("2022-12-05") }++ it "shows avatar decoration and callout" do+ visit("/")++ expect(page).to have_css("body.rewind-notification-active")+ find("#toggle-current-user").click+ expect(page).to have_css(".rewind-callout__container")+ end++ context "when the user dismisses rewind by clicking the callout" do+ it "no longer shows the callout" do+ visit("/")++ expect(page).to have_css("body.rewind-notification-active")+ find("#toggle-current-user").click+ find(".rewind-callout__container .rewind-callout").click+ expect(page).to have_css(".rewind .rewind__header")+ expect(page).to have_current_path("/u/#{current_user.username}/activity/rewind")++ visit("/")+ expect(page).to have_no_css("body.rewind-notification-active")+ end+ end+ end++ context "when in november" do+ before { freeze_time DateTime.parse("2022-11-24") }++ it "doesn't show the avatar decoration and callout" do+ visit("/")++ expect(page).to have_no_css("body.rewind-notification-active")+ end+ end+end