DEV: Add system spec for styling step

This commit is contained in:
Martin Brennan 2024-12-09 17:09:17 +10:00
parent 70eec69090
commit ab11cb92ea
No known key found for this signature in database
GPG Key ID: BD981EFEEC8F5675
5 changed files with 87 additions and 3 deletions

View File

@ -1,4 +1,4 @@
import { click, render } from "@ember/test-helpers";
import { render } from "@ember/test-helpers";
import { module, test } from "qunit";
import Dropdown from "discourse/static/wizard/components/fields/dropdown";
import { Choice, Field } from "discourse/static/wizard/models/wizard";

View File

@ -372,6 +372,10 @@ class Theme < ActiveRecord::Base
end
end
def self.find_default
find_by(id: SiteSetting.default_theme_id)
end
def self.lookup_field(theme_id, target, field, skip_transformation: false, csp_nonce: nil)
return "" if theme_id.blank?

View File

@ -137,7 +137,7 @@ class Wizard
def append_styling_step
@wizard.append_step("styling") do |step|
step.emoji = "art"
default_theme = Theme.find_by(id: SiteSetting.default_theme_id)
default_theme = Theme.find_default
default_theme_override = SiteSetting.exists?(name: "default_theme_id")
base_scheme = default_theme&.color_scheme&.base_scheme_id

View File

@ -82,6 +82,57 @@ class PageObjects::Pages::Wizard::BrandingStep < PageObjects::Pages::Wizard::Ste
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_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_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

View File

@ -66,10 +66,32 @@ describe "Wizard", type: :system do
it "lets user configure styling including fonts 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_body_font_option("lato")
wizard_page.styling_step.select_heading_font_option("merriweather")
wizard_page.styling_step.select_homepage_style_option("categories_only")
wizard_page.go_to_next_step
expect(wizard_page).to be_on_step("ready")
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("lato")
expect(SiteSetting.heading_font).to eq("merriweather")
expect(SiteSetting.homepage).to eq("categories")
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_body_font("lato")
expect(wizard_page.styling_step).to have_selected_heading_font("merriweather")
expect(wizard_page.styling_step).to have_selected_homepage_style("categories_only")
end
end
context "when wizard is completed" do
describe "Wizard Step: Ready" do
it "redirects to latest" do
wizard_page.go_to_step("ready")
wizard_page.click_jump_in
@ -88,4 +110,11 @@ describe "Wizard", type: :system do
expect(page).to have_current_path(topic.url)
end
end
describe "Wizard Step: Corporate" do
it "lets user configure corporate including governing law and city for disputes" do
wizard_page.go_to_step("corporate")
expect(wizard_page).to be_on_step("corporate")
end
end
end