0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-09 19:36:44 +08:00
discourse/plugins/discourse-narrative-bot/spec/requests/discobot_welcome_post_spec.rb
Martin Brennan ad2d3007d5
Some checks are pending
Licenses / run (push) Waiting to run
Linting / run (push) Waiting to run
Publish Assets / publish-assets (push) Waiting to run
Tests / core backend (push) Waiting to run
Tests / plugins backend (push) Waiting to run
Tests / core frontend (Chrome) (push) Waiting to run
Tests / plugins frontend (push) Waiting to run
Tests / themes frontend (push) Waiting to run
Tests / core system (push) Waiting to run
Tests / plugins system (push) Waiting to run
Tests / themes system (push) Waiting to run
Tests / core frontend (Firefox ESR) (push) Waiting to run
Tests / core frontend (Firefox Evergreen) (push) Waiting to run
Tests / chat system (push) Waiting to run
Tests / merge (push) Blocked by required conditions
FEATURE: Disable user tips + narrative bot welcome post for all sites (round 2) (#34373)
We want to temporarily disable user tips and the Discobot welcome PM
on all sites by default until we have time to improve their
functionality, because
right now they create a lot of noise for new members and admins without
providing obvious benefits.

Existing sites which have customized any of these localization strings will have
`disable_discourse_narrative_bot_welcome_post` kept as `false`:

* system_messages.welcome_user.subject_template OR
* system_messages.welcome_user.text_body_template OR
* discourse_narrative_bot.new_user_narrative.hello.message

Followup revert 70859e277f.
2025-08-21 09:17:20 +10:00

58 lines
1.9 KiB
Ruby
Vendored

# frozen_string_literal: true
RSpec.describe "Discobot welcome post" do
let(:user) { Fabricate(:user) }
before do
SiteSetting.discourse_narrative_bot_enabled = true
SiteSetting.disable_discourse_narrative_bot_welcome_post = false
end
context "when discourse_narrative_bot_welcome_post_delay is 0" do
it "should not delay the welcome post" do
user
expect { sign_in(user) }.to_not change { Jobs::NarrativeInit.jobs.count }
end
end
context "when discourse_narrative_bot_welcome_post_delay is greater than 0" do
before { SiteSetting.discourse_narrative_bot_welcome_post_delay = 5 }
context "when user logs in normally" do
it "should delay the welcome post until user logs in" do
expect { sign_in(user) }.to change { Jobs::NarrativeInit.jobs.count }.by(1)
expect(Jobs::NarrativeInit.jobs.first["args"].first["user_id"]).to eq(user.id)
end
end
context "when user redeems an invite" do
let!(:invite) do
Fabricate(:invite, invited_by: Fabricate(:admin), email: "testing@gmail.com")
end
it "should delay the welcome post until the user logs in" do
expect do
put "/invites/show/#{invite.invite_key}.json",
params: {
username: "somename",
name: "testing",
password: "verystrongpassword",
email_token: invite.email_token,
}
end.to change { User.count }.by(1)
expect(Jobs::NarrativeInit.jobs.first["args"].first["user_id"]).to eq(User.last.id)
end
end
end
context "when user is staged" do
let(:staged_user) { Fabricate(:user, staged: true) }
before { SiteSetting.discourse_narrative_bot_welcome_post_type = "welcome_message" }
it "should not send welcome message" do
expect { staged_user }.to_not change { Jobs::SendDefaultWelcomeMessage.jobs.count }
end
end
end