FEATURE: Chat and Sidebar are now on by default (#19406)

FEATURE: Chat and Sidebar are now on by default

- Set the sidebar site setting to be enabled by default
- Set the chat site setting to be enabled by default
- Updated existing specs that assumed the original default
- Use a migration to keep old defaults for existing sites
This commit is contained in:
Blake Erickson 2022-12-13 17:25:19 -07:00 committed by GitHub
parent aa3a9b6fea
commit 5c925f2db3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 66 additions and 3 deletions

View File

@ -25,6 +25,9 @@ acceptance("Enforce Second Factor", function (needs) {
});
});
});
needs.settings({
navigation_menu: "legacy",
});
test("as an admin", async function (assert) {
await visit("/u/eviltrout/preferences/second-factor");

View File

@ -14,6 +14,9 @@ acceptance(
needs.pretender((server, helper) => {
server.get("/review/count.json", () => helper.response({ count: 3 }));
});
needs.settings({
navigation_menu: "legacy",
});
test("As a staff member", async function (assert) {
updateCurrentUser({ moderator: true, admin: false });
@ -28,7 +31,10 @@ acceptance(
}
);
acceptance("Hamburger Menu accessibility", function () {
acceptance("Hamburger Menu accessibility", function (needs) {
needs.settings({
navigation_menu: "legacy",
});
test("Escape key closes hamburger menu", async function (assert) {
await visit("/");
await click("#toggle-hamburger-menu");

View File

@ -8,6 +8,9 @@ acceptance("Opengraph Tag Updater", function (needs) {
return helper.response({});
});
});
needs.settings({
navigation_menu: "legacy",
});
test("updates OG title and URL", async function (assert) {
await visit("/");

View File

@ -2060,7 +2060,7 @@ developer:
navigation:
navigation_menu:
client: true
default: "legacy"
default: "sidebar"
type: enum
enum: "NavigationMenuSiteSetting"
default_sidebar_categories:

View File

@ -0,0 +1,30 @@
# frozen_string_literal: true
class EnableSidebarAndChat < ActiveRecord::Migration[7.0]
def up
result = execute <<~SQL
SELECT created_at
FROM schema_migration_details
ORDER BY created_at
LIMIT 1
SQL
# keep sidebar legacy and chat disabled for for existing sites
if result.first['created_at'].to_datetime < 1.hour.ago
execute <<~SQL
INSERT INTO site_settings(name, data_type, value, created_at, updated_at)
VALUES('chat_enabled', 5, 'f', NOW(), NOW())
ON CONFLICT (name) DO NOTHING
SQL
execute <<~SQL
INSERT INTO site_settings(name, data_type, value, created_at, updated_at)
VALUES('navigation_menu', 7, 'legacy', NOW(), NOW())
ON CONFLICT (name) DO NOTHING
SQL
end
end
def down
raise ActiveRecord::IrreversibleMigration
end
end

View File

@ -1,6 +1,6 @@
chat:
chat_enabled:
default: false
default: true
client: true
chat_allowed_groups:
client: true

View File

@ -14,6 +14,8 @@ describe Jobs::EmailChatNotifications do
end
context "when chat is not enabled" do
before { SiteSetting.chat_enabled = false }
it "does nothing" do
Chat::ChatMailer.expects(:send_unread_mentions_summary).never

View File

@ -12,6 +12,7 @@ RSpec.describe "Navigation", type: :system, js: true do
before do
chat_system_bootstrap(user, [category_channel, category_channel_2])
sign_in(user)
SiteSetting.navigation_menu = "legacy"
end
context "when sidebar is enabled as the navigation menu" do

View File

@ -15,6 +15,7 @@ acceptance("Discourse Chat - Chat live pane", function (needs) {
});
needs.settings({
chat_enabled: true,
navigation_menu: "legacy",
});
needs.pretender((server, helper) => {
server.get("/chat/:chatChannelId/messages.json", () =>

View File

@ -37,6 +37,7 @@ acceptance(
});
needs.settings({
chat_enabled: true,
navigation_menu: "legacy",
});
let loadAllMessages = false;
@ -195,6 +196,7 @@ acceptance(
});
needs.settings({
chat_enabled: true,
navigation_menu: "legacy",
});
needs.pretender((server, helper) => {

View File

@ -61,6 +61,7 @@ acceptance(
needs.settings({
chat_enabled: true,
chat_allow_archiving_channels: true,
navigation_menu: "legacy",
});
needs.pretender((server, helper) => {

View File

@ -168,6 +168,7 @@ RSpec.describe Jobs::NotifyReviewable do
end
it "respects priority" do
SiteSetting.navigation_menu = "legacy"
SiteSetting.enable_category_group_moderation = true
Reviewable.set_priorities(medium: 2.0)
SiteSetting.reviewable_default_visibility = 'medium'

View File

@ -594,6 +594,7 @@ RSpec.describe TopicTrackingState do
end
it "includes tags when SiteSetting.navigation_menu is not legacy" do
SiteSetting.navigation_menu = "legacy"
report = TopicTrackingState.report(user)
expect(report.length).to eq(1)
row = report[0]
@ -608,6 +609,7 @@ RSpec.describe TopicTrackingState do
end
it "includes tags when TopicTrackingState.include_tags_in_report option is enabled" do
SiteSetting.navigation_menu = "legacy"
report = TopicTrackingState.report(user)
expect(report.length).to eq(1)
row = report[0]

View File

@ -9,6 +9,7 @@ RSpec.describe 'users' do
before do
SiteSetting.tagging_enabled = true
SiteSetting.navigation_menu = "legacy"
Jobs.run_immediately!
sign_in(admin)
end

View File

@ -4,6 +4,11 @@ RSpec.describe TopicTrackingStateSerializer do
fab!(:user) { Fabricate(:user) }
fab!(:post) { create_post }
before do
SiteSetting.navigation_menu = "legacy"
SiteSetting.chat_enabled = false if defined?(::Chat)
end
it 'serializes topic tracking state reports' do
report = TopicTrackingState.report(user)
serialized = described_class.new(report[0], scope: Guardian.new(user), root: false).as_json

View File

@ -13,6 +13,11 @@ RSpec.describe WebHookUserSerializer do
WebHookUserSerializer.new(user, scope: Guardian.new(admin), root: false)
end
before do
SiteSetting.navigation_menu = "legacy"
SiteSetting.chat_enabled = false if defined?(::Chat)
end
it "should include relevant user info" do
payload = serializer.as_json
expect(payload[:email]).to eq(user.email)