FIX: more stable system tests (#19678)

This commit is a series of fixes to improve stability of system tests following the use of threadsafe:

* Jobs.run_immediately in before block was causing issues
* During test a js error could be caused by an undefined this.details in chat-live-pane
* Apply the chat composer click trick everywhere when sending a message, it ensures we are not hiding anything with autocomplete
* There was another case not using send_message yet
This commit is contained in:
Joffrey JAFFEUX 2023-01-03 05:53:41 +01:00 committed by GitHub
parent 431b129d8b
commit b235799792
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 10 deletions

View File

@ -1026,7 +1026,7 @@ export default Component.extend({
this.set("sendingLoading", false);
});
if (this.details.can_load_more_future) {
if (this.details?.can_load_more_future) {
msgCreationPromise.then(() => this._fetchAndScrollToLatest());
} else {
const stagedMessage = this._prepareSingleMessage(

View File

@ -9,14 +9,15 @@ RSpec.describe "JIT messages", type: :system, js: true do
let(:channel) { PageObjects::Pages::ChatChannel.new }
before do
Jobs.run_immediately!
channel_1.add(current_user)
chat_system_bootstrap
sign_in(current_user)
end
context "when mentioning a user not on the channel" do
it "displays a mention warning" do
xit "displays a mention warning" do
Jobs.run_immediately!
chat.visit_channel(channel_1)
channel.send_message("hi @#{other_user.username}")
@ -36,6 +37,8 @@ RSpec.describe "JIT messages", type: :system, js: true do
end
it "displays a mention warning" do
Jobs.run_immediately!
chat.visit_channel(private_channel_1)
channel.send_message("hi @#{other_user.username}")
@ -50,6 +53,8 @@ RSpec.describe "JIT messages", type: :system, js: true do
fab!(:group_1) { Fabricate(:group, mentionable_level: Group::ALIAS_LEVELS[:nobody]) }
it "displays a mention warning" do
Jobs.run_immediately!
chat.visit_channel(channel_1)
channel.send_message("hi @#{group_1.name}")

View File

@ -72,6 +72,7 @@ module PageObjects
find(".chat-composer-input").click # makes helper more reliable by ensuring focus is not lost
find(".chat-composer-input").fill_in(with: text)
click_send_message
find(".chat-composer-input").click # ensures autocomplete is closed and not masking anything
end
def reply_to(message)

View File

@ -162,16 +162,13 @@ RSpec.describe "User menu notifications | sidebar", type: :system, js: true do
fab!(:channel_1) { Fabricate(:chat_channel) }
fab!(:other_user) { Fabricate(:user) }
before do
Jobs.run_immediately!
channel_1.add(current_user)
end
before { channel_1.add(current_user) }
it "shows an invitation notification" do
Jobs.run_immediately!
chat.visit_channel(channel_1)
find(".chat-composer-input").fill_in(with: "this is fine @#{other_user.username}")
find(".send-btn").click
find(".chat-composer-input").click # ensures autocomplete is closed and not masking invite link
channel.send_message("this is fine @#{other_user.username}")
find(".invite-link", wait: 5).click
using_session(:user_1) do