diff --git a/app/assets/javascripts/discourse/app/static/wizard/components/wizard-step.gjs b/app/assets/javascripts/discourse/app/static/wizard/components/wizard-step.gjs index b7c6630b782..a8e74dc40e4 100644 --- a/app/assets/javascripts/discourse/app/static/wizard/components/wizard-step.gjs +++ b/app/assets/javascripts/discourse/app/static/wizard/components/wizard-step.gjs @@ -11,7 +11,7 @@ import emoji from "discourse/helpers/emoji"; import { i18n } from "discourse-i18n"; import WizardField from "./wizard-field"; -const READY_STEP_INDEX = 5; +const READY_STEP_INDEX = 3; export default class WizardStepComponent extends Component { @tracked saving = false; diff --git a/app/assets/javascripts/discourse/app/static/wizard/models/wizard.js b/app/assets/javascripts/discourse/app/static/wizard/models/wizard.js index 73a60856ad6..70aac2a7cbb 100644 --- a/app/assets/javascripts/discourse/app/static/wizard/models/wizard.js +++ b/app/assets/javascripts/discourse/app/static/wizard/models/wizard.js @@ -26,7 +26,7 @@ export default class Wizard { get totalSteps() { // We used to use this.steps.length() here, but we don't want to // include optional steps after "Ready" here. - return 4; + return 2; } get title() { diff --git a/app/assets/stylesheets/wizard.scss b/app/assets/stylesheets/wizard.scss index c56b9073149..5d325dd2bfd 100644 --- a/app/assets/stylesheets/wizard.scss +++ b/app/assets/stylesheets/wizard.scss @@ -106,15 +106,6 @@ body.wizard { margin: 0 0 0.5em; } } - - &.styling { - max-width: 100%; - width: auto; - - @include viewport.until(sm) { - width: 95%; - } - } } &__fields { @@ -137,32 +128,6 @@ body.wizard { } } - &__step.branding .wizard-container__field { - @include viewport.until(sm) { - max-width: 100%; - } - } - - &__step.branding .wizard-container__preview { - background-color: var(--primary-very-low); - border-radius: 0.5em; - padding: 1em; - margin-bottom: 1em; - } - - &__step.branding .wizard-container__preview canvas { - @include viewport.until(sm) { - max-width: 100%; - height: auto !important; - } - } - - &__step.styling .wizard-container__field.styling-preview-field { - label { - display: none; - } - } - &__field { margin-bottom: 1em; } @@ -185,19 +150,6 @@ body.wizard { display: block; } - &__field.text-governing-law, - &__field.text-city-for-disputes { - @media only screen and (width <= 568px) { - display: none; - } - } - - &__field.dropdown-field.dropdown-homepage-style { - .wizard-container__dropdown { - height: auto; - } - } - &__step-form { display: flex; flex: 1 0 50%; @@ -231,58 +183,6 @@ body.wizard { } } - .preview-nav { - display: flex; - justify-content: flex-end; - position: relative; - padding-right: 10px; - - .preview-nav-button { - text-align: center; - padding: 10px 15px; - cursor: pointer; - margin-left: 10px; - font-size: 14px; - font-weight: bold; - color: var(--primary-high); - - &.active { - background: var(--secondary); - border-bottom-left-radius: 10px; - border-bottom-right-radius: 10px; - color: var(--tertiary); - border-top: none; - } - } - } - - .previews { - position: relative; - height: 320px; - width: 628px; - overflow: hidden; - background: var(--secondary); - border-radius: 10px; - cursor: grab; - user-select: none; - - &.dragging { - cursor: grabbing; - } - - .topic-preview { - position: absolute; - left: 0; - top: 0; - } - - .homepage-preview { - position: absolute; - left: calc(100% + 25px); - top: 0; - } - } - &__step-header { text-align: center; margin-bottom: 3em; @@ -321,10 +221,6 @@ body.wizard { } } - &__step.branding .wizard-container__description { - font-size: var(--font-0); - } - &__buttons-left { display: flex; flex-wrap: wrap; @@ -526,10 +422,6 @@ body.wizard { font-size: var(--font-up-1); } - &__step.styling .wizard-container__label { - font-size: var(--font-0); - } - &__label.required { display: inline; color: var(--danger); @@ -579,28 +471,6 @@ body.wizard { border-radius: 4px; } - &__dropdown.color-palettes .select-kit-row.color-palettes-row .name { - flex: 0 0 30%; - } - - &__dropdown.color-palettes .select-kit-row.color-palettes-row .palettes { - flex: 1 1 70%; - overflow: hidden; - } - - &__dropdown.homepage-style-selector { - .select-kit-row { - .name { - font-weight: bold; - } - - .desc { - display: block; - margin-top: 0.1em; - } - } - } - &__field.checkbox-field .wizard-container__label { cursor: pointer; display: inline-block; @@ -744,10 +614,6 @@ body.wizard { top: 2px; } - .wizard-container__image-upload canvas { - border: 1px solid rgba(0, 0, 0, 0.2); - } - .finish-installation { .wizard-congratulations-wrap { display: flex; diff --git a/lib/wizard/builder.rb b/lib/wizard/builder.rb index a59e57065f6..a40ffaeb25f 100644 --- a/lib/wizard/builder.rb +++ b/lib/wizard/builder.rb @@ -13,8 +13,6 @@ class Wizard append_introduction_step append_privacy_step - append_styling_step - append_branding_step append_ready_step DiscourseEvent.trigger(:build_wizard, @wizard) @@ -119,191 +117,6 @@ class Wizard end end - def append_branding_step - @wizard.append_step("branding") do |step| - step.emoji = "framed_picture" - step.add_field(id: "logo", type: "image", value: SiteSetting.site_logo_url) - step.add_field(id: "logo_small", type: "image", value: SiteSetting.site_logo_small_url) - - step.on_update do |updater| - if SiteSetting.site_logo_url != updater.fields[:logo] || - SiteSetting.site_logo_small_url != updater.fields[:logo_small] - updater.apply_settings(:logo, :logo_small) - updater.refresh_required = true - end - end - end - end - - def append_styling_step - @wizard.append_step("styling") do |step| - step.emoji = "art" - default_theme = Theme.find_default - default_theme_override = SiteSetting.exists?(name: "default_theme_id") - - base_scheme = default_theme&.color_scheme&.base_scheme_id - color_scheme_name = default_theme&.color_scheme&.name - - scheme_id = - default_theme_override ? (base_scheme || color_scheme_name) : ColorScheme::LIGHT_THEME_ID - - themes = - step.add_field( - id: "color_scheme", - type: "dropdown", - required: !default_theme_override, - value: scheme_id || ColorScheme::LIGHT_THEME_ID, - show_in_sidebar: true, - ) - - # fix for the case when base_scheme is nil - if scheme_id && default_theme_override && base_scheme.nil? - scheme = default_theme.color_scheme - themes.add_choice(scheme_id, data: { colors: scheme.colors_hashes }) - end - - ColorScheme.base_color_scheme_colors.each do |t| - themes.add_choice(t[:id], data: { colors: t[:colors] }) - end - - if SiteSetting.base_font != SiteSetting.heading_font - body_font = - step.add_field( - id: "body_font", - type: "dropdown", - value: SiteSetting.base_font, - show_in_sidebar: true, - ) - - heading_font = - step.add_field( - id: "heading_font", - type: "dropdown", - value: SiteSetting.heading_font, - show_in_sidebar: true, - ) - else - site_font = - step.add_field( - id: "site_font", - type: "dropdown", - value: SiteSetting.base_font, - show_in_sidebar: true, - ) - end - - allowed_fonts = WIZARD_FONTS - allowed_fonts << SiteSetting.base_font if !allowed_fonts.include?(SiteSetting.base_font) - if !allowed_fonts.include?(SiteSetting.heading_font) - allowed_fonts << SiteSetting.heading_font - end - - DiscourseFonts - .fonts - .select do |font| - # We only want to display certain fonts in the wizard, others will be accessible - # in site settings. - allowed_fonts.include?(font[:key]) - end - .sort_by { |font| font[:name] } - .each do |font| - body_font&.add_choice(font[:key], label: font[:name]) - heading_font&.add_choice(font[:key], label: font[:name]) - site_font&.add_choice(font[:key], label: font[:name]) - end - - current = - ( - if SiteSetting.homepage == "categories" - SiteSetting.desktop_category_page_style - else - SiteSetting.homepage - end - ) - style = - step.add_field( - id: "homepage_style", - type: "dropdown", - required: false, - value: current, - show_in_sidebar: true, - ) - - # When changing these options, also consider the Dropdown component - # for the wizard, we have special logic to add a "Custom" category for - # unsupported options. - style.add_choice("latest") - style.add_choice("hot") - # Subset of CategoryPageStyle, we don't want to show all the options here. - style.add_choice("categories_boxes") - - step.add_field(id: "styling_preview", type: "styling-preview") - - step.on_update do |updater| - if updater.fields[:site_font].present? - updater.update_setting(:base_font, updater.fields[:site_font]) - updater.update_setting(:heading_font, updater.fields[:site_font]) - else - updater.update_setting(:base_font, updater.fields[:body_font]) - updater.update_setting(:heading_font, updater.fields[:heading_font]) - end - - top_menu = SiteSetting.top_menu_map - if !updater.fields[:homepage_style].include?("categories") && - !updater.fields[:homepage_style].include?("category") - if top_menu.first != updater.fields[:homepage_style] - top_menu.delete(updater.fields[:homepage_style]) - top_menu.insert(0, updater.fields[:homepage_style]) - end - else - top_menu.delete("categories") - top_menu.insert(0, "categories") - updater.update_setting(:desktop_category_page_style, updater.fields[:homepage_style]) - end - updater.update_setting(:top_menu, top_menu.join("|")) - - scheme_name = ((updater.fields[:color_scheme] || "") || ColorScheme::LIGHT_THEME_ID) - - if updater.setting_changed?(:base_font) || updater.setting_changed?(:heading_font) - updater.refresh_required = true - end - - next unless scheme_name.present? && ColorScheme.is_base?(scheme_name) - - name = I18n.t("color_schemes.#{scheme_name.downcase.gsub(" ", "_")}_theme_name") - - scheme = ColorScheme.find_by(base_scheme_id: scheme_name, via_wizard: true) - scheme ||= - ColorScheme.create_from_base(name: name, via_wizard: true, base_scheme_id: scheme_name) - - theme_changed = false - if default_theme - if default_theme.color_scheme_id != scheme.id - default_theme.color_scheme_id = scheme.id - default_theme.save! - theme_changed = true - end - else - theme = - Theme.create!( - name: I18n.t("color_schemes.default_theme_name"), - user_id: @wizard.user.id, - color_scheme_id: scheme.id, - ) - - theme.set_default! - theme_changed = true - end - - updater.update_setting(:default_dark_mode_color_scheme_id, -1) if scheme.is_dark? - - if updater.setting_changed?(:default_dark_mode_color_scheme_id) || theme_changed - updater.refresh_required = true - end - end - end - end - def replace_setting_value(updater, raw, field_name) old_value = SiteSetting.get(field_name) old_value = field_name if old_value.blank? diff --git a/spec/lib/wizard/step_updater_spec.rb b/spec/lib/wizard/step_updater_spec.rb index 369e00b422a..abbb147f3e5 100644 --- a/spec/lib/wizard/step_updater_spec.rb +++ b/spec/lib/wizard/step_updater_spec.rb @@ -79,335 +79,4 @@ RSpec.describe Wizard::StepUpdater do expect(wizard.completed_steps?("privacy")).to eq(true) end end - - describe "styling" do - it "updates fonts" do - updater = - wizard.create_updater( - "styling", - body_font: "open_sans", - heading_font: "oswald", - homepage_style: "latest", - ) - updater.update - expect(updater.success?).to eq(true) - expect(updater.refresh_required?).to eq(true) - expect(wizard.completed_steps?("styling")).to eq(true) - expect(SiteSetting.base_font).to eq("open_sans") - expect(SiteSetting.heading_font).to eq("oswald") - end - - it "updates both fonts if site_font is used" do - updater = wizard.create_updater("styling", site_font: "open_sans", homepage_style: "latest") - updater.update - expect(updater.success?).to eq(true) - expect(updater.refresh_required?).to eq(true) - expect(wizard.completed_steps?("styling")).to eq(true) - expect(SiteSetting.base_font).to eq("open_sans") - expect(SiteSetting.heading_font).to eq("open_sans") - end - - it "does not require refresh if the font, color scheme, or theme are unchanged" do - SiteSetting.base_font = "open_sans" - SiteSetting.heading_font = "open_sans" - SiteSetting.top_menu = "latest|categories|unread|top" - dark_scheme = ColorScheme.find_by(name: "Dark") - Theme.find_default.update!(color_scheme: dark_scheme) - SiteSetting.default_dark_mode_color_scheme_id = -1 - updater = - wizard.create_updater( - "styling", - color_scheme: "Dark", - site_font: "open_sans", - heading_font: "open_sans", - homepage_style: "latest", - ) - updater.update - expect(updater.success?).to eq(true) - expect(updater.refresh_required?).to eq(false) - end - - context "with colors" do - context "with an existing color scheme" do - fab!(:color_scheme) { Fabricate(:color_scheme, name: "existing", via_wizard: true) } - - it "updates the scheme" do - updater = - wizard.create_updater( - "styling", - color_scheme: "Dark", - body_font: "arial", - heading_font: "arial", - homepage_style: "latest", - ) - updater.update - expect(updater.success?).to eq(true) - expect(wizard.completed_steps?("styling")).to eq(true) - expect(updater.refresh_required?).to eq(true) - theme = Theme.find_by(id: SiteSetting.default_theme_id) - expect(theme.color_scheme.base_scheme_id).to eq("Dark") - end - end - - context "with an existing default theme" do - fab!(:theme) - - before { theme.set_default! } - - it "should update the color scheme of the default theme" do - updater = - wizard.create_updater( - "styling", - color_scheme: "Neutral", - body_font: "arial", - heading_font: "arial", - homepage_style: "latest", - ) - expect { updater.update }.not_to change { Theme.count } - expect(updater.refresh_required?).to eq(true) - theme.reload - expect(theme.color_scheme.base_scheme_id).to eq("Neutral") - end - end - - context "without an existing theme" do - before { Theme.delete_all } - - context "with dark theme" do - it "creates the theme" do - updater = - wizard.create_updater( - "styling", - color_scheme: "Dark", - body_font: "arial", - heading_font: "arial", - homepage_style: "latest", - ) - - expect { updater.update }.to change { Theme.count }.by(1) - - theme = Theme.last - - expect(theme.user_id).to eq(wizard.user.id) - expect(theme.color_scheme.base_scheme_id).to eq("Dark") - end - end - - context "with light theme" do - it "creates the theme" do - updater = - wizard.create_updater( - "styling", - color_scheme: ColorScheme::LIGHT_THEME_ID, - body_font: "arial", - heading_font: "arial", - homepage_style: "latest", - ) - - expect { updater.update }.to change { Theme.count }.by(1) - - theme = Theme.last - - expect(theme.user_id).to eq(wizard.user.id) - - expect(theme.color_scheme).to eq(ColorScheme.find_by(name: ColorScheme::LIGHT_THEME_ID)) - end - end - end - - context "without an existing scheme" do - it "creates the scheme" do - ColorScheme.destroy_all - updater = - wizard.create_updater( - "styling", - color_scheme: "Dark", - body_font: "arial", - heading_font: "arial", - homepage_style: "latest", - ) - updater.update - expect(updater.success?).to eq(true) - expect(wizard.completed_steps?("styling")).to eq(true) - - color_scheme = ColorScheme.where(via_wizard: true).first - expect(color_scheme).to be_present - expect(color_scheme.colors).to be_present - - theme = Theme.find_by(id: SiteSetting.default_theme_id) - expect(theme.color_scheme_id).to eq(color_scheme.id) - end - end - - context "with auto dark mode" do - before do - dark_scheme = ColorScheme.where(name: "Dark").first - SiteSetting.default_dark_mode_color_scheme_id = dark_scheme.id - end - - it "does nothing when selected scheme is light" do - updater = - wizard.create_updater( - "styling", - color_scheme: "Neutral", - body_font: "arial", - heading_font: "arial", - homepage_style: "latest", - ) - - expect { updater.update }.not_to change { SiteSetting.default_dark_mode_color_scheme_id } - end - - it "unsets auto dark mode site setting when default selected scheme is also dark" do - updater = - wizard.create_updater( - "styling", - color_scheme: "Latte", - body_font: "arial", - heading_font: "arial", - homepage_style: "latest", - ) - - expect { updater.update }.to change { SiteSetting.default_dark_mode_color_scheme_id }.to( - -1, - ) - end - end - end - - context "with homepage style" do - it "updates the fields correctly" do - SiteSetting.top_menu = "latest|categories|unread|top" - updater = - wizard.create_updater( - "styling", - body_font: "arial", - heading_font: "arial", - homepage_style: "categories_and_top_topics", - ) - updater.update - - expect(updater).to be_success - expect(wizard.completed_steps?("styling")).to eq(true) - expect(SiteSetting.top_menu).to eq("categories|latest|unread|top") - expect(SiteSetting.desktop_category_page_style).to eq("categories_and_top_topics") - - SiteSetting.top_menu = "categories|latest|new|top" - updater = - wizard.create_updater( - "styling", - body_font: "arial", - heading_font: "arial", - homepage_style: "latest", - ) - updater.update - expect(updater).to be_success - expect(SiteSetting.top_menu).to eq("latest|categories|new|top") - end - - it "updates style even when categories is first in top menu" do - SiteSetting.top_menu = "categories|new|latest" - updater = - wizard.create_updater( - "styling", - body_font: "arial", - heading_font: "arial", - homepage_style: "categories_with_featured_topics", - ) - updater.update - expect(updater).to be_success - expect(SiteSetting.desktop_category_page_style).to eq("categories_with_featured_topics") - - updater = - wizard.create_updater( - "styling", - body_font: "arial", - heading_font: "arial", - homepage_style: "subcategories_with_featured_topics", - ) - updater.update - expect(updater).to be_success - expect(SiteSetting.desktop_category_page_style).to eq("subcategories_with_featured_topics") - end - - it "updates top_menu if it doesn't match the new homepage_style and does nothing if it matches" do - SiteSetting.top_menu = "categories|new|latest" - - updater = - wizard.create_updater( - "styling", - body_font: "arial", - heading_font: "arial", - homepage_style: "hot", - ) - updater.update - expect(updater).to be_success - expect(SiteSetting.top_menu).to eq("hot|categories|new|latest") - - updater = - wizard.create_updater( - "styling", - body_font: "arial", - heading_font: "arial", - homepage_style: "hot", - ) - updater.update - expect(updater).to be_success - expect(SiteSetting.top_menu).to eq("hot|categories|new|latest") - - updater = - wizard.create_updater( - "styling", - body_font: "arial", - heading_font: "arial", - homepage_style: "latest", - ) - updater.update - expect(updater).to be_success - expect(SiteSetting.top_menu).to eq("latest|hot|categories|new") - end - - it "does not overwrite top_menu site setting" do - SiteSetting.top_menu = "latest|unread|unseen|categories" - updater = - wizard.create_updater( - "styling", - body_font: "arial", - heading_font: "arial", - homepage_style: "latest", - ) - updater.update - expect(updater).to be_success - expect(SiteSetting.top_menu).to eq("latest|unread|unseen|categories") - - SiteSetting.top_menu = "categories|new|latest" - updater = - wizard.create_updater( - "styling", - body_font: "arial", - heading_font: "arial", - homepage_style: "categories_and_top_topics", - ) - updater.update - expect(updater).to be_success - expect(SiteSetting.top_menu).to eq("categories|new|latest") - end - end - end - - describe "branding" do - it "updates the fields correctly" do - upload = Fabricate(:upload) - upload2 = Fabricate(:upload) - - updater = wizard.create_updater("branding", logo: upload.url, logo_small: upload2.url) - - updater.update - - expect(updater).to be_success - expect(wizard.completed_steps?("branding")).to eq(true) - expect(SiteSetting.logo).to eq(upload) - expect(SiteSetting.logo_small).to eq(upload2) - end - end end diff --git a/spec/lib/wizard/wizard_builder_spec.rb b/spec/lib/wizard/wizard_builder_spec.rb index 7d790bc3e43..9799a8e7391 100644 --- a/spec/lib/wizard/wizard_builder_spec.rb +++ b/spec/lib/wizard/wizard_builder_spec.rb @@ -89,89 +89,4 @@ RSpec.describe Wizard::Builder do expect(must_approve_users_field.value).to eq("yes") end end - - describe "styling" do - let(:styling_step) { wizard.steps.find { |s| s.id == "styling" } } - let(:font_field) { styling_step.fields.find { |f| f.id == "site_font" } } - fab!(:theme) - let(:colors_field) { styling_step.fields.first } - - before do - SiteSetting.remove_override!(:base_font) - SiteSetting.remove_override!(:heading_font) - end - - it "has the full list of available fonts in alphabetical order" do - expect(font_field.choices.map(&:label)).to eq( - ["Inter", "Lato", "Montserrat", "Open Sans", "Poppins", "Roboto"], - ) - end - - context "with colors" do - context "when the default theme has not been override" do - before { SiteSetting.find_by(name: "default_theme_id").destroy! } - - it "should set the right default values" do - expect(colors_field.required).to eq(true) - expect(colors_field.value).to eq(ColorScheme::LIGHT_THEME_ID) - end - end - - context "when the default theme has been override and the color scheme doesn't have a base scheme" do - let(:color_scheme) { Fabricate(:color_scheme, base_scheme_id: nil) } - - before do - SiteSetting.default_theme_id = theme.id - theme.update(color_scheme: color_scheme) - end - - it "fallbacks to the color scheme name" do - expect(colors_field.required).to eq(false) - expect(colors_field.value).to eq(color_scheme.name) - end - end - - context "when the default theme has been overridden by a theme without a color scheme" do - before { theme.set_default! } - - it "should set the right default values" do - expect(colors_field.required).to eq(false) - expect(colors_field.value).to eq("Light") - end - end - - context "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(colors_field.required).to eq(false) - expect(colors_field.value).to eq("Dark") - end - end - end - end - - describe "branding" do - let(:branding_step) { wizard.steps.find { |s| s.id == "branding" } } - - it "should set the right default value for the fields" do - upload = Fabricate(:upload) - upload2 = Fabricate(:upload) - - SiteSetting.logo = upload - SiteSetting.logo_small = upload2 - - fields = branding_step.fields - logo_field = fields.first - logo_small_field = fields.last - - expect(logo_field.id).to eq("logo") - expect(logo_field.value).to eq(GlobalPathInstance.full_cdn_url(upload.url)) - expect(logo_small_field.id).to eq("logo_small") - expect(logo_small_field.value).to eq(GlobalPathInstance.full_cdn_url(upload2.url)) - end - end end diff --git a/spec/system/page_objects/pages/wizard.rb b/spec/system/page_objects/pages/wizard.rb index 48e63a911cc..57521c56939 100644 --- a/spec/system/page_objects/pages/wizard.rb +++ b/spec/system/page_objects/pages/wizard.rb @@ -3,20 +3,12 @@ module PageObjects module Pages class Wizard < PageObjects::Pages::Base - attr_reader :introduction_step, - :privacy_step, - :ready_step, - :branding_step, - :styling_step, - :corporate_step + attr_reader :introduction_step, :privacy_step, :ready_step, :corporate_step def initialize @introduction_step = PageObjects::Pages::Wizard::IntroductionStep.new(self) @privacy_step = PageObjects::Pages::Wizard::PrivacyStep.new(self) @ready_step = PageObjects::Pages::Wizard::ReadyStep.new(self) - @branding_step = PageObjects::Pages::Wizard::BrandingStep.new(self) - @styling_step = PageObjects::Pages::Wizard::StylingStep.new(self) - @corporate_step = PageObjects::Pages::Wizard::CorporateStep.new(self) end def go_to_step(step_id) @@ -77,87 +69,3 @@ end class PageObjects::Pages::Wizard::ReadyStep < PageObjects::Pages::Wizard::StepBase end - -class PageObjects::Pages::Wizard::BrandingStep < PageObjects::Pages::Wizard::StepBase - def click_upload_button(field_id) - wizard.find_field("image", field_id).find(".wizard-container__button-upload").click - end - - def has_upload?(field_id) - wizard.find_field("image", field_id).has_css?(".wizard-container__button-upload.has-upload") - end - - def has_preview?(field_id) - wizard.find_field("image", field_id).has_css?(".wizard-container__preview") - end -end - -class PageObjects::Pages::Wizard::StylingStep < PageObjects::Pages::Wizard::StepBase - def select_color_palette_option(palette) - select_kit = - PageObjects::Components::SelectKit.new(".dropdown-color-scheme .wizard-container__dropdown") - select_kit.expand - select_kit.select_row_by_value(palette) - end - - def select_font_option(font) - select_kit = - PageObjects::Components::SelectKit.new(".dropdown-site-font .wizard-container__dropdown") - select_kit.expand - select_kit.select_row_by_value(font) - end - - def select_body_font_option(font) - select_kit = - PageObjects::Components::SelectKit.new(".dropdown-body-font .wizard-container__dropdown") - select_kit.expand - select_kit.select_row_by_value(font) - end - - def select_heading_font_option(font) - select_kit = - PageObjects::Components::SelectKit.new(".dropdown-heading-font .wizard-container__dropdown") - select_kit.expand - select_kit.select_row_by_value(font) - end - - def select_homepage_style_option(homepage) - select_kit = - PageObjects::Components::SelectKit.new(".dropdown-homepage-style .wizard-container__dropdown") - select_kit.expand - select_kit.select_row_by_value(homepage) - end - - def has_selected_color_palette?(palette) - select_kit = - PageObjects::Components::SelectKit.new(".dropdown-color-scheme .wizard-container__dropdown") - select_kit.has_selected_value?(palette) - end - - def has_selected_font?(font) - select_kit = - PageObjects::Components::SelectKit.new(".dropdown-site-font .wizard-container__dropdown") - select_kit.has_selected_value?(font) - end - - def has_selected_body_font?(font) - select_kit = - PageObjects::Components::SelectKit.new(".dropdown-body-font .wizard-container__dropdown") - select_kit.has_selected_value?(font) - end - - def has_selected_heading_font?(font) - select_kit = - PageObjects::Components::SelectKit.new(".dropdown-heading-font .wizard-container__dropdown") - select_kit.has_selected_value?(font) - end - - def has_selected_homepage_style?(hompage) - select_kit = - PageObjects::Components::SelectKit.new(".dropdown-homepage-style .wizard-container__dropdown") - select_kit.has_selected_value?(hompage) - end -end - -class PageObjects::Pages::Wizard::CorporateStep < PageObjects::Pages::Wizard::StepBase -end diff --git a/spec/system/wizard_spec.rb b/spec/system/wizard_spec.rb index 1f3ca0f16d1..bd4281574a2 100644 --- a/spec/system/wizard_spec.rb +++ b/spec/system/wizard_spec.rb @@ -14,10 +14,6 @@ describe "Wizard", type: :system do wizard_page.go_to_next_step expect(wizard_page).to be_on_step("privacy") wizard_page.go_to_next_step - expect(wizard_page).to be_on_step("styling") - wizard_page.go_to_next_step - expect(wizard_page).to be_on_step("branding") - wizard_page.go_to_next_step expect(wizard_page).to be_on_step("ready") wizard_page.click_jump_in expect(page).to have_current_path("/latest") @@ -40,7 +36,7 @@ describe "Wizard", type: :system do wizard_page.go_to_next_step - expect(wizard_page).to be_on_step("styling") + expect(wizard_page).to be_on_step("ready") expect(SiteSetting.login_required).to eq(true) expect(SiteSetting.invite_only).to eq(true) expect(SiteSetting.must_approve_users).to eq(true) @@ -53,77 +49,6 @@ describe "Wizard", type: :system do end end - describe "Wizard Step: Branding" do - let(:file_path_1) { file_from_fixtures("logo.png", "images").path } - let(:file_path_2) { file_from_fixtures("logo.jpg", "images").path } - - before do - SiteSetting.logo = nil - SiteSetting.logo_small = nil - end - - it "lets user configure logos" do - wizard_page.go_to_step("branding") - expect(wizard_page).to be_on_step("branding") - attach_file(file_path_1) { wizard_page.branding_step.click_upload_button("logo") } - expect(wizard_page.branding_step).to have_upload("logo") - expect(wizard_page.branding_step).to have_preview("logo") - attach_file(file_path_2) { wizard_page.branding_step.click_upload_button("logo-small") } - expect(wizard_page.branding_step).to have_upload("logo-small") - expect(wizard_page.branding_step).to have_preview("logo-small") - wizard_page.go_to_next_step - expect(wizard_page).to be_on_step("ready") - - expect(SiteSetting.logo).to eq(Upload.find_by(original_filename: File.basename(file_path_1))) - expect(SiteSetting.logo_small).to eq( - Upload.find_by(original_filename: File.basename(file_path_2)), - ) - end - end - - describe "Wizard Step: Styling" do - it "lets user configure styling including font and colors" do - wizard_page.go_to_step("styling") - expect(wizard_page).to be_on_step("styling") - - wizard_page.styling_step.select_color_palette_option("Dark") - wizard_page.styling_step.select_font_option("roboto") - wizard_page.styling_step.select_homepage_style_option("hot") - - wizard_page.go_to_next_step - expect(wizard_page).to be_on_step("branding") - - expect(Theme.find_default.color_scheme_id).to eq( - ColorScheme.find_by(base_scheme_id: "Dark", via_wizard: true).id, - ) - expect(SiteSetting.base_font).to eq("roboto") - expect(SiteSetting.heading_font).to eq("roboto") - expect(SiteSetting.homepage).to eq("hot") - - wizard_page.go_to_step("styling") - - expect(wizard_page.styling_step).to have_selected_color_palette("Dark") - expect(wizard_page.styling_step).to have_selected_font("roboto") - expect(wizard_page.styling_step).to have_selected_homepage_style("hot") - end - - it "lets user select separate body and heading font if they are already seperate" do - SiteSetting.base_font = "poppins" - SiteSetting.heading_font = "montserrat" - wizard_page.go_to_step("styling") - expect(wizard_page).to be_on_step("styling") - - wizard_page.styling_step.select_body_font_option("roboto") - wizard_page.styling_step.select_heading_font_option("inter") - - wizard_page.go_to_next_step - expect(wizard_page).to be_on_step("branding") - - expect(SiteSetting.base_font).to eq("roboto") - expect(SiteSetting.heading_font).to eq("inter") - end - end - describe "Wizard Step: Ready" do it "redirects to latest" do wizard_page.go_to_step("ready")