discourse/plugins/chat/spec/system/chat_message_onebox_spec.rb
Alan Guo Xiang Tan 30e4ebd19b
Revert "DEV: Update checks in chat channel and thread page objects (#21875)" (#21883)
This reverts commit ddf4ecba04.

Causing a flaky test to appear:

```
main $ LOAD_PLUGINS=1 rspec plugins/chat/spec/system/chat/composer/shortcuts/channel_spec.rb

Randomized with seed 17765
.....F..

Failures:

  1) Chat | composer | shortcuts | channel when using ArrowUp when last message is staged does not edit a message
     Failure/Error: channel_page.send_message
       expected `#<PageObjects::Components::Chat::Messages:0x00007fe823ac1710 @context=".chat-channel">.has_message?({:persisted=>true, :text=>"2"})` to be truthy, got false

     [Screenshot Image]: /home/tgxworld/work/discourse/tmp/capybara/failures_r_spec_example_groups_chat_composer_shortcuts_channel_when_using_arrow_up_when_last_message_is_staged_does_not_edit_a_message_148.png
```
2023-06-01 16:59:03 +08:00

46 lines
1.3 KiB
Ruby

# frozen_string_literal: true
RSpec.describe "Chat message onebox", type: :system, js: true do
let(:chat_page) { PageObjects::Pages::Chat.new }
let(:channel_page) { PageObjects::Pages::ChatChannel.new }
fab!(:current_user) { Fabricate(:user) }
fab!(:channel_1) { Fabricate(:category_channel) }
before do
chat_system_bootstrap
channel_1.add(current_user)
sign_in(current_user)
end
context "when sending a message with a link" do
before do
SiteSetting.enable_inline_onebox_on_all_domains = true
full_onebox_html = <<~HTML.chomp
<aside class="onebox wikipedia" data-onebox-src="https://en.wikipedia.org/wiki/Hyperlink">
<article class="onebox-body">
<p>This is a test</p>
</article>
</aside>
HTML
Oneboxer
.stubs(:cached_onebox)
.with("https://en.wikipedia.org/wiki/Hyperlink")
.returns(full_onebox_html)
stub_request(:get, "https://en.wikipedia.org/wiki/Hyperlink").to_return(
status: 200,
body: "<html><head><title>a</title></head></html>",
)
end
it "is oneboxed" do
chat_page.visit_channel(channel_1)
channel_page.send_message("https://en.wikipedia.org/wiki/Hyperlink")
expect(page).to have_content("This is a test", wait: 20)
end
end
end