mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 07:11:34 +08:00
FIX: allows selection of messages in threads (#22119)
This commit fixes the selection of message in threads and also applies various refactorings - improves specs and especially page objects/components - makes the channel/thread panes responsible of the state - adds an animationend modifier - continues to follow the logic of "state" should be displayed as data attributes on component by having a new `data-selected` attribute on chat messages
This commit is contained in:
@ -7,7 +7,7 @@ RSpec.describe "Quoting chat message transcripts", type: :system do
|
||||
|
||||
let(:cdp) { PageObjects::CDP.new }
|
||||
let(:chat_page) { PageObjects::Pages::Chat.new }
|
||||
let(:chat_channel_page) { PageObjects::Pages::ChatChannel.new }
|
||||
let(:channel_page) { PageObjects::Pages::ChatChannel.new }
|
||||
let(:topic_page) { PageObjects::Pages::Topic.new }
|
||||
|
||||
before do
|
||||
@ -16,38 +16,11 @@ RSpec.describe "Quoting chat message transcripts", type: :system do
|
||||
sign_in(current_user)
|
||||
end
|
||||
|
||||
def select_message_desktop(message)
|
||||
if page.has_css?(".chat-message-container.selecting-messages", wait: 0)
|
||||
chat_channel_page.message_by_id(message.id).find(".chat-message-selector").click
|
||||
else
|
||||
chat_channel_page.message_by_id(message.id).hover
|
||||
expect(page).to have_css(".chat-message-actions .more-buttons")
|
||||
find(".chat-message-actions .more-buttons").click
|
||||
find(".select-kit-row[data-value=\"select\"]").click
|
||||
end
|
||||
end
|
||||
|
||||
def click_selection_button(button)
|
||||
selector =
|
||||
case button
|
||||
when "quote"
|
||||
"chat-quote-btn"
|
||||
when "copy"
|
||||
"chat-copy-btn"
|
||||
when "cancel"
|
||||
"chat-cancel-selection-btn"
|
||||
when "move"
|
||||
"chat-move-to-channel-btn"
|
||||
end
|
||||
find_button(selector, disabled: false, wait: 5).click
|
||||
end
|
||||
|
||||
def copy_messages_to_clipboard(messages)
|
||||
messages = Array.wrap(messages)
|
||||
messages.each { |message| select_message_desktop(message) }
|
||||
expect(chat_channel_page).to have_selection_management
|
||||
click_selection_button("copy")
|
||||
expect(page).to have_selector(".chat-copy-success")
|
||||
messages.each { |message| channel_page.messages.select(message) }
|
||||
channel_page.selection_management.copy
|
||||
expect(page).to have_selector(".chat-selection-management__copy-success")
|
||||
clip_text = cdp.read_clipboard
|
||||
expect(clip_text.chomp).to eq(generate_transcript(messages, current_user))
|
||||
clip_text
|
||||
@ -140,8 +113,8 @@ RSpec.describe "Quoting chat message transcripts", type: :system do
|
||||
chat_page.visit_channel(chat_channel_1)
|
||||
|
||||
clip_text = copy_messages_to_clipboard(message_1)
|
||||
click_selection_button("cancel")
|
||||
chat_channel_page.send_message(clip_text)
|
||||
channel_page.selection_management.cancel
|
||||
channel_page.send_message(clip_text)
|
||||
|
||||
expect(page).to have_selector(".chat-message", count: 2)
|
||||
expect(page).to have_css(".chat-transcript")
|
||||
@ -155,9 +128,8 @@ RSpec.describe "Quoting chat message transcripts", type: :system do
|
||||
|
||||
it "opens the topic composer with correct state" do
|
||||
chat_page.visit_channel(chat_channel_1)
|
||||
|
||||
select_message_desktop(message_1)
|
||||
click_selection_button("quote")
|
||||
channel_page.messages.select(message_1)
|
||||
channel_page.selection_management.quote
|
||||
|
||||
expect(topic_page).to have_expanded_composer
|
||||
expect(topic_page).to have_composer_content(generate_transcript(message_1, current_user))
|
||||
@ -181,8 +153,8 @@ RSpec.describe "Quoting chat message transcripts", type: :system do
|
||||
it "first navigates to the channel's category before opening the topic composer with the quote prefilled",
|
||||
mobile: true do
|
||||
chat_page.visit_channel(chat_channel_1)
|
||||
chat_channel_page.select_message(message_1)
|
||||
click_selection_button("quote")
|
||||
channel_page.messages.select(message_1)
|
||||
channel_page.selection_management.quote
|
||||
|
||||
expect(topic_page).to have_expanded_composer
|
||||
expect(topic_page).to have_composer_content(generate_transcript(message_1, current_user))
|
||||
|
Reference in New Issue
Block a user