mirror of
https://github.com/discourse/discourse.git
synced 2026-08-17 16:35:03 -05:00
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:
@@ -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
|
||||
|
||||
@@ -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) }
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 } }
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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 }
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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) }
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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) }
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user