DEV: Remove experimental site setting for chat threads (#22720)

We are removing the experimental site setting. Admins can now decide on a per channel basis to enable/disable threading. It's disabled by default.
This commit is contained in:
Jan Cernik 2023-07-26 07:46:23 -03:00 committed by GitHub
parent d06431ba9b
commit a2eb2b0490
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
67 changed files with 287 additions and 653 deletions

View File

@ -6,7 +6,6 @@ module Jobs
sidekiq_options queue: "critical"
def execute(args = {})
return if !SiteSetting.enable_experimental_chat_threaded_discussions
channel = ::Chat::Channel.find_by(id: args[:channel_id])
return if channel.blank?
channel.mark_all_threads_as_read

View File

@ -4,8 +4,6 @@ module Jobs
module Chat
class UpdateThreadReplyCount < Jobs::Base
def execute(args = {})
return if !SiteSetting.enable_experimental_chat_threaded_discussions
thread = ::Chat::Thread.find_by(id: args[:thread_id])
return if thread.blank?
return if thread.replies_count_cache_recently_updated?

View File

@ -188,9 +188,7 @@ module Chat
end
def mark_all_threads_as_read(user: nil)
if !(self.threading_enabled || SiteSetting.enable_experimental_chat_threaded_discussions)
return
end
return if !self.threading_enabled
DB.exec(<<~SQL, channel_id: self.id)
UPDATE user_chat_thread_memberships

View File

@ -108,7 +108,6 @@ module Chat
end
def self.ensure_consistency!
return if !SiteSetting.enable_experimental_chat_threaded_discussions
update_counts
end

View File

@ -25,10 +25,6 @@ module Chat
has_one :last_message, serializer: Chat::LastMessageSerializer, embed: :objects
def threading_enabled
SiteSetting.enable_experimental_chat_threaded_discussions && object.threading_enabled
end
def initialize(object, opts)
super(object, opts)

View File

@ -177,7 +177,7 @@ module Chat
end
def include_threading_data?
SiteSetting.enable_experimental_chat_threaded_discussions && channel.threading_enabled
channel.threading_enabled
end
def include_thread_id?

View File

@ -8,10 +8,6 @@ module Chat
object[:tracking]
end
def include_unread_thread_overview?
SiteSetting.enable_experimental_chat_threaded_discussions
end
def unread_thread_overview
object[:unread_thread_overview]
end

View File

@ -36,7 +36,7 @@ module Chat
end
def include_thread_data?
channel.threading_enabled && SiteSetting.enable_experimental_chat_threaded_discussions
channel.threading_enabled
end
def channel

View File

@ -112,8 +112,7 @@ module Chat
end
def determine_threads_enabled(channel:, **)
context.threads_enabled =
SiteSetting.enable_experimental_chat_threaded_discussions && channel.threading_enabled
context.threads_enabled = channel.threading_enabled
end
def determine_include_thread_messages(contract:, threads_enabled:, **)

View File

@ -24,7 +24,6 @@ module Chat
# @param [Integer] offset
# @return [Service::Base::Context]
policy :threaded_discussions_enabled
contract
step :set_limit
step :set_offset
@ -55,10 +54,6 @@ module Chat
context.offset = [contract.offset || 0, 0].max
end
def threaded_discussions_enabled
::SiteSetting.enable_experimental_chat_threaded_discussions
end
def fetch_channel(contract:, **)
::Chat::Channel.strict_loading.includes(:chatable).find_by(id: contract.channel_id)
end

View File

@ -2,10 +2,7 @@
module Chat
# Finds a thread within a channel. The thread_id and channel_id must
# match. For now we do not want to allow fetching threads if the
# enable_experimental_chat_threaded_discussions hidden site setting
# is not turned on, and the channel must specifically have threading
# enabled.
# match, and the channel must specifically have threading enabled.
#
# @example
# Chat::LookupThread.call(thread_id: 88, channel_id: 2, guardian: guardian)
@ -19,7 +16,6 @@ module Chat
# @param [Guardian] guardian
# @return [Service::Base::Context]
policy :threaded_discussions_enabled
contract
model :thread, :fetch_thread
policy :invalid_access
@ -37,10 +33,6 @@ module Chat
private
def threaded_discussions_enabled
SiteSetting.enable_experimental_chat_threaded_discussions
end
def fetch_thread(contract:, **)
Chat::Thread.includes(
:channel,

View File

@ -32,7 +32,7 @@ module Chat
end
def self.allow_publish_to_thread?(channel)
SiteSetting.enable_experimental_chat_threaded_discussions && channel.threading_enabled
channel.threading_enabled
end
def self.publish_new!(chat_channel, chat_message, staged_id, staged_thread_id: nil)
@ -161,8 +161,7 @@ module Chat
def self.publish_delete!(chat_channel, chat_message)
message_bus_targets = calculate_publish_targets(chat_channel, chat_message)
latest_not_deleted_message_id =
if chat_message.thread_reply? && chat_channel.threading_enabled &&
SiteSetting.enable_experimental_chat_threaded_discussions
if chat_message.thread_reply? && chat_channel.threading_enabled
chat_message.thread.latest_not_deleted_message_id(anchor_message_id: chat_message.id)
else
chat_channel.latest_not_deleted_message_id(anchor_message_id: chat_message.id)

View File

@ -34,7 +34,6 @@ module Chat
# @return [Service::Base::Context]
contract
policy :threaded_discussions_settings_ok
step :cast_thread_and_channel_ids_to_integer
model :report
@ -49,11 +48,6 @@ module Chat
private
def threaded_discussions_settings_ok(contract:, **)
return true if !contract.include_threads
SiteSetting.enable_experimental_chat_threaded_discussions
end
def cast_thread_and_channel_ids_to_integer(contract:, **)
contract.thread_ids = contract.thread_ids.map(&:to_i)
contract.channel_ids = contract.channel_ids.map(&:to_i)

View File

@ -2,10 +2,7 @@
module Chat
# Updates a thread. The thread_id and channel_id must
# match. For now we do not want to allow updating threads if the
# enable_experimental_chat_threaded_discussions hidden site setting
# is not turned on, and the channel must specifically have threading
# enabled.
# match, and the channel must specifically have threading enabled.
#
# Only the thread title can be updated.
#
@ -22,7 +19,6 @@ module Chat
# @option params_to_edit [String,nil] title
# @return [Service::Base::Context]
policy :threaded_discussions_enabled
contract
model :thread, :fetch_thread
policy :can_view_channel
@ -43,10 +39,6 @@ module Chat
private
def threaded_discussions_enabled
SiteSetting.enable_experimental_chat_threaded_discussions
end
def fetch_thread(contract:, **)
Chat::Thread.find_by(id: contract.thread_id, channel_id: contract.channel_id)
end

View File

@ -127,31 +127,29 @@
</div>
{{/if}}
{{#if this.togglingThreadingAvailable}}
<div class="chat-form__section -threading">
<div class="chat-form__field">
<label class="chat-form__label">
<span>{{i18n "chat.settings.channel_threading_label"}}</span>
<span class="channel-settings-view__channel-threading-tooltip">
{{d-icon "info-circle"}}
<DTooltip>
{{i18n "chat.settings.channel_threading_description"}}
</DTooltip>
</span>
<ChatChannelSettingsSavedIndicator
@property={{@channel.threadingEnabled}}
/>
</label>
<ComboBox
@content={{this.threadingEnabledOptions}}
@value={{@channel.threadingEnabled}}
@valueProperty="value"
@class="channel-settings-view__selector"
@onChange={{this.onToggleThreadingEnabled}}
<div class="chat-form__section -threading">
<div class="chat-form__field">
<label class="chat-form__label">
<span>{{i18n "chat.settings.channel_threading_label"}}</span>
<span class="channel-settings-view__channel-threading-tooltip">
{{d-icon "info-circle"}}
<DTooltip>
{{i18n "chat.settings.channel_threading_description"}}
</DTooltip>
</span>
<ChatChannelSettingsSavedIndicator
@property={{@channel.threadingEnabled}}
/>
</div>
</label>
<ComboBox
@content={{this.threadingEnabledOptions}}
@value={{@channel.threadingEnabled}}
@valueProperty="value"
@class="channel-settings-view__selector"
@onChange={{this.onToggleThreadingEnabled}}
/>
</div>
{{/if}}
</div>
{{/if}}
{{#unless @channel.isDirectMessageChannel}}

View File

@ -59,14 +59,6 @@ export default class ChatChannelSettingsView extends Component {
return this.args.channel.isCategoryChannel;
}
get togglingThreadingAvailable() {
return (
this.siteSettings.enable_experimental_chat_threaded_discussions &&
this.args.channel.isCategoryChannel &&
this.currentUser?.admin
);
}
get autoJoinAvailable() {
return (
this.siteSettings.max_chat_auto_joined_users > 0 &&

View File

@ -104,25 +104,23 @@
</div>
{{/if}}
{{#if this.threadingAvailable}}
<div class="chat-modal-create-channel__control -threading-toggle">
<label class="chat-modal-create-channel__label">
<Input
name="threading_enabled"
@type="checkbox"
@checked={{this.threadingEnabled}}
/>
<div class="threading-channel">
<span class="chat-modal-create-channel__label-title">
{{i18n "chat.create_channel.threading.label"}}
</span>
<p class="chat-modal-create-channel__label-description">
{{i18n "chat.settings.channel_threading_description"}}
</p>
</div>
</label>
</div>
{{/if}}
<div class="chat-modal-create-channel__control -threading-toggle">
<label class="chat-modal-create-channel__label">
<Input
name="threading_enabled"
@type="checkbox"
@checked={{this.threadingEnabled}}
/>
<div class="threading-channel">
<span class="chat-modal-create-channel__label-title">
{{i18n "chat.create_channel.threading.label"}}
</span>
<p class="chat-modal-create-channel__label-description">
{{i18n "chat.settings.channel_threading_description"}}
</p>
</div>
</label>
</div>
</:body>
<:footer>
<button

View File

@ -50,13 +50,6 @@ export default class ChatModalCreateChannel extends Component {
return isPresent(this.category);
}
get threadingAvailable() {
return (
this.siteSettings.enable_experimental_chat_threaded_discussions &&
this.categorySelected
);
}
get createDisabled() {
return !this.categorySelected || isBlank(this.name);
}

View File

@ -7,7 +7,6 @@ export default class ChatChannelComposer extends Service {
@service chat;
@service currentUser;
@service router;
@service siteSettings;
@service("chat-thread-composer") threadComposer;
@tracked message;
@ -53,10 +52,7 @@ export default class ChatChannelComposer extends Service {
async replyTo(message) {
this.chat.activeMessage = null;
if (
this.siteSettings.enable_experimental_chat_threaded_discussions &&
message.channel.threadingEnabled
) {
if (message.channel.threadingEnabled) {
if (!message.thread?.id) {
message.thread = message.channel.createStagedThread(message);
}

View File

@ -27,7 +27,6 @@ de:
max_mentions_per_chat_message: "Maximale Anzahl von @name-Benachrichtigungen, die ein Benutzer in einer Chat-Nachricht verwenden kann."
chat_max_direct_message_users: "Benutzer können nicht mehr als diese Anzahl anderer Benutzer hinzufügen, wenn sie eine neue Direktnachricht erstellen. Auf 0 setzen, um nur Nachrichten an sich selbst zuzulassen. Teammitglieder sind von dieser Einstellung ausgenommen."
chat_allow_archiving_channels: "Dem Team erlauben, Nachrichten zu einem Thema zu archivieren, wenn sie einen Kanal schließen."
enable_experimental_chat_threaded_discussions: "EXPERIMENTELL: Team-Mitgliedern erlauben, Threading in Chat-Kanälen zu aktivieren, damit parallele Diskussionen in einem Kanal stattfinden können, wenn Benutzer einander antworten."
errors:
chat_default_channel: "Der Standard-Chat-Kanal muss ein öffentlicher Kanal sein."
direct_message_enabled_groups_invalid: "Du musst mindestens eine Gruppe für diese Einstellung angeben. Wenn du nicht möchtest, dass andere Personen als Teammitglieder Direktnachrichten senden, wähle die Gruppe für Teammitglieder aus."

View File

@ -21,7 +21,6 @@ en:
max_mentions_per_chat_message: "Maximum number of @name notifications a user can use in a chat message."
chat_max_direct_message_users: "Users cannot add more than this number of other users when creating a new direct message. Set to 0 to only allow messages to oneself. Staff are exempt from this setting."
chat_allow_archiving_channels: "Allow staff to archive messages to a topic when closing a channel."
enable_experimental_chat_threaded_discussions: "EXPERIMENTAL: Allow staff to enable threading on chat channels, which allows for parallel discussions to occur in a channel when users reply to one another."
errors:
chat_default_channel: "The default chat channel must be a public channel."
direct_message_enabled_groups_invalid: "You must specify at least one group for this setting. If you do not want anyone except staff to send direct messages, choose the staff group."

View File

@ -27,7 +27,6 @@ he:
max_mentions_per_chat_message: "מספר התראות מרבי של @שם בהן יכול להשתמש משתמש בהודעת צ׳אט."
chat_max_direct_message_users: "משתמשים לא יכולים להוסיף יותר מכמות זו של משתמשים אחרים בעת יצירת הודעה ישירה חדשה. יש להגדיר ל־0 כדי לאפשר הודעות עצמיות. הסגל מוחרג מההגדרה הזאת."
chat_allow_archiving_channels: "לאפשר לסגל להעביר הודעות לארכיון בנושא בעת סגירת ערוץ."
enable_experimental_chat_threaded_discussions: "ניסיוני: לאפשר לצוות לאפשר שרשור על ערוצי צ׳אט, מה שמאפשר להתדיין במקביל בערוץ כאשר משתמשים מגיבים זה לזה."
errors:
chat_default_channel: "ערוץ הצ׳אט כברירת המחדל חייב להיות ערוץ ציבורי."
direct_message_enabled_groups_invalid: "יש לציין לפחות קבוצה אחת בהגדרה הזאת. כדי למנוע מכולם לשלוח הודעות ישירות למעט הסגל, יש לבחור בקבוצת הסגל."

View File

@ -27,7 +27,6 @@ it:
max_mentions_per_chat_message: "Numero massimo di notifiche @name che un utente può utilizzare in un messaggio di chat."
chat_max_direct_message_users: "Gli utenti non possono aggiungere più utenti di quelli indicati da questa opzione durante la creazione di un nuovo messaggio diretto. Impostare l'opzione a 0 per consentire solo i messaggi a se stessi. Questa impostazione non si applica allo staff."
chat_allow_archiving_channels: "Consenti allo staff di archiviare i messaggi in un argomento alla chiusura di un canale."
enable_experimental_chat_threaded_discussions: "SPERIMENTALE: Consenti al personale di attivare il threading sui canali di chat, che permette di avere discussioni parallele in un canale quando gli utenti rispondono l'uno all'altro."
errors:
chat_default_channel: "Il canale di chat predefinito deve essere un canale pubblico."
direct_message_enabled_groups_invalid: "Devi specificare almeno un gruppo per questa impostazione. Se non vuoi che nessuno al di fuori dello staff possa inviare messaggi diretti, scegli il gruppo dello staff."

View File

@ -26,7 +26,6 @@ pl_PL:
max_mentions_per_chat_message: "Maksymalna liczba powiadomień @name, których użytkownik może użyć w wiadomości na czacie."
chat_max_direct_message_users: "Użytkownicy nie mogą dodać więcej niż ta liczba innych użytkowników podczas tworzenia nowej wiadomości bezpośredniej. Ustaw na 0, aby zezwolić na wysyłanie wiadomości tylko do siebie. Personel jest zwolniony z tego ustawienia."
chat_allow_archiving_channels: "Zezwól personelowi na archiwizowanie wiadomości w temacie podczas zamykania kanału."
enable_experimental_chat_threaded_discussions: "EKSPERYMENTALNE: Zezwól personelowi na włączanie wątków na kanałach czatu, co pozwala na prowadzenie równoległych dyskusji na kanale, gdy użytkownicy odpowiadają sobie nawzajem."
errors:
chat_default_channel: "Domyślny kanał czatu musi być kanałem publicznym."
direct_message_enabled_groups_invalid: "Musisz określić co najmniej jedną grupę dla tego ustawienia. Jeśli nie chcesz, aby ktokolwiek poza personelem wysyłał bezpośrednie wiadomości, wybierz grupę pracowników."

View File

@ -27,7 +27,6 @@ sv:
max_mentions_per_chat_message: "Maximalt antal @namnomnämnanden en användare kan göra i ett chattmeddelande."
chat_max_direct_message_users: "Användare kan inte lägga till fler än detta antal andra användare när de skapar ett nytt direktmeddelande. Ställ in till 0 för att endast tillåta meddelanden till sig själv. Personalen är undantagen från denna inställning."
chat_allow_archiving_channels: "Tillåt att personalen arkiverar meddelanden till ett ämne när en kanal stängs."
enable_experimental_chat_threaded_discussions: "EXPERIMENTELLT: Tillåt att personalen aktiverar trådning på chattkanaler, vilket gör att parallella diskussioner kan uppstå i en kanal när användare svarar varandra."
errors:
chat_default_channel: "Standardchattkanalen måste vara en offentlig kanal."
direct_message_enabled_groups_invalid: "Du måste ange minst en grupp för den här inställningen. Om du inte vill att någon förutom personal ska skicka direktmeddelanden, välj personalgrupp."

View File

@ -116,6 +116,3 @@ chat:
max_chat_draft_length:
default: 50_000
hidden: true
enable_experimental_chat_threaded_discussions:
default: false
client: true

View File

@ -245,8 +245,7 @@ module Chat
channel_ids: channel_ids,
guardian: guardian,
include_missing_memberships: true,
include_threads:
SiteSetting.enable_experimental_chat_threaded_discussions && include_threads,
include_threads: include_threads,
).report
end

View File

@ -25,8 +25,7 @@
# into a new channel, they end up as just a flat series of messages that are
# not in a chain. If the original message of a thread and N other messages
# in that thread, then any messages left behind just get placed into a new
# thread. Message moving will be disabled in the thread UI while
# enable_experimental_chat_threaded_discussions is present, its too complicated
# thread. Message moving will be disabled in the thread UI, its too complicated
# to have end users reason about for now, and we may want a standalone
# "Move Thread" UI later on.
module Chat

View File

@ -13,10 +13,6 @@ module DiscourseDev
end
def data
if !SiteSetting.enable_experimental_chat_threaded_discussions
raise "You need to enable_experimental_chat_threaded_discussions to run this task"
end
channel = ::Chat::Channel.find(@channel_id)
return if !channel

View File

@ -238,15 +238,13 @@ after_initialize do
add_to_serializer(:current_user, :chat_channels) do
structured = Chat::ChannelFetcher.structured(self.scope)
if SiteSetting.enable_experimental_chat_threaded_discussions
structured[:unread_thread_overview] = ::Chat::TrackingStateReportQuery.call(
guardian: self.scope,
channel_ids: structured[:public_channels].map(&:id),
include_threads: true,
include_read: false,
include_last_reply_details: true,
).thread_unread_overview_by_channel
end
structured[:unread_thread_overview] = ::Chat::TrackingStateReportQuery.call(
guardian: self.scope,
channel_ids: structured[:public_channels].map(&:id),
include_threads: true,
include_read: false,
include_last_reply_details: true,
).thread_unread_overview_by_channel
Chat::ChannelIndexSerializer.new(structured, scope: self.scope, root: false).as_json
end

View File

@ -6,10 +6,7 @@ RSpec.describe "Chat::Thread replies_count cache accuracy" do
fab!(:user) { Fabricate(:user) }
fab!(:thread) { Fabricate(:chat_thread) }
before do
SiteSetting.chat_enabled = true
SiteSetting.enable_experimental_chat_threaded_discussions = true
end
before { SiteSetting.chat_enabled = true }
it "keeps an accurate replies_count cache" do
freeze_time

View File

@ -429,10 +429,7 @@ describe Jobs::Chat::NotifyMentioned do
end
context "when the mention is within a thread" do
before do
SiteSetting.enable_experimental_chat_threaded_discussions = true
public_channel.update!(threading_enabled: true)
end
before { public_channel.update!(threading_enabled: true) }
fab!(:thread) { Fabricate(:chat_thread, channel: public_channel) }

View File

@ -2,45 +2,32 @@
RSpec.describe Jobs::Chat::MarkAllChannelThreadsRead do
fab!(:channel) { Fabricate(:chat_channel, threading_enabled: true) }
fab!(:thread_1) { Fabricate(:chat_thread, channel: channel) }
fab!(:thread_2) { Fabricate(:chat_thread, channel: channel) }
fab!(:user_1) { Fabricate(:user) }
fab!(:user_2) { Fabricate(:user) }
fab!(:thread_1_message_1) { Fabricate(:chat_message, thread: thread_1) }
fab!(:thread_1_message_2) { Fabricate(:chat_message, thread: thread_1) }
fab!(:thread_1_message_3) { Fabricate(:chat_message, thread: thread_1) }
fab!(:thread_2_message_1) { Fabricate(:chat_message, thread: thread_2) }
fab!(:thread_2_message_2) { Fabricate(:chat_message, thread: thread_2) }
context "when enable_experimental_chat_threaded_discussions is false" do
before { SiteSetting.enable_experimental_chat_threaded_discussions = false }
it "does nothing" do
Chat::Channel.any_instance.expects(:mark_all_threads_as_read).never
described_class.new.execute(channel_id: channel.id)
end
before do
channel.add(user_1)
channel.add(user_2)
thread_1.add(user_1)
thread_2.add(user_2)
end
context "when enable_experimental_chat_threaded_discussions is true" do
fab!(:thread_1) { Fabricate(:chat_thread, channel: channel) }
fab!(:thread_2) { Fabricate(:chat_thread, channel: channel) }
fab!(:user_1) { Fabricate(:user) }
fab!(:user_2) { Fabricate(:user) }
fab!(:thread_1_message_1) { Fabricate(:chat_message, thread: thread_1) }
fab!(:thread_1_message_2) { Fabricate(:chat_message, thread: thread_1) }
fab!(:thread_1_message_3) { Fabricate(:chat_message, thread: thread_1) }
fab!(:thread_2_message_1) { Fabricate(:chat_message, thread: thread_2) }
fab!(:thread_2_message_2) { Fabricate(:chat_message, thread: thread_2) }
def unread_count(user)
Chat::ThreadUnreadsQuery.call(channel_ids: [channel.id], user_id: user.id).first.unread_count
end
before do
SiteSetting.enable_experimental_chat_threaded_discussions = true
channel.add(user_1)
channel.add(user_2)
thread_1.add(user_1)
thread_2.add(user_2)
end
def unread_count(user)
Chat::ThreadUnreadsQuery.call(channel_ids: [channel.id], user_id: user.id).first.unread_count
end
it "marks all threads as read across all users in the channel" do
expect(unread_count(user_1)).to eq(3)
expect(unread_count(user_2)).to eq(2)
described_class.new.execute(channel_id: channel.id)
expect(unread_count(user_1)).to eq(0)
expect(unread_count(user_2)).to eq(0)
end
it "marks all threads as read across all users in the channel" do
expect(unread_count(user_1)).to eq(3)
expect(unread_count(user_2)).to eq(2)
described_class.new.execute(channel_id: channel.id)
expect(unread_count(user_1)).to eq(0)
expect(unread_count(user_2)).to eq(0)
end
end

View File

@ -5,16 +5,7 @@ RSpec.describe Jobs::Chat::UpdateThreadReplyCount do
fab!(:message_1) { Fabricate(:chat_message, thread: thread) }
fab!(:message_2) { Fabricate(:chat_message, thread: thread) }
before do
Chat::Thread.clear_caches!(thread.id)
SiteSetting.enable_experimental_chat_threaded_discussions = true
end
it "does nothing if enable_experimental_chat_threaded_discussions is false" do
SiteSetting.enable_experimental_chat_threaded_discussions = false
Chat::Thread.any_instance.expects(:set_replies_count_cache).never
described_class.new.execute(thread_id: thread.id)
end
before { Chat::Thread.clear_caches!(thread.id) }
it "does not error if the thread is deleted" do
id = thread.id

View File

@ -1,10 +1,7 @@
# frozen_string_literal: true
RSpec.describe Chat::Thread do
before do
SiteSetting.chat_enabled = true
SiteSetting.enable_experimental_chat_threaded_discussions = true
end
before { SiteSetting.chat_enabled = true }
describe ".ensure_consistency!" do
fab!(:channel) { Fabricate(:category_channel) }
@ -65,12 +62,6 @@ RSpec.describe Chat::Thread do
Chat::Thread.expects(:clear_caches!).never
described_class.ensure_consistency!
end
it "does nothing if threads are disabled" do
SiteSetting.enable_experimental_chat_threaded_discussions = false
Chat::Thread.expects(:update_counts).never
described_class.ensure_consistency!
end
end
end

View File

@ -29,7 +29,6 @@ describe Chat::ThreadUnreadsQuery do
before do
SiteSetting.chat_enabled = true
SiteSetting.enable_experimental_chat_threaded_discussions = true
SiteSetting.chat_allowed_groups = Group::AUTO_GROUPS[:everyone]
channel_1.add(current_user)
channel_2.add(current_user)

View File

@ -9,7 +9,6 @@ RSpec.describe Chat::Api::ChannelThreadsController do
before do
SiteSetting.chat_enabled = true
SiteSetting.chat_allowed_groups = Group::AUTO_GROUPS[:everyone]
SiteSetting.enable_experimental_chat_threaded_discussions = true
Group.refresh_automatic_groups!
sign_in(current_user)
end
@ -62,15 +61,6 @@ RSpec.describe Chat::Api::ChannelThreadsController do
end
end
context "when enable_experimental_chat_threaded_discussions is disabled" do
before { SiteSetting.enable_experimental_chat_threaded_discussions = false }
it "returns 404" do
get "/chat/api/channels/#{thread.channel_id}/threads/#{thread.id}"
expect(response.status).to eq(404)
end
end
context "when user cannot access the channel" do
before do
thread.channel.update!(chatable: Fabricate(:private_category, group: Fabricate(:group)))
@ -175,15 +165,6 @@ RSpec.describe Chat::Api::ChannelThreadsController do
expect(response.status).to eq(404)
end
end
context "when enable_experimental_chat_threaded_discussions is disabled" do
before { SiteSetting.enable_experimental_chat_threaded_discussions = false }
it "returns 404" do
get "/chat/api/channels/#{public_channel.id}/threads"
expect(response.status).to eq(404)
end
end
end
describe "update" do
@ -247,14 +228,5 @@ RSpec.describe Chat::Api::ChannelThreadsController do
expect(response.status).to eq(404)
end
end
context "when enable_experimental_chat_threaded_discussions is disabled" do
before { SiteSetting.enable_experimental_chat_threaded_discussions = false }
it "returns 404" do
put "/chat/api/channels/#{thread.channel_id}/threads/#{thread.id}", params: params
expect(response.status).to eq(404)
end
end
end
end

View File

@ -906,8 +906,6 @@ RSpec.describe Chat::Api::ChannelsController do
end
describe "when updating threading_enabled" do
before { SiteSetting.enable_experimental_chat_threaded_discussions = true }
it "sets the new value" do
expect {
put "/chat/api/channels/#{channel.id}", params: { channel: { threading_enabled: true } }

View File

@ -233,20 +233,8 @@ describe Chat::MessageSerializer do
describe "threading data" do
before { message_1.update!(thread: Fabricate(:chat_thread, channel: chat_channel)) }
context "when enable_experimental_chat_threaded_discussions is disabled" do
before { SiteSetting.enable_experimental_chat_threaded_discussions = false }
it "does not include thread data" do
serialized = described_class.new(message_1, scope: guardian, root: nil).as_json
expect(serialized).not_to have_key(:thread_id)
end
end
context "when the channel has threading_enabled false" do
before do
SiteSetting.enable_experimental_chat_threaded_discussions = true
chat_channel.update!(threading_enabled: false)
end
before { chat_channel.update!(threading_enabled: false) }
it "does not include thread data" do
serialized = described_class.new(message_1, scope: guardian, root: nil).as_json
@ -254,11 +242,8 @@ describe Chat::MessageSerializer do
end
end
context "when the channel has threading_enabled true and enable_experimental_chat_threaded_discussions is true" do
before do
SiteSetting.enable_experimental_chat_threaded_discussions = true
chat_channel.update!(threading_enabled: true)
end
context "when the channel has threading_enabled true" do
before { chat_channel.update!(threading_enabled: true) }
it "does include thread data" do
serialized = described_class.new(message_1, scope: guardian, root: nil).as_json

View File

@ -112,11 +112,8 @@ RSpec.describe Chat::ChannelViewBuilder do
it { is_expected.to fail_a_contract }
end
context "when channel has threading_enabled and enable_experimental_chat_threaded_discussions is true" do
before do
channel.update!(threading_enabled: true)
SiteSetting.enable_experimental_chat_threaded_discussions = true
end
context "when channel has threading_enabled true" do
before { channel.update!(threading_enabled: true) }
it "threads_enabled is true" do
expect(result.threads_enabled).to eq(true)
@ -320,10 +317,7 @@ RSpec.describe Chat::ChannelViewBuilder do
end
context "when not including thread messages" do
before do
channel.update!(threading_enabled: true)
SiteSetting.enable_experimental_chat_threaded_discussions = true
end
before { channel.update!(threading_enabled: true) }
it "does not include the target message" do
expect(result.view.chat_messages).to eq(

View File

@ -15,16 +15,6 @@ RSpec.describe ::Chat::LookupChannelThreads do
let(:offset) { 0 }
let(:params) { { guardian: guardian, channel_id: channel_id, limit: limit, offset: offset } }
before { SiteSetting.enable_experimental_chat_threaded_discussions = true }
describe "policy - threaded_discussions_enabled" do
context "when disabled" do
before { SiteSetting.enable_experimental_chat_threaded_discussions = false }
it { is_expected.to fail_a_policy(:threaded_discussions_enabled) }
end
end
describe "step - set_limit" do
fab!(:channel_1) { Fabricate(:chat_channel) }
let(:channel_id) { channel_1.id }

View File

@ -18,54 +18,44 @@ RSpec.describe Chat::LookupThread do
let(:guardian) { Guardian.new(current_user) }
let(:params) { { guardian: guardian, thread_id: thread.id, channel_id: thread.channel_id } }
context "when enable_experimental_chat_threaded_discussions is disabled" do
before { SiteSetting.enable_experimental_chat_threaded_discussions = false }
context "when all steps pass" do
it "sets the service result as successful" do
expect(result).to be_a_success
end
it { is_expected.to fail_a_policy(:threaded_discussions_enabled) }
it "fetches the thread" do
expect(result.thread).to eq(thread)
end
end
context "when enable_experimental_chat_threaded_discussions is enabled" do
before { SiteSetting.enable_experimental_chat_threaded_discussions = true }
context "when params are not valid" do
before { params.delete(:thread_id) }
context "when all steps pass" do
it "sets the service result as successful" do
expect(result).to be_a_success
end
it { is_expected.to fail_a_contract }
end
it "fetches the thread" do
expect(result.thread).to eq(thread)
end
end
context "when thread is not found because the channel ID differs" do
before { params[:thread_id] = other_thread.id }
context "when params are not valid" do
before { params.delete(:thread_id) }
it { is_expected.to fail_to_find_a_model(:thread) }
end
it { is_expected.to fail_a_contract }
end
context "when thread is not found" do
before { thread.destroy! }
context "when thread is not found because the channel ID differs" do
before { params[:thread_id] = other_thread.id }
it { is_expected.to fail_to_find_a_model(:thread) }
end
it { is_expected.to fail_to_find_a_model(:thread) }
end
context "when user cannot see channel" do
before { thread.update!(channel: private_channel) }
context "when thread is not found" do
before { thread.destroy! }
it { is_expected.to fail_a_policy(:invalid_access) }
end
it { is_expected.to fail_to_find_a_model(:thread) }
end
context "when threading is not enabled for the channel" do
before { channel.update!(threading_enabled: false) }
context "when user cannot see channel" do
before { thread.update!(channel: private_channel) }
it { is_expected.to fail_a_policy(:invalid_access) }
end
context "when threading is not enabled for the channel" do
before { channel.update!(threading_enabled: false) }
it { is_expected.to fail_a_policy(:threading_enabled_for_channel) }
end
it { is_expected.to fail_a_policy(:threading_enabled_for_channel) }
end
end
end

View File

@ -32,7 +32,6 @@ describe Chat::Publisher do
context "when the message is in a thread and the channel has threading_enabled" do
before do
SiteSetting.enable_experimental_chat_threaded_discussions = true
thread = Fabricate(:chat_thread, channel: channel)
message_1.update!(thread: thread)
message_2.update!(thread: thread)
@ -130,48 +129,8 @@ describe Chat::Publisher do
end
describe ".calculate_publish_targets" do
context "when enable_experimental_chat_threaded_discussions is false" do
before { SiteSetting.enable_experimental_chat_threaded_discussions = false }
context "when the message is the original message of a thread" do
fab!(:thread) { Fabricate(:chat_thread, original_message: message_1, channel: channel) }
it "generates the correct targets" do
targets = described_class.calculate_publish_targets(channel, message_1)
expect(targets).to contain_exactly("/chat/#{channel.id}")
end
end
context "when the message is a thread reply" do
fab!(:thread) do
Fabricate(
:chat_thread,
original_message: Fabricate(:chat_message, chat_channel: channel),
channel: channel,
)
end
before { message_1.update!(thread: thread) }
it "generates the correct targets" do
targets = described_class.calculate_publish_targets(channel, message_1)
expect(targets).to contain_exactly("/chat/#{channel.id}")
end
end
context "when the message is not part of a thread" do
it "generates the correct targets" do
targets = described_class.calculate_publish_targets(channel, message_1)
expect(targets).to contain_exactly("/chat/#{channel.id}")
end
end
end
context "when threading_enabled is false for the channel" do
before do
SiteSetting.enable_experimental_chat_threaded_discussions = true
channel.update!(threading_enabled: false)
end
before { channel.update!(threading_enabled: false) }
context "when the message is the original message of a thread" do
fab!(:thread) { Fabricate(:chat_thread, original_message: message_1, channel: channel) }
@ -207,11 +166,8 @@ describe Chat::Publisher do
end
end
context "when enable_experimental_chat_threaded_discussions is true and threading_enabled is true for the channel" do
before do
channel.update!(threading_enabled: true)
SiteSetting.enable_experimental_chat_threaded_discussions = true
end
context "when threading_enabled is true for the channel" do
before { channel.update!(threading_enabled: true) }
context "when the message is the original message of a thread" do
fab!(:thread) { Fabricate(:chat_thread, original_message: message_1, channel: channel) }
@ -312,8 +268,8 @@ describe Chat::Publisher do
before { message_1.update!(thread: thread) }
context "if enable_experimental_chat_threaded_discussions is false" do
before { SiteSetting.enable_experimental_chat_threaded_discussions = false }
context "if threading_enabled is false for the channel" do
before { channel.update!(threading_enabled: false) }
it "publishes to the new_messages_message_bus_channel" do
messages =
@ -322,22 +278,6 @@ describe Chat::Publisher do
) { described_class.publish_new!(channel, message_1, staged_id) }
expect(messages).not_to be_empty
end
end
context "if enable_experimental_chat_threaded_discussions is true" do
before { SiteSetting.enable_experimental_chat_threaded_discussions = true }
context "if threading_enabled is false for the channel" do
before { channel.update!(threading_enabled: false) }
it "publishes to the new_messages_message_bus_channel" do
messages =
MessageBus.track_publish(
described_class.new_messages_message_bus_channel(channel.id),
) { described_class.publish_new!(channel, message_1, staged_id) }
expect(messages).not_to be_empty
end
end
context "if threading_enabled is true for the channel" do
before { channel.update!(threading_enabled: true) }

View File

@ -14,7 +14,7 @@ RSpec.describe ::Chat::TrackingState do
let(:guardian) { Guardian.new(current_user) }
let(:id_params) { { channel_ids: [channel_1.id], thread_ids: [thread_1.id] } }
let(:include_threads) { nil }
let(:include_threads) { true }
let(:include_missing_memberships) { nil }
let(:params) do
@ -24,128 +24,31 @@ RSpec.describe ::Chat::TrackingState do
)
end
context "when enable_experimental_chat_threaded_discussions is disabled" do
before { SiteSetting.enable_experimental_chat_threaded_discussions = false }
context "when include_threads is true" do
let(:include_threads) { true }
it { is_expected.to fail_a_policy(:threaded_discussions_settings_ok) }
end
context "when include_threads is false" do
let(:include_threads) { false }
it { is_expected.not_to fail_a_policy(:threaded_discussions_settings_ok) }
end
fab!(:channel_1_membership) do
Fabricate(:user_chat_channel_membership, chat_channel: channel_1, user: current_user)
end
fab!(:thread_1_membership) do
Fabricate(:user_chat_thread_membership, thread: thread_1, user: current_user)
end
fab!(:thread_2_membership) do
Fabricate(:user_chat_thread_membership, thread: thread_2, user: current_user)
end
context "when enable_experimental_chat_threaded_discussions is enabled" do
before { SiteSetting.enable_experimental_chat_threaded_discussions = true }
let(:include_threads) { true }
fab!(:channel_1_membership) do
Fabricate(:user_chat_channel_membership, chat_channel: channel_1, user: current_user)
end
fab!(:thread_1_membership) do
Fabricate(:user_chat_thread_membership, thread: thread_1, user: current_user)
end
fab!(:thread_2_membership) do
Fabricate(:user_chat_thread_membership, thread: thread_2, user: current_user)
end
context "when not including channels and threads where the user is not a member" do
context "when only channel_ids are provided" do
let(:id_params) { { channel_ids: [channel_1.id, channel_2.id] } }
it "gets the tracking state of the channels" do
generate_tracking_state
expect(result.report.channel_tracking).to eq(
channel_1.id => {
unread_count: 4, # 2 messages + 2 thread original messages
mention_count: 0,
},
)
end
it "gets the tracking state of the threads in the channels" do
generate_tracking_state
expect(result.report.thread_tracking).to eq(
thread_1.id => {
channel_id: channel_1.id,
unread_count: 1,
mention_count: 0,
},
thread_2.id => {
channel_id: channel_1.id,
unread_count: 2,
mention_count: 0,
},
)
end
context "when include_threads is false" do
let(:include_threads) { false }
it "only gets channel tracking state and no thread tracking state" do
generate_tracking_state
expect(result.report.thread_tracking).to eq({})
expect(result.report.channel_tracking).to eq(
channel_1.id => {
unread_count: 4, # 2 messages + 2 thread original messages
mention_count: 0,
},
)
end
end
end
context "when thread_ids and channel_ids are provided" do
let(:id_params) do
{ channel_ids: [channel_1.id, channel_2.id], thread_ids: [thread_2.id] }
end
it "gets the tracking state of the channels" do
generate_tracking_state
expect(result.report.channel_tracking).to eq(
channel_1.id => {
unread_count: 4, # 2 messages + 2 thread original messages
mention_count: 0,
},
)
end
it "only gets the tracking state of the specified threads in the channels" do
generate_tracking_state
expect(result.report.thread_tracking).to eq(
thread_2.id => {
channel_id: channel_1.id,
unread_count: 2,
mention_count: 0,
},
)
end
end
end
context "when including channels and threads where the user is not a member" do
context "when not including channels and threads where the user is not a member" do
context "when only channel_ids are provided" do
let(:id_params) { { channel_ids: [channel_1.id, channel_2.id] } }
let(:include_missing_memberships) { true }
let(:include_threads) { true }
it "gets the tracking state of all channels including the ones where the user is not a member" do
it "gets the tracking state of the channels" do
generate_tracking_state
expect(result.report.channel_tracking).to eq(
channel_1.id => {
unread_count: 4, # 2 messages + 2 thread original messages
mention_count: 0,
},
channel_2.id => {
unread_count: 0,
mention_count: 0,
},
)
end
it "gets the tracking state of all the threads in the channels including the ones where the user is not a member" do
it "gets the tracking state of the threads in the channels" do
generate_tracking_state
expect(result.report.thread_tracking).to eq(
thread_1.id => {
@ -158,18 +61,94 @@ RSpec.describe ::Chat::TrackingState do
unread_count: 2,
mention_count: 0,
},
thread_3.id => {
channel_id: channel_2.id,
unread_count: 0,
mention_count: 0,
},
thread_4.id => {
channel_id: channel_2.id,
unread_count: 0,
)
end
context "when include_threads is false" do
let(:include_threads) { false }
it "only gets channel tracking state and no thread tracking state" do
generate_tracking_state
expect(result.report.thread_tracking).to eq({})
expect(result.report.channel_tracking).to eq(
channel_1.id => {
unread_count: 4, # 2 messages + 2 thread original messages
mention_count: 0,
},
)
end
end
end
context "when thread_ids and channel_ids are provided" do
let(:id_params) { { channel_ids: [channel_1.id, channel_2.id], thread_ids: [thread_2.id] } }
it "gets the tracking state of the channels" do
generate_tracking_state
expect(result.report.channel_tracking).to eq(
channel_1.id => {
unread_count: 4, # 2 messages + 2 thread original messages
mention_count: 0,
},
)
end
it "only gets the tracking state of the specified threads in the channels" do
generate_tracking_state
expect(result.report.thread_tracking).to eq(
thread_2.id => {
channel_id: channel_1.id,
unread_count: 2,
mention_count: 0,
},
)
end
end
end
context "when including channels and threads where the user is not a member" do
let(:id_params) { { channel_ids: [channel_1.id, channel_2.id] } }
let(:include_missing_memberships) { true }
let(:include_threads) { true }
it "gets the tracking state of all channels including the ones where the user is not a member" do
generate_tracking_state
expect(result.report.channel_tracking).to eq(
channel_1.id => {
unread_count: 4, # 2 messages + 2 thread original messages
mention_count: 0,
},
channel_2.id => {
unread_count: 0,
mention_count: 0,
},
)
end
it "gets the tracking state of all the threads in the channels including the ones where the user is not a member" do
generate_tracking_state
expect(result.report.thread_tracking).to eq(
thread_1.id => {
channel_id: channel_1.id,
unread_count: 1,
mention_count: 0,
},
thread_2.id => {
channel_id: channel_1.id,
unread_count: 2,
mention_count: 0,
},
thread_3.id => {
channel_id: channel_2.id,
unread_count: 0,
mention_count: 0,
},
thread_4.id => {
channel_id: channel_2.id,
unread_count: 0,
mention_count: 0,
},
)
end
end
end

View File

@ -21,85 +21,75 @@ RSpec.describe Chat::UpdateThread do
{ guardian: guardian, thread_id: thread.id, channel_id: thread.channel_id, title: title }
end
context "when enable_experimental_chat_threaded_discussions is disabled" do
before { SiteSetting.enable_experimental_chat_threaded_discussions = false }
context "when all steps pass" do
it "sets the service result as successful" do
expect(result).to be_a_success
end
it { is_expected.to fail_a_policy(:threaded_discussions_enabled) }
it "updates the title of the thread" do
result
expect(thread.reload.title).to eq(title)
end
it "publishes a MessageBus message" do
message =
MessageBus
.track_publish(Chat::Publisher.root_message_bus_channel(thread.channel_id)) { result }
.first
expect(message.data["type"]).to eq("update_thread_original_message")
end
end
context "when enable_experimental_chat_threaded_discussions is enabled" do
before { SiteSetting.enable_experimental_chat_threaded_discussions = true }
context "when params are not valid" do
before { params.delete(:thread_id) }
context "when all steps pass" do
it "sets the service result as successful" do
expect(result).to be_a_success
end
it { is_expected.to fail_a_contract }
end
it "updates the title of the thread" do
result
expect(thread.reload.title).to eq(title)
end
context "when title is too long" do
let(:title) { "a" * Chat::Thread::MAX_TITLE_LENGTH + "a" }
it "publishes a MessageBus message" do
message =
MessageBus
.track_publish(Chat::Publisher.root_message_bus_channel(thread.channel_id)) { result }
.first
it { is_expected.to fail_a_contract }
end
expect(message.data["type"]).to eq("update_thread_original_message")
end
context "when thread is not found because the channel ID differs" do
before { params[:thread_id] = other_thread.id }
it { is_expected.to fail_to_find_a_model(:thread) }
end
context "when thread is not found" do
before { thread.destroy! }
it { is_expected.to fail_to_find_a_model(:thread) }
end
context "when user cannot see channel" do
before { thread.update!(channel: private_channel) }
it { is_expected.to fail_a_policy(:can_view_channel) }
end
context "when user is not the thread original message creator" do
before { thread.update!(original_message_user: Fabricate(:user)) }
it { is_expected.to fail_a_policy(:can_edit_thread) }
end
context "when user is not the thread original message creator but they are staff" do
before do
thread.original_message.update!(user: Fabricate(:user))
current_user.update!(admin: true)
end
context "when params are not valid" do
before { params.delete(:thread_id) }
it { is_expected.not_to fail_a_policy(:can_edit_thread) }
end
it { is_expected.to fail_a_contract }
end
context "when threading is not enabled for the channel" do
before { channel.update!(threading_enabled: false) }
context "when title is too long" do
let(:title) { "a" * Chat::Thread::MAX_TITLE_LENGTH + "a" }
it { is_expected.to fail_a_contract }
end
context "when thread is not found because the channel ID differs" do
before { params[:thread_id] = other_thread.id }
it { is_expected.to fail_to_find_a_model(:thread) }
end
context "when thread is not found" do
before { thread.destroy! }
it { is_expected.to fail_to_find_a_model(:thread) }
end
context "when user cannot see channel" do
before { thread.update!(channel: private_channel) }
it { is_expected.to fail_a_policy(:can_view_channel) }
end
context "when user is not the thread original message creator" do
before { thread.update!(original_message_user: Fabricate(:user)) }
it { is_expected.to fail_a_policy(:can_edit_thread) }
end
context "when user is not the thread original message creator but they are staff" do
before do
thread.original_message.update!(user: Fabricate(:user))
current_user.update!(admin: true)
end
it { is_expected.not_to fail_a_policy(:can_edit_thread) }
end
context "when threading is not enabled for the channel" do
before { channel.update!(threading_enabled: false) }
it { is_expected.to fail_a_policy(:threading_enabled_for_channel) }
end
it { is_expected.to fail_a_policy(:threading_enabled_for_channel) }
end
end
end

View File

@ -178,7 +178,6 @@ RSpec.describe "Channel - Info - Settings page", type: :system do
end
it "can enable threading" do
SiteSetting.enable_experimental_chat_threaded_discussions = true
chat_page.visit_channel_settings(channel_1)
expect {

View File

@ -15,25 +15,9 @@ describe "Channel thread message echoing", type: :system do
sign_in(current_user)
end
context "when enable_experimental_chat_threaded_discussions is disabled" do
fab!(:channel) { Fabricate(:chat_channel) }
before { SiteSetting.enable_experimental_chat_threaded_discussions = false }
it "echoes the thread messages into the main channel stream" do
thread = chat_thread_chain_bootstrap(channel: channel, users: [current_user, other_user])
chat_page.visit_channel(channel)
thread.chat_messages.each do |thread_message|
expect(channel_page).to have_css(channel_page.message_by_id_selector(thread_message.id))
end
end
end
context "when threading_enabled is false for the channel" do
fab!(:channel) { Fabricate(:chat_channel) }
before do
SiteSetting.enable_experimental_chat_threaded_discussions = true
channel.update!(threading_enabled: false)
end
before { channel.update!(threading_enabled: false) }
it "echoes the thread messages into the main channel stream" do
thread = chat_thread_chain_bootstrap(channel: channel, users: [current_user, other_user])
@ -44,16 +28,13 @@ describe "Channel thread message echoing", type: :system do
end
end
context "when enable_experimental_chat_threaded_discussions is true and threading is enabled for the channel" do
context "when threading is enabled for the channel" do
fab!(:channel) { Fabricate(:chat_channel) }
fab!(:thread) do
chat_thread_chain_bootstrap(channel: channel, users: [current_user, other_user])
end
before do
SiteSetting.enable_experimental_chat_threaded_discussions = true
channel.update!(threading_enabled: true)
end
before { channel.update!(threading_enabled: true) }
it "does not echo the thread messages except for the original message into the channel stream" do
chat_page.visit_channel(channel)

View File

@ -38,10 +38,7 @@ RSpec.describe "Chat | composer | channel", type: :system, js: true do
end
context "when threading is enabled" do
before do
SiteSetting.enable_experimental_chat_threaded_discussions = true
channel_1.update!(threading_enabled: true)
end
before { channel_1.update!(threading_enabled: true) }
it "replies in the thread" do
chat_page.visit_channel(channel_1)

View File

@ -54,10 +54,7 @@ RSpec.describe "Chat | composer | shortcuts | channel", type: :system do
)
end
before do
SiteSetting.enable_experimental_chat_threaded_discussions = true
channel_1.update!(threading_enabled: true)
end
before { channel_1.update!(threading_enabled: true) }
it "directs the shortcut to the focused composer" do
chat.visit_channel(channel_1)

View File

@ -11,7 +11,6 @@ RSpec.describe "Chat | composer | shortcuts | thread", type: :system do
let(:side_panel_page) { PageObjects::Pages::ChatSidePanel.new }
before do
SiteSetting.enable_experimental_chat_threaded_discussions = true
chat_system_bootstrap
channel_1.add(current_user)
sign_in(current_user)

View File

@ -13,7 +13,6 @@ RSpec.describe "Chat | composer | thread", type: :system, js: true do
let(:thread_page) { PageObjects::Pages::ChatThread.new }
before do
SiteSetting.enable_experimental_chat_threaded_discussions = true
chat_system_bootstrap
channel_1.add(current_user)
sign_in(current_user)

View File

@ -39,10 +39,7 @@ RSpec.describe "Chat message - channel", type: :system do
end
context "when the message is part of a thread" do
before do
SiteSetting.enable_experimental_chat_threaded_discussions = true
channel_1.update!(threading_enabled: true)
end
before { channel_1.update!(threading_enabled: true) }
fab!(:thread_1) do
chat_thread_chain_bootstrap(

View File

@ -18,7 +18,6 @@ RSpec.describe "Chat message - thread", type: :system do
channel_1.update!(threading_enabled: true)
channel_1.add(current_user)
channel_1.add(other_user)
SiteSetting.enable_experimental_chat_threaded_discussions = true
sign_in(current_user)
end

View File

@ -33,8 +33,6 @@ RSpec.describe "Create channel", type: :system do
end
it "shows threading toggle" do
SiteSetting.enable_experimental_chat_threaded_discussions = true
chat_page.visit_browse
chat_page.new_channel_button.click
channel_modal.select_category(category_1)

View File

@ -118,7 +118,6 @@ RSpec.describe "Deleted message", type: :system do
before do
channel_1.update!(threading_enabled: true)
SiteSetting.enable_experimental_chat_threaded_discussions = true
chat_system_user_bootstrap(user: other_user, channel: channel_1)
Chat::Thread.update_counts
end

View File

@ -15,23 +15,9 @@ describe "Thread indicator for chat messages", type: :system do
sign_in(current_user)
end
context "when enable_experimental_chat_threaded_discussions is disabled" do
fab!(:channel) { Fabricate(:chat_channel) }
before { SiteSetting.enable_experimental_chat_threaded_discussions = false }
it "shows no thread indicators in the channel" do
thread = chat_thread_chain_bootstrap(channel: channel, users: [current_user, other_user])
chat_page.visit_channel(channel)
expect(channel_page).to have_no_thread_indicator(thread.original_message)
end
end
context "when threading_enabled is false for the channel" do
fab!(:channel) { Fabricate(:chat_channel) }
before do
SiteSetting.enable_experimental_chat_threaded_discussions = true
channel.update!(threading_enabled: false)
end
before { channel.update!(threading_enabled: false) }
it "shows no thread inidcators in the channel" do
thread = chat_thread_chain_bootstrap(channel: channel, users: [current_user, other_user])
@ -40,7 +26,7 @@ describe "Thread indicator for chat messages", type: :system do
end
end
context "when enable_experimental_chat_threaded_discussions is true and threading is enabled for the channel" do
context "when threading is enabled for the channel" do
fab!(:channel) { Fabricate(:chat_channel) }
fab!(:thread_1) do
chat_thread_chain_bootstrap(channel: channel, users: [current_user, other_user])
@ -53,10 +39,7 @@ describe "Thread indicator for chat messages", type: :system do
)
end
before do
SiteSetting.enable_experimental_chat_threaded_discussions = true
channel.update!(threading_enabled: true)
end
before { channel.update!(threading_enabled: true) }
it "throws thread indicators on all original messages" do
chat_page.visit_channel(channel)

View File

@ -135,7 +135,6 @@ RSpec.describe "Navigation", type: :system do
fab!(:thread) { Fabricate(:chat_thread, channel: category_channel) }
before do
SiteSetting.enable_experimental_chat_threaded_discussions = true
category_channel.update!(threading_enabled: true)
Fabricate(:chat_message, thread: thread, chat_channel: thread.channel)
thread.add(current_user)

View File

@ -18,7 +18,6 @@ RSpec.describe "Reply to message - channel - drawer", type: :system do
end
before do
SiteSetting.enable_experimental_chat_threaded_discussions = true
chat_system_bootstrap
channel_1.update!(threading_enabled: true)
channel_1.add(current_user)

View File

@ -18,7 +18,6 @@ RSpec.describe "Reply to message - channel - full page", type: :system do
end
before do
SiteSetting.enable_experimental_chat_threaded_discussions = true
chat_system_bootstrap
channel_1.add(current_user)
sign_in(current_user)

View File

@ -18,7 +18,6 @@ RSpec.describe "Reply to message - channel - mobile", type: :system, mobile: tru
end
before do
SiteSetting.enable_experimental_chat_threaded_discussions = true
chat_system_bootstrap
channel_1.update!(threading_enabled: true)
channel_1.add(current_user)

View File

@ -11,7 +11,6 @@ RSpec.describe "Reply to message - smoke", type: :system do
fab!(:original_message) { Fabricate(:chat_message, chat_channel: channel_1) }
before do
SiteSetting.enable_experimental_chat_threaded_discussions = true
chat_system_bootstrap
channel_1.add(user_1)
channel_1.add(user_2)

View File

@ -10,7 +10,6 @@ RSpec.describe "Chat | Select message | thread", type: :system do
let(:thread_page) { PageObjects::Pages::ChatThread.new }
before do
SiteSetting.enable_experimental_chat_threaded_discussions = true
chat_system_bootstrap
channel_1.add(current_user)
sign_in(current_user)
@ -26,10 +25,7 @@ RSpec.describe "Chat | Select message | thread", type: :system do
Fabricate(:chat_message, chat_channel: channel_1, in_reply_to: original_message)
end
before do
SiteSetting.enable_experimental_chat_threaded_discussions = true
channel_1.update!(threading_enabled: true)
end
before { channel_1.update!(threading_enabled: true) }
it "can select multiple messages" do
chat_page.visit_thread(thread_message_1.thread)

View File

@ -15,25 +15,9 @@ describe "Single thread in side panel", type: :system do
sign_in(current_user)
end
context "when enable_experimental_chat_threaded_discussions is disabled" do
fab!(:channel) { Fabricate(:chat_channel) }
before { SiteSetting.enable_experimental_chat_threaded_discussions = false }
it "does not open the side panel for a single thread" do
thread =
chat_thread_chain_bootstrap(channel: channel, users: [current_user, Fabricate(:user)])
chat_page.visit_channel(channel)
channel_page.hover_message(thread.original_message)
expect(page).not_to have_css(".chat-message-thread-btn")
end
end
context "when threading_enabled is false for the channel" do
fab!(:channel) { Fabricate(:chat_channel) }
before do
SiteSetting.enable_experimental_chat_threaded_discussions = true
channel.update!(threading_enabled: false)
end
before { channel.update!(threading_enabled: false) }
it "does not open the side panel for a single thread" do
thread =
@ -44,13 +28,11 @@ describe "Single thread in side panel", type: :system do
end
end
context "when enable_experimental_chat_threaded_discussions is true and threading is enabled for the channel" do
context "when threading is enabled for the channel" do
fab!(:user_2) { Fabricate(:user) }
fab!(:channel) { Fabricate(:chat_channel, threading_enabled: true) }
fab!(:thread) { chat_thread_chain_bootstrap(channel: channel, users: [current_user, user_2]) }
before { SiteSetting.enable_experimental_chat_threaded_discussions = true }
context "when in full page" do
context "when switching channel" do
fab!(:channel_2) { Fabricate(:chat_channel, threading_enabled: true) }

View File

@ -13,7 +13,6 @@ describe "Thread list in side panel | drawer", type: :system do
let(:drawer_page) { PageObjects::Pages::ChatDrawer.new }
before do
SiteSetting.enable_experimental_chat_threaded_discussions = true
chat_system_bootstrap(current_user, [channel])
sign_in(current_user)
end

View File

@ -13,7 +13,6 @@ describe "Thread list in side panel | full page", type: :system do
let(:thread_list_page) { PageObjects::Components::Chat::ThreadList.new }
before do
SiteSetting.enable_experimental_chat_threaded_discussions = true
chat_system_bootstrap(current_user, [channel])
sign_in(current_user)
end

View File

@ -15,7 +15,6 @@ describe "Thread tracking state | drawer", type: :system do
let(:drawer_page) { PageObjects::Pages::ChatDrawer.new }
before do
SiteSetting.enable_experimental_chat_threaded_discussions = true
chat_system_bootstrap(current_user, [channel])
chat_system_user_bootstrap(user: other_user, channel: channel)
sign_in(current_user)

View File

@ -13,7 +13,6 @@ describe "Thread tracking state | full page", type: :system do
let(:sidebar_page) { PageObjects::Pages::Sidebar.new }
before do
SiteSetting.enable_experimental_chat_threaded_discussions = true
chat_system_bootstrap(current_user, [channel])
sign_in(current_user)
thread.add(current_user)