DEV: In development, refresh client when theme changes are made (#22978)

This brings the theme development experience (via the discourse_theme cli) closer to the experience of making javascript changes in Discourse core/plugins via Ember CLI. Whenever a change is made to a non-css theme field, all clients will be instructed to immediately refresh via message-bus.
This commit is contained in:
David Taylor
2023-08-04 11:02:26 +01:00
committed by GitHub
parent 28dc222e2f
commit e76e0ad592
3 changed files with 57 additions and 10 deletions

View File

@@ -1093,4 +1093,30 @@ HTML
expect(messages.count).to eq(0)
end
end
describe "development experience" do
it "sends 'development-mode-theme-changed event when non-css fields are updated" do
Theme.any_instance.stubs(:should_refresh_development_clients?).returns(true)
theme.set_field(target: :common, name: :scss, value: "body {background: green;}")
messages =
MessageBus
.track_publish { theme.save! }
.filter { |m| m.channel == "/file-change" }
.map(&:data)
expect(messages).not_to include("development-mode-theme-changed")
theme.set_field(target: :common, name: :header, value: "<p>Hello world</p>")
messages =
MessageBus
.track_publish { theme.save! }
.filter { |m| m.channel == "/file-change" }
.map(&:data)
expect(messages).to include(["development-mode-theme-changed"])
end
end
end