Joffrey JAFFEUX 187b59d376
UX: implements draft threads (#21361)
This commit implements all the necessary logic to create thread seamlessly. For this it relies on the same logic used for messages and generates a `staged-id`(using the format: `staged-thread-CHANNEL_ID-MESSAGE_ID` which is used to re-conciliate state client sides once the thread has been persisted on the backend.

Part of this change the client side is now always using real thread and channel objects instead of sometimes relying on a flat `threadId` or `channelId`.

This PR also brings three UX changes:
- thread starts from top
- number of buttons on message actions is dependent of the width of the enclosing container
- <kbd>shift + ArrowUp</kbd> will reply to the last message
2023-05-05 08:55:55 +02:00

78 lines
2.5 KiB
Ruby

# frozen_string_literal: true
RSpec.describe "Reply to message - smoke", type: :system, js: true do
let(:chat_page) { PageObjects::Pages::Chat.new }
let(:channel_page) { PageObjects::Pages::ChatChannel.new }
let(:thread_page) { PageObjects::Pages::ChatThread.new }
fab!(:user_1) { Fabricate(:user) }
fab!(:user_2) { Fabricate(:user) }
fab!(:channel_1) { Fabricate(:category_channel) }
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)
channel_1.update!(threading_enabled: true)
end
context "when two users create a thread on the same message" do
it "works" do
using_session(:user_1) do
sign_in(user_1)
chat_page.visit_channel(channel_1)
channel_page.reply_to(original_message)
end
using_session(:user_2) do
sign_in(user_2)
chat_page.visit_channel(channel_1)
channel_page.reply_to(original_message)
end
using_session(:user_1) do
thread_page.fill_composer("user1reply")
thread_page.click_send_message
expect(channel_page).to have_thread_indicator(original_message, text: 1)
expect(thread_page).to have_message(text: "user1reply")
end
using_session(:user_2) do |session|
expect(thread_page).to have_message(text: "user1reply")
expect(channel_page).to have_thread_indicator(original_message, text: 1)
thread_page.fill_composer("user2reply")
thread_page.click_send_message
expect(thread_page).to have_message(text: "user2reply")
expect(channel_page).to have_thread_indicator(original_message, text: 2)
refresh
expect(thread_page).to have_message(text: "user1reply")
expect(thread_page).to have_message(text: "user2reply")
expect(channel_page).to have_thread_indicator(original_message, text: 2)
session.quit
end
using_session(:user_1) do |session|
expect(thread_page).to have_message(text: "user2reply")
expect(channel_page).to have_thread_indicator(original_message, text: 2)
refresh
expect(thread_page).to have_message(text: "user1reply")
expect(thread_page).to have_message(text: "user2reply")
expect(channel_page).to have_thread_indicator(original_message, text: 2)
session.quit
end
end
end
end