Martin Brennan 78a857931c
FEATURE: Improve wizard font selection and set Inter as default font for new sites (#30974)
This commit narrows down the list of fonts we offer
in our setup wizard and simplifies things to only
show a single font dropdown. This selection will then
set the `base_font` and `heading_font` site setting to
the same value.

For existing sites that may have set different values,
we will still show 2 dropdowns when visiting the wizard.

We are also changing our default font to the more modern
selection Inter, replacing Arial. Arial is very dependent
on system installed fonts, whereas Inter we can package
to everyone in Discourse.

Finally, for existing sites that have not changed their default
from Arial, we will keep that value via a migration so we do
not surprise site owners with a completely new font.
2025-01-27 11:29:55 +10:00

164 lines
5.1 KiB
Ruby

# frozen_string_literal: true
module PageObjects
module Pages
class Wizard < PageObjects::Pages::Base
attr_reader :introduction_step,
:privacy_step,
:ready_step,
:branding_step,
:styling_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)
visit("/wizard/steps/#{step_id}")
end
def on_step?(step_id)
has_css?(".wizard-container__step.#{step_id}")
end
def click_jump_in
find(".wizard-container__button.jump-in").click
end
def click_configure_more
find(".wizard-container__button.configure-more").click
end
def go_to_next_step
find(".wizard-container__button.next").click
end
def find_field(field_type, field_id)
find(".wizard-container__field.#{field_type}-field.#{field_type}-#{field_id}")
end
def fill_field(field_type, field_id, value)
find_field(field_type, field_id).fill_in(with: value)
end
def has_field_with_value?(field_type, field_id, value)
find_field(field_type, field_id).find("input").value == value
end
end
end
end
class PageObjects::Pages::Wizard::StepBase < PageObjects::Pages::Base
attr_reader :wizard
def initialize(wizard)
@wizard = wizard
end
end
class PageObjects::Pages::Wizard::IntroductionStep < PageObjects::Pages::Wizard::StepBase
end
class PageObjects::Pages::Wizard::PrivacyStep < PageObjects::Pages::Wizard::StepBase
def choice_selector(choice_id)
".wizard-container__radio-choice[data-choice-id='#{choice_id}']"
end
def select_access_option(section, choice_id)
wizard.find_field("radio", section).find(choice_selector(choice_id)).click
end
def has_selected_choice?(section, choice_id)
wizard.find_field("radio", section).has_css?(choice_selector(choice_id) + ".--selected")
end
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
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