0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-06 13:08:40 +08:00
discourse/plugins/chat/spec/system/send_message_spec.rb
David Taylor 9527868295
DEV: Replace JS build system with Rolldown (#35963)
This replaces the old ember-cli build with a modern Rolldown build. In
local testing, this provides an 80% improvement in build times, while
remaining 100% backwards compatible for themes and plugins.

As part of this move, we have decided to stop using a proxy in front of
Discourse for development. Development should now be done directly
against the Rails server.

`bin/ember-cli -u` has been replaced with `bin/dev`. This will launch
Rails on `:3000`, and will run the rolldown build in the background. Log
output from both processes will be shown with an appropriate prefix. You
should visit `:3000` in your browser. `:4200` will no longer serve
anything.

To help with migration, `bin/ember-cli` is now a backwards-compatible
shim. It will print help information, and will launch a lightweight
server on `:4200` with instructions to move to `:3000`.

If you prefer to launch Rails and the JS build as separate commands, you
can still do that. Rails boot commands are unchanged, and the rolldown
development builder can be run using `bin/dev --only ember`.

https://meta.discourse.org/t/403908

---------

Co-authored-by: Jarek Radosz <jarek@cvx.dev>
Co-authored-by: Chris Manson <chris@manson.ie>
2026-05-29 11:11:55 +01:00

128 lines
3.6 KiB
Ruby
Vendored

# frozen_string_literal: true
RSpec.describe "Send message" do
fab!(:user_1, :admin)
fab!(:user_2, :admin)
let(:chat_page) { PageObjects::Pages::Chat.new }
let(:channel_page) { PageObjects::Pages::ChatChannel.new }
before do
# simpler user search without having to worry about user search data
SiteSetting.enable_names = false
chat_system_bootstrap
end
context "with direct message channels" do
context "when users are not following the channel" do
fab!(:channel_1) { Fabricate(:direct_message_channel, users: [user_1, user_2]) }
before do
channel_1.remove(user_1)
channel_1.remove(user_2)
end
it "shows correct state" do
sign_in(user_1)
visit("/")
expect(chat_page.sidebar).to have_no_direct_message_channel(channel_1)
using_session(:user_2) do
sign_in(user_2)
visit("/")
expect(chat_page.sidebar).to have_no_direct_message_channel(channel_1)
end
chat_page.open_new_message
chat_page.message_creator.filter(user_2.username)
chat_page.message_creator.click_row(user_2)
expect(chat_page.sidebar).to have_direct_message_channel(channel_1)
using_session(:user_2) do
expect(chat_page.sidebar).to have_no_direct_message_channel(channel_1)
end
channel_page.send_message
expect(chat_page.sidebar).to have_direct_message_channel(channel_1)
using_session(:user_2) do
expect(chat_page.sidebar).to have_direct_message_channel(channel_1, mention: true)
end
end
end
context "when users are following the channel" do
fab!(:channel_1) { Fabricate(:direct_message_channel, users: [user_1, user_2]) }
it "shows correct state" do
sign_in(user_1)
visit("/")
expect(chat_page.sidebar).to have_direct_message_channel(channel_1)
using_session(:user_2) do
sign_in(user_2)
visit("/")
expect(chat_page.sidebar).to have_direct_message_channel(channel_1)
end
chat_page.open_new_message
chat_page.message_creator.filter(user_2.username)
chat_page.message_creator.click_row(user_2)
expect(chat_page.sidebar).to have_direct_message_channel(channel_1)
using_session(:user_2) do
expect(chat_page.sidebar).to have_direct_message_channel(channel_1)
end
channel_page.send_message
expect(chat_page.sidebar).to have_direct_message_channel(channel_1)
using_session(:user_2) do
expect(chat_page.sidebar).to have_direct_message_channel(channel_1, mention: true)
end
end
end
end
context "when sending message from drawer" do
let(:drawer_page) { PageObjects::Pages::ChatDrawer.new }
let(:topic_page) { PageObjects::Pages::Topic.new }
fab!(:post_1, :post)
fab!(:post_2) { Fabricate(:post, topic: post_1.topic) }
fab!(:channel_1, :chat_channel)
before do
sign_in(user_1)
channel_1.add(user_1)
Jobs.run_immediately!
end
it "has topic context" do
tested_context = {}
blk = ->(*, context) { tested_context = context }
DiscourseEvent.on(:chat_message_created, &blk)
topic_page.visit_topic(post_1.topic)
chat_page.open_from_header
drawer_page.open_channel(channel_1)
channel_page.send_message
try_until_success do
expect(tested_context.dig(:context, :post_ids)).to eq([post_1.id, post_2.id])
expect(tested_context.dig(:context, :topic_id)).to eq(post_1.topic_id)
end
ensure
DiscourseEvent.off(:chat_message_created, &blk)
end
end
end