discourse/spec/lib/wizard/step_updater_spec.rb
Penar Musaraj efee8ea4fc
UX: One step wizard (#36082)
Consolidates all three wizard screens into one. Cleans up some leftover,
unused wizard elements (checkbox, image, canvas inputs).

Internal ticket: t/164852

<img width="2880" height="2376" alt="CleanShot 2025-11-25 at 10 35
43@2x"
src="https://github.com/user-attachments/assets/f824a172-38b0-4fda-922a-3732335b93b2"
/>

---------

Co-authored-by: Jordan Vidrine <jordan@jordanvidrine.com>
2025-11-25 13:35:32 -05:00

62 lines
1.8 KiB
Ruby

# frozen_string_literal: true
RSpec.describe Wizard::StepUpdater do
before { SiteSetting.wizard_enabled = true }
fab!(:user, :admin)
let(:wizard) { Wizard::Builder.new(user).build }
describe "setup" do
it "updates the setup step with all fields" do
updater =
wizard.create_updater(
"setup",
title: "new forum title",
default_locale: "ru",
login_required: "public",
invite_only: "sign_up",
must_approve_users: "no",
)
updater.update
expect(updater.success?).to eq(true)
expect(SiteSetting.title).to eq("new forum title")
expect(SiteSetting.login_required?).to eq(false)
expect(SiteSetting.invite_only?).to eq(false)
expect(SiteSetting.must_approve_users?).to eq(false)
expect(SiteSetting.default_locale).to eq("ru")
expect(wizard.completed_steps?("setup")).to eq(true)
end
it "won't allow updates to the default value when required" do
updater =
wizard.create_updater(
"setup",
title: SiteSetting.title,
login_required: "public",
invite_only: "sign_up",
must_approve_users: "no",
)
updater.update
expect(updater.success?).to eq(false)
end
it "updates privacy settings to private correctly" do
updater =
wizard.create_updater(
"setup",
title: "new forum title",
login_required: "private",
invite_only: "invite_only",
must_approve_users: "yes",
)
updater.update
expect(updater.success?).to eq(true)
expect(SiteSetting.login_required?).to eq(true)
expect(SiteSetting.invite_only?).to eq(true)
expect(SiteSetting.must_approve_users?).to eq(true)
expect(wizard.completed_steps?("setup")).to eq(true)
end
end
end