FIX: Default to light theme in wizard so that previews are displayed

FIX: Default to light theme in wizard so that previews are displayed

Previously, without a theme selection, the previews wouldn’t show.

diff --git a/lib/wizard/builder.rb b/lib/wizard/builder.rb
index a8727bd..40318d8 100644
--- a/lib/wizard/builder.rb
+++ b/lib/wizard/builder.rb
@@ -155,7 +155,7 @@ class Wizard
           id: 'theme_previews',
           type: 'component',
           required: !default_theme_override,
-          value: scheme_id
+          value: scheme_id || ColorScheme::LIGHT_THEME_ID
         )
 
         # fix for the case when base_scheme is nil
diff --git a/spec/components/wizard/wizard_builder_spec.rb b/spec/components/wizard/wizard_builder_spec.rb
index 88cb951..b63ed9c 100644
--- a/spec/components/wizard/wizard_builder_spec.rb
+++ b/spec/components/wizard/wizard_builder_spec.rb
@@ -176,14 +176,26 @@ describe Wizard::Builder do
       end
     end
 
-    describe "when the default theme has been override" do
+    describe "when the default theme has been overridden by a theme without a color scheme" do
       before do
         theme.set_default!
       end
 
       it 'should set the right default values' do
         expect(field.required).to eq(false)
-        expect(field.value).to eq(nil)
+        expect(field.value).to eq("Light")
+      end
+    end
+
+    describe "when the default theme has been overridden by a theme with a color scheme" do
+      before do
+        theme.update(color_scheme_id: ColorScheme.find_by_name("Dark").id)
+        theme.set_default!
+      end
+
+      it 'should set the right default values' do
+        expect(field.required).to eq(false)
+        expect(field.value).to eq("Dark")
       end
     end
   end

GitHub sha: 76610acb

@markvanlan, You’ve looked at this code recently, would you mind taking a look at this?

1 Like

I’m assuming it works? Looks good to me!

1 Like