FEATURE: revamped wizard (#17477)

* FEATURE: revamped wizard

* UX: Wizard redesign (#17381)

* UX: Step 1-2

* swap out images

* UX: Finalize all steps

* UX: mobile

* UX: Fix test

* more test

* DEV: remove unneeded wizard components

* DEV: fix wizard tests

* DEV: update rails tests for new wizard

* Remove empty hbs files that were created because of rebase

* Fixes for rebase

* Fix wizard image link

* More rebase fixes

* Fix rails tests

* FIX: Update preview for new color schemes: (#17481)

* UX: make layout more responsive, update images

* fix typo

* DEV: move discourse logo svg to template only component

* DEV: formatting improvements

* Remove unneeded files

* Add tests for privacy step

* Fix banner image height for step "ready"

Co-authored-by: Jordan Vidrine <30537603+jordanvidrine@users.noreply.github.com>
Co-authored-by: awesomerobot <kris.aubuchon@discourse.org>
This commit is contained in:
Arpit Jalan
2022-07-27 06:53:01 +05:30
committed by GitHub
parent 021200167c
commit 10f200a5d3
53 changed files with 1088 additions and 2402 deletions

View File

@ -8,164 +8,63 @@ describe Wizard::StepUpdater do
fab!(:user) { Fabricate(:admin) }
let(:wizard) { Wizard::Builder.new(user).build }
context "locale" do
it "does not require refresh when the language stays the same" do
context "introduction" do
it "updates the introduction step" do
locale = SiteSettings::DefaultsProvider::DEFAULT_LOCALE
updater = wizard.create_updater('locale', default_locale: locale)
updater = wizard.create_updater('introduction',
title: 'new forum title',
site_description: 'neat place',
default_locale: locale,
contact_email: 'eviltrout@example.com')
updater.update
expect(updater.success?).to eq(true)
expect(SiteSetting.title).to eq("new forum title")
expect(SiteSetting.site_description).to eq("neat place")
expect(SiteSetting.contact_email).to eq("eviltrout@example.com")
expect(updater.refresh_required?).to eq(false)
expect(wizard.completed_steps?('locale')).to eq(true)
expect(wizard.completed_steps?('introduction')).to eq(true)
end
it "updates the locale and requires refresh when it does change" do
updater = wizard.create_updater('locale', default_locale: 'ru')
updater = wizard.create_updater('introduction', default_locale: 'ru')
updater.update
expect(SiteSetting.default_locale).to eq('ru')
expect(updater.refresh_required?).to eq(true)
expect(wizard.completed_steps?('locale')).to eq(true)
expect(wizard.completed_steps?('introduction')).to eq(true)
end
it "won't allow updates to the default value, when required" do
updater = wizard.create_updater('introduction', title: SiteSetting.title, site_description: 'neat place')
updater.update
expect(updater.success?).to eq(false)
end
end
it "updates the forum title step" do
updater = wizard.create_updater('forum_title', title: 'new forum title', site_description: 'neat place', short_site_description: 'best community')
updater.update
expect(updater.success?).to eq(true)
expect(SiteSetting.title).to eq("new forum title")
expect(SiteSetting.site_description).to eq("neat place")
expect(SiteSetting.short_site_description).to eq("best community")
expect(wizard.completed_steps?('forum-title')).to eq(true)
end
it "updates the introduction step" do
topic = Fabricate(:topic, title: "Welcome to Discourse")
welcome_post = Fabricate(:post, topic: topic, raw: "this will be the welcome topic post\n\ncool!")
updater = wizard.create_updater('introduction', welcome: "Welcome to my new awesome forum!")
updater.update
expect(updater.success?).to eq(true)
welcome_post.reload
expect(welcome_post.raw).to eq("Welcome to my new awesome forum!\n\ncool!")
expect(wizard.completed_steps?('introduction')).to eq(true)
end
it "won't allow updates to the default value, when required" do
updater = wizard.create_updater('forum_title', title: SiteSetting.title, site_description: 'neat place')
updater.update
expect(updater.success?).to eq(false)
end
context "privacy settings" do
context "privacy" do
it "updates to open correctly" do
updater = wizard.create_updater('privacy', privacy: 'open', privacy_options: 'open')
updater = wizard.create_updater('privacy', login_required: false, invite_only: false, must_approve_users: false)
updater.update
expect(updater.success?).to eq(true)
expect(SiteSetting.login_required?).to eq(false)
expect(SiteSetting.invite_only?).to eq(false)
expect(SiteSetting.must_approve_users?).to eq(false)
expect(wizard.completed_steps?('privacy')).to eq(true)
end
it "updates to private correctly" do
updater = wizard.create_updater('privacy', privacy: 'restricted', privacy_options: 'invite_only')
updater = wizard.create_updater('privacy', login_required: true, invite_only: true, must_approve_users: true)
updater.update
expect(updater.success?).to eq(true)
expect(SiteSetting.login_required?).to eq(true)
expect(SiteSetting.invite_only?).to eq(true)
expect(SiteSetting.must_approve_users?).to eq(true)
expect(wizard.completed_steps?('privacy')).to eq(true)
end
end
context "contact step" do
it "updates the fields correctly" do
p = Fabricate(:post, raw: '<contact_email> template')
SiteSetting.tos_topic_id = p.topic_id
updater = wizard.create_updater('contact',
contact_email: 'eviltrout@example.com',
contact_url: 'http://example.com/custom-contact-url',
site_contact: user.username)
updater.update
expect(updater).to be_success
expect(SiteSetting.contact_email).to eq("eviltrout@example.com")
expect(SiteSetting.contact_url).to eq("http://example.com/custom-contact-url")
expect(SiteSetting.site_contact_username).to eq(user.username)
# Should update the TOS topic
raw = Post.where(topic_id: SiteSetting.tos_topic_id, post_number: 1).pluck_first(:raw)
expect(raw).to eq("<eviltrout@example.com> template")
# Can update the TOS topic again
updater = wizard.create_updater('contact', contact_email: 'alice@example.com')
updater.update
raw = Post.where(topic_id: SiteSetting.tos_topic_id, post_number: 1).pluck_first(:raw)
expect(raw).to eq("<alice@example.com> template")
# Can update the TOS to nothing
updater = wizard.create_updater('contact', {})
updater.update
raw = Post.where(topic_id: SiteSetting.tos_topic_id, post_number: 1).pluck_first(:raw)
expect(raw).to eq("<contact_email> template")
expect(wizard.completed_steps?('contact')).to eq(true)
end
it "doesn't update when there are errors" do
updater = wizard.create_updater('contact',
contact_email: 'not-an-email',
site_contact_username: 'not-a-username')
updater.update
expect(updater).to_not be_success
expect(updater.errors).to be_present
expect(wizard.completed_steps?('contact')).to eq(false)
end
end
context "corporate step" do
it "updates the fields properly" do
p = Fabricate(:post, raw: 'company_name - governing_law - city_for_disputes template')
SiteSetting.tos_topic_id = p.topic_id
updater = wizard.create_updater('corporate',
company_name: 'ACME, Inc.',
governing_law: 'New Jersey law',
city_for_disputes: 'Fairfield, New Jersey')
updater.update
expect(updater).to be_success
expect(SiteSetting.company_name).to eq("ACME, Inc.")
expect(SiteSetting.governing_law).to eq("New Jersey law")
expect(SiteSetting.city_for_disputes).to eq("Fairfield, New Jersey")
# Should update the TOS topic
raw = Post.where(topic_id: SiteSetting.tos_topic_id, post_number: 1).pluck_first(:raw)
expect(raw).to eq("ACME, Inc. - New Jersey law - Fairfield, New Jersey template")
# Can update the TOS topic again
updater = wizard.create_updater('corporate',
company_name: 'Pied Piper Inc',
governing_law: 'California law',
city_for_disputes: 'San Francisco, California')
updater.update
raw = Post.where(topic_id: SiteSetting.tos_topic_id, post_number: 1).pluck_first(:raw)
expect(raw).to eq("Pied Piper Inc - California law - San Francisco, California template")
# Can update the TOS to nothing
updater = wizard.create_updater('corporate', {})
updater.update
raw = Post.where(topic_id: SiteSetting.tos_topic_id, post_number: 1).pluck_first(:raw)
expect(raw).to eq("company_name - governing_law - city_for_disputes template")
expect(wizard.completed_steps?('corporate')).to eq(true)
end
end
context "styling step" do
context "styling" do
it "updates fonts" do
updater = wizard.create_updater('styling',
body_font: 'open_sans',
@ -340,16 +239,15 @@ describe Wizard::StepUpdater do
expect(SiteSetting.top_menu).to eq('latest|new|unread|top|categories')
end
end
end
context "logos step" do
context "branding" do
it "updates the fields correctly" do
upload = Fabricate(:upload)
upload2 = Fabricate(:upload)
updater = wizard.create_updater(
'logos',
'branding',
logo: upload.url,
logo_small: upload2.url
)
@ -357,52 +255,49 @@ describe Wizard::StepUpdater do
updater.update
expect(updater).to be_success
expect(wizard.completed_steps?('logos')).to eq(true)
expect(wizard.completed_steps?('branding')).to eq(true)
expect(SiteSetting.logo).to eq(upload)
expect(SiteSetting.logo_small).to eq(upload2)
end
end
context "icons step" do
it "updates the fields correctly" do
upload = Fabricate(:upload)
upload2 = Fabricate(:upload)
updater = wizard.create_updater('icons',
favicon: upload.url,
large_icon: upload2.url
)
context "corporate" do
it "updates the fields properly" do
p = Fabricate(:post, raw: 'company_name - governing_law - city_for_disputes template')
SiteSetting.tos_topic_id = p.topic_id
updater = wizard.create_updater('corporate',
company_name: 'ACME, Inc.',
governing_law: 'New Jersey law',
contact_url: 'http://example.com/custom-contact-url',
city_for_disputes: 'Fairfield, New Jersey')
updater.update
expect(updater).to be_success
expect(wizard.completed_steps?('icons')).to eq(true)
expect(SiteSetting.favicon).to eq(upload)
expect(SiteSetting.large_icon).to eq(upload2)
expect(SiteSetting.company_name).to eq("ACME, Inc.")
expect(SiteSetting.governing_law).to eq("New Jersey law")
expect(SiteSetting.contact_url).to eq("http://example.com/custom-contact-url")
expect(SiteSetting.city_for_disputes).to eq("Fairfield, New Jersey")
# Should update the TOS topic
raw = Post.where(topic_id: SiteSetting.tos_topic_id, post_number: 1).pluck_first(:raw)
expect(raw).to eq("ACME, Inc. - New Jersey law - Fairfield, New Jersey template")
# Can update the TOS topic again
updater = wizard.create_updater('corporate',
company_name: 'Pied Piper Inc',
governing_law: 'California law',
city_for_disputes: 'San Francisco, California')
updater.update
raw = Post.where(topic_id: SiteSetting.tos_topic_id, post_number: 1).pluck_first(:raw)
expect(raw).to eq("Pied Piper Inc - California law - San Francisco, California template")
# Can update the TOS to nothing
updater = wizard.create_updater('corporate', {})
updater.update
raw = Post.where(topic_id: SiteSetting.tos_topic_id, post_number: 1).pluck_first(:raw)
expect(raw).to eq("company_name - governing_law - city_for_disputes template")
expect(wizard.completed_steps?('corporate')).to eq(true)
end
end
context "invites step" do
let(:invites) {
return [{ email: 'regular@example.com', role: 'regular' },
{ email: 'moderator@example.com', role: 'moderator' }]
}
it "updates the fields correctly" do
updater = wizard.create_updater('invites', invite_list: invites.to_json)
updater.update
expect(updater).to be_success
expect(wizard.completed_steps?('invites')).to eq(true)
reg_invite = Invite.where(email: 'regular@example.com').first
expect(reg_invite).to be_present
expect(reg_invite.moderator?).to eq(false)
mod_invite = Invite.where(email: 'moderator@example.com').first
expect(mod_invite).to be_present
expect(mod_invite.moderator?).to eq(true)
end
end
end