mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-01 10:37:12 +08:00
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>
73 lines
2.5 KiB
Ruby
73 lines
2.5 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe WizardSerializer do
|
|
let(:admin) { Fabricate(:admin) }
|
|
|
|
after { ColorScheme.hex_cache.clear }
|
|
|
|
describe "color scheme" do
|
|
it "works with base colors" do
|
|
expect(Theme.where(id: SiteSetting.default_theme_id).first&.color_scheme).to be_nil
|
|
|
|
wizard = Wizard::Builder.new(admin).build
|
|
serializer = WizardSerializer.new(wizard, scope: Guardian.new(admin))
|
|
json = MultiJson.load(MultiJson.dump(serializer.as_json))
|
|
|
|
expect(json["wizard"]["current_color_scheme"][0]["name"]).to eq("primary")
|
|
expect(json["wizard"]["current_color_scheme"][0]["hex"]).to eq("222")
|
|
end
|
|
|
|
it "should provide custom colors correctly" do
|
|
colors =
|
|
ColorScheme.create_from_base(
|
|
name: "Customized",
|
|
colors: {
|
|
header_background: "00FF00",
|
|
header_primary: "20CCFF",
|
|
},
|
|
)
|
|
theme = Fabricate(:theme, color_scheme_id: colors.id)
|
|
|
|
SiteSetting.default_theme_id = theme.id
|
|
|
|
wizard = Wizard::Builder.new(admin).build
|
|
|
|
serializer = WizardSerializer.new(wizard, scope: Guardian.new(admin))
|
|
# serializer.as_json leaves in Ruby objects, force to true json
|
|
json = MultiJson.load(MultiJson.dump(serializer.as_json))
|
|
|
|
expect(json["wizard"]["current_color_scheme"].to_s).to include(
|
|
'{"name"=>"header_background", "hex"=>"00FF00"}', # ruby 3.3
|
|
).or include('{"name" => "header_background", "hex" => "00FF00"}') # ruby 3.4
|
|
end
|
|
end
|
|
|
|
describe "steps" do
|
|
let(:wizard) { Wizard::Builder.new(admin).build }
|
|
let(:serializer) { WizardSerializer.new(wizard, scope: Guardian.new(admin)) }
|
|
|
|
it "has expected steps" do
|
|
SiteSetting.login_required = true
|
|
SiteSetting.invite_only = true
|
|
SiteSetting.must_approve_users = true
|
|
|
|
json = MultiJson.load(MultiJson.dump(serializer.as_json))
|
|
steps = json["wizard"]["steps"]
|
|
|
|
expect(steps.length).to eq(1)
|
|
expect(steps.first["id"]).to eq("setup")
|
|
|
|
setup_step = steps.first
|
|
expect(setup_step).to_not be_nil
|
|
|
|
login_required_field = setup_step["fields"].find { |f| f["id"] == "login_required" }
|
|
expect(login_required_field["value"]).to eq("private")
|
|
|
|
invite_only_field = setup_step["fields"].find { |f| f["id"] == "invite_only" }
|
|
expect(invite_only_field["value"]).to eq("invite_only")
|
|
|
|
must_approve_users_field = setup_step["fields"].find { |f| f["id"] == "must_approve_users" }
|
|
expect(must_approve_users_field["value"]).to eq("yes")
|
|
end
|
|
end
|
|
end
|