DEV: start glimmer-ification and optimisations of chat plugin (#19531)
Note this is a very large PR, and some of it could have been splited, but keeping it one chunk made it to merge conflicts and to revert if necessary. Actual new code logic is also not that much, as most of the changes are removing js tests, adding system specs or moving things around.
To make it possible this commit is doing the following changes:
- converting (and adding new) existing js acceptances tests into system tests. This change was necessary to ensure as little regressions as possible while changing paradigm
- moving away from store. Using glimmer and tracked properties requires to have class objects everywhere and as a result works well with models. However store/adapters are suffering from many bugs and limitations. As a workaround the `chat-api` and `chat-channels-manager` are an answer to this problem by encapsulating backend calls and frontend storage logic; while still using js models.
- dropping `appEvents` as much as possible. Using tracked properties and a better local storage of channel models, allows to be much more reactive and doesn’t require arbitrary manual updates everywhere in the app.
- while working on replacing store, the existing work of a chat api (backend) has been continued to support more cases.
- removing code from the `chat` service to separate concerns, `chat-subscriptions-manager` and `chat-channels-manager`, being the largest examples of where the code has been rewritten/moved.
Future wok:
- improve behavior when closing/deleting a channel, it's already slightly buggy on live, it's rare enough that it's not a big issue, but should be improved
- improve page objects used in chat
- move more endpoints to the API
- finish temporarily skipped tests
- extract more code from the `chat` service
- use glimmer for `chat-messages`
- separate concerns in `chat-live-pane`
- eventually add js tests for `chat-api`, `chat-channels-manager` and `chat-subscriptions-manager`, they are indirectly heavy tested through system tests but it would be nice to at least test the public API
<!-- NOTE: All pull requests should have tests (rspec in Ruby, qunit in JavaScript). If your code does not include test coverage, please include an explanation of why it was omitted. -->
2022-12-21 20:21:02 +08:00
|
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
|
|
RSpec.describe "Chat composer", type: :system, js: true do
|
|
|
|
|
fab!(:current_user) { Fabricate(:user) }
|
|
|
|
|
fab!(:channel_1) { Fabricate(:chat_channel) }
|
|
|
|
|
fab!(:message_1) { Fabricate(:chat_message, chat_channel: channel_1) }
|
|
|
|
|
|
|
|
|
|
let(:chat) { PageObjects::Pages::Chat.new }
|
|
|
|
|
let(:channel) { PageObjects::Pages::ChatChannel.new }
|
|
|
|
|
|
|
|
|
|
before { chat_system_bootstrap }
|
|
|
|
|
|
2023-04-25 16:23:03 +08:00
|
|
|
|
context "when loading a channel with a draft" do
|
|
|
|
|
fab!(:draft_1) do
|
|
|
|
|
Chat::Draft.create!(
|
|
|
|
|
chat_channel: channel_1,
|
|
|
|
|
user: current_user,
|
|
|
|
|
data: { message: "draft" }.to_json,
|
|
|
|
|
)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
before do
|
|
|
|
|
channel_1.add(current_user)
|
|
|
|
|
sign_in(current_user)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "loads the draft" do
|
|
|
|
|
chat.visit_channel(channel_1)
|
|
|
|
|
|
|
|
|
|
expect(find(".chat-composer__input").value).to eq("draft")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context "with uploads" do
|
|
|
|
|
fab!(:upload_1) do
|
|
|
|
|
Fabricate(
|
|
|
|
|
:upload,
|
|
|
|
|
url: "/images/logo-dark.png",
|
|
|
|
|
original_filename: "logo_dark.png",
|
|
|
|
|
width: 400,
|
|
|
|
|
height: 300,
|
|
|
|
|
extension: "png",
|
|
|
|
|
)
|
|
|
|
|
end
|
DEV: start glimmer-ification and optimisations of chat plugin (#19531)
Note this is a very large PR, and some of it could have been splited, but keeping it one chunk made it to merge conflicts and to revert if necessary. Actual new code logic is also not that much, as most of the changes are removing js tests, adding system specs or moving things around.
To make it possible this commit is doing the following changes:
- converting (and adding new) existing js acceptances tests into system tests. This change was necessary to ensure as little regressions as possible while changing paradigm
- moving away from store. Using glimmer and tracked properties requires to have class objects everywhere and as a result works well with models. However store/adapters are suffering from many bugs and limitations. As a workaround the `chat-api` and `chat-channels-manager` are an answer to this problem by encapsulating backend calls and frontend storage logic; while still using js models.
- dropping `appEvents` as much as possible. Using tracked properties and a better local storage of channel models, allows to be much more reactive and doesn’t require arbitrary manual updates everywhere in the app.
- while working on replacing store, the existing work of a chat api (backend) has been continued to support more cases.
- removing code from the `chat` service to separate concerns, `chat-subscriptions-manager` and `chat-channels-manager`, being the largest examples of where the code has been rewritten/moved.
Future wok:
- improve behavior when closing/deleting a channel, it's already slightly buggy on live, it's rare enough that it's not a big issue, but should be improved
- improve page objects used in chat
- move more endpoints to the API
- finish temporarily skipped tests
- extract more code from the `chat` service
- use glimmer for `chat-messages`
- separate concerns in `chat-live-pane`
- eventually add js tests for `chat-api`, `chat-channels-manager` and `chat-subscriptions-manager`, they are indirectly heavy tested through system tests but it would be nice to at least test the public API
<!-- NOTE: All pull requests should have tests (rspec in Ruby, qunit in JavaScript). If your code does not include test coverage, please include an explanation of why it was omitted. -->
2022-12-21 20:21:02 +08:00
|
|
|
|
|
2023-04-25 16:23:03 +08:00
|
|
|
|
fab!(:draft_1) do
|
|
|
|
|
Chat::Draft.create!(
|
|
|
|
|
chat_channel: channel_1,
|
|
|
|
|
user: current_user,
|
|
|
|
|
data: { message: "draft", uploads: [upload_1] }.to_json,
|
|
|
|
|
)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "loads the draft with the upload" do
|
|
|
|
|
chat.visit_channel(channel_1)
|
|
|
|
|
|
|
|
|
|
expect(find(".chat-composer__input").value).to eq("draft")
|
|
|
|
|
expect(page).to have_selector(".chat-composer-upload--image", count: 1)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context "when replying" do
|
|
|
|
|
fab!(:draft_1) do
|
|
|
|
|
Chat::Draft.create!(
|
|
|
|
|
chat_channel: channel_1,
|
|
|
|
|
user: current_user,
|
|
|
|
|
data: {
|
|
|
|
|
message: "draft",
|
|
|
|
|
replyToMsg: {
|
|
|
|
|
id: message_1.id,
|
|
|
|
|
excerpt: message_1.excerpt,
|
|
|
|
|
user: {
|
|
|
|
|
id: message_1.user.id,
|
|
|
|
|
name: nil,
|
|
|
|
|
avatar_template: message_1.user.avatar_template,
|
|
|
|
|
username: message_1.user.username,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}.to_json,
|
|
|
|
|
)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "loads the draft with replied to mesage" do
|
|
|
|
|
chat.visit_channel(channel_1)
|
|
|
|
|
|
|
|
|
|
expect(find(".chat-composer__input").value).to eq("draft")
|
|
|
|
|
expect(page).to have_selector(".chat-reply__username", text: message_1.user.username)
|
|
|
|
|
expect(page).to have_selector(".chat-reply__excerpt", text: message_1.excerpt)
|
|
|
|
|
end
|
|
|
|
|
end
|
DEV: start glimmer-ification and optimisations of chat plugin (#19531)
Note this is a very large PR, and some of it could have been splited, but keeping it one chunk made it to merge conflicts and to revert if necessary. Actual new code logic is also not that much, as most of the changes are removing js tests, adding system specs or moving things around.
To make it possible this commit is doing the following changes:
- converting (and adding new) existing js acceptances tests into system tests. This change was necessary to ensure as little regressions as possible while changing paradigm
- moving away from store. Using glimmer and tracked properties requires to have class objects everywhere and as a result works well with models. However store/adapters are suffering from many bugs and limitations. As a workaround the `chat-api` and `chat-channels-manager` are an answer to this problem by encapsulating backend calls and frontend storage logic; while still using js models.
- dropping `appEvents` as much as possible. Using tracked properties and a better local storage of channel models, allows to be much more reactive and doesn’t require arbitrary manual updates everywhere in the app.
- while working on replacing store, the existing work of a chat api (backend) has been continued to support more cases.
- removing code from the `chat` service to separate concerns, `chat-subscriptions-manager` and `chat-channels-manager`, being the largest examples of where the code has been rewritten/moved.
Future wok:
- improve behavior when closing/deleting a channel, it's already slightly buggy on live, it's rare enough that it's not a big issue, but should be improved
- improve page objects used in chat
- move more endpoints to the API
- finish temporarily skipped tests
- extract more code from the `chat` service
- use glimmer for `chat-messages`
- separate concerns in `chat-live-pane`
- eventually add js tests for `chat-api`, `chat-channels-manager` and `chat-subscriptions-manager`, they are indirectly heavy tested through system tests but it would be nice to at least test the public API
<!-- NOTE: All pull requests should have tests (rspec in Ruby, qunit in JavaScript). If your code does not include test coverage, please include an explanation of why it was omitted. -->
2022-12-21 20:21:02 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context "when replying to a message" do
|
|
|
|
|
before do
|
|
|
|
|
channel_1.add(current_user)
|
|
|
|
|
sign_in(current_user)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "adds the reply indicator to the composer" do
|
|
|
|
|
chat.visit_channel(channel_1)
|
|
|
|
|
channel.reply_to(message_1)
|
|
|
|
|
|
|
|
|
|
expect(page).to have_selector(
|
|
|
|
|
".chat-composer-message-details .chat-reply__username",
|
|
|
|
|
text: message_1.user.username,
|
|
|
|
|
)
|
|
|
|
|
end
|
2023-03-27 21:42:30 +08:00
|
|
|
|
|
|
|
|
|
context "with HTML tags" do
|
|
|
|
|
before { message_1.update!(message: "<mark>not marked</mark>") }
|
|
|
|
|
|
|
|
|
|
it "renders text in the details" do
|
|
|
|
|
chat.visit_channel(channel_1)
|
|
|
|
|
channel.reply_to(message_1)
|
|
|
|
|
|
|
|
|
|
expect(
|
|
|
|
|
find(".chat-composer-message-details .chat-reply__excerpt")["innerHTML"].strip,
|
|
|
|
|
).to eq("not marked")
|
|
|
|
|
end
|
|
|
|
|
end
|
DEV: start glimmer-ification and optimisations of chat plugin (#19531)
Note this is a very large PR, and some of it could have been splited, but keeping it one chunk made it to merge conflicts and to revert if necessary. Actual new code logic is also not that much, as most of the changes are removing js tests, adding system specs or moving things around.
To make it possible this commit is doing the following changes:
- converting (and adding new) existing js acceptances tests into system tests. This change was necessary to ensure as little regressions as possible while changing paradigm
- moving away from store. Using glimmer and tracked properties requires to have class objects everywhere and as a result works well with models. However store/adapters are suffering from many bugs and limitations. As a workaround the `chat-api` and `chat-channels-manager` are an answer to this problem by encapsulating backend calls and frontend storage logic; while still using js models.
- dropping `appEvents` as much as possible. Using tracked properties and a better local storage of channel models, allows to be much more reactive and doesn’t require arbitrary manual updates everywhere in the app.
- while working on replacing store, the existing work of a chat api (backend) has been continued to support more cases.
- removing code from the `chat` service to separate concerns, `chat-subscriptions-manager` and `chat-channels-manager`, being the largest examples of where the code has been rewritten/moved.
Future wok:
- improve behavior when closing/deleting a channel, it's already slightly buggy on live, it's rare enough that it's not a big issue, but should be improved
- improve page objects used in chat
- move more endpoints to the API
- finish temporarily skipped tests
- extract more code from the `chat` service
- use glimmer for `chat-messages`
- separate concerns in `chat-live-pane`
- eventually add js tests for `chat-api`, `chat-channels-manager` and `chat-subscriptions-manager`, they are indirectly heavy tested through system tests but it would be nice to at least test the public API
<!-- NOTE: All pull requests should have tests (rspec in Ruby, qunit in JavaScript). If your code does not include test coverage, please include an explanation of why it was omitted. -->
2022-12-21 20:21:02 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context "when editing a message" do
|
|
|
|
|
fab!(:message_2) { Fabricate(:chat_message, chat_channel: channel_1, user: current_user) }
|
|
|
|
|
|
|
|
|
|
before do
|
|
|
|
|
channel_1.add(current_user)
|
|
|
|
|
sign_in(current_user)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "adds the edit indicator" do
|
|
|
|
|
chat.visit_channel(channel_1)
|
|
|
|
|
channel.edit_message(message_2)
|
|
|
|
|
|
|
|
|
|
expect(page).to have_selector(
|
|
|
|
|
".chat-composer-message-details .chat-reply__username",
|
|
|
|
|
text: current_user.username,
|
|
|
|
|
)
|
2023-04-25 16:23:03 +08:00
|
|
|
|
expect(find(".chat-composer__input").value).to eq(message_2.message)
|
DEV: start glimmer-ification and optimisations of chat plugin (#19531)
Note this is a very large PR, and some of it could have been splited, but keeping it one chunk made it to merge conflicts and to revert if necessary. Actual new code logic is also not that much, as most of the changes are removing js tests, adding system specs or moving things around.
To make it possible this commit is doing the following changes:
- converting (and adding new) existing js acceptances tests into system tests. This change was necessary to ensure as little regressions as possible while changing paradigm
- moving away from store. Using glimmer and tracked properties requires to have class objects everywhere and as a result works well with models. However store/adapters are suffering from many bugs and limitations. As a workaround the `chat-api` and `chat-channels-manager` are an answer to this problem by encapsulating backend calls and frontend storage logic; while still using js models.
- dropping `appEvents` as much as possible. Using tracked properties and a better local storage of channel models, allows to be much more reactive and doesn’t require arbitrary manual updates everywhere in the app.
- while working on replacing store, the existing work of a chat api (backend) has been continued to support more cases.
- removing code from the `chat` service to separate concerns, `chat-subscriptions-manager` and `chat-channels-manager`, being the largest examples of where the code has been rewritten/moved.
Future wok:
- improve behavior when closing/deleting a channel, it's already slightly buggy on live, it's rare enough that it's not a big issue, but should be improved
- improve page objects used in chat
- move more endpoints to the API
- finish temporarily skipped tests
- extract more code from the `chat` service
- use glimmer for `chat-messages`
- separate concerns in `chat-live-pane`
- eventually add js tests for `chat-api`, `chat-channels-manager` and `chat-subscriptions-manager`, they are indirectly heavy tested through system tests but it would be nice to at least test the public API
<!-- NOTE: All pull requests should have tests (rspec in Ruby, qunit in JavaScript). If your code does not include test coverage, please include an explanation of why it was omitted. -->
2022-12-21 20:21:02 +08:00
|
|
|
|
end
|
|
|
|
|
|
2023-04-29 02:11:57 +08:00
|
|
|
|
it "updates the message instantly" do
|
|
|
|
|
chat.visit_channel(channel_1)
|
|
|
|
|
page.driver.browser.network_conditions = { offline: true }
|
|
|
|
|
|
|
|
|
|
channel.edit_message(message_2)
|
|
|
|
|
find(".chat-composer__input").send_keys("instant")
|
|
|
|
|
channel.click_send_message
|
|
|
|
|
|
|
|
|
|
expect(channel).to have_message(text: message_2.message + "instant")
|
|
|
|
|
page.driver.browser.network_conditions = { offline: false }
|
|
|
|
|
end
|
|
|
|
|
|
DEV: start glimmer-ification and optimisations of chat plugin (#19531)
Note this is a very large PR, and some of it could have been splited, but keeping it one chunk made it to merge conflicts and to revert if necessary. Actual new code logic is also not that much, as most of the changes are removing js tests, adding system specs or moving things around.
To make it possible this commit is doing the following changes:
- converting (and adding new) existing js acceptances tests into system tests. This change was necessary to ensure as little regressions as possible while changing paradigm
- moving away from store. Using glimmer and tracked properties requires to have class objects everywhere and as a result works well with models. However store/adapters are suffering from many bugs and limitations. As a workaround the `chat-api` and `chat-channels-manager` are an answer to this problem by encapsulating backend calls and frontend storage logic; while still using js models.
- dropping `appEvents` as much as possible. Using tracked properties and a better local storage of channel models, allows to be much more reactive and doesn’t require arbitrary manual updates everywhere in the app.
- while working on replacing store, the existing work of a chat api (backend) has been continued to support more cases.
- removing code from the `chat` service to separate concerns, `chat-subscriptions-manager` and `chat-channels-manager`, being the largest examples of where the code has been rewritten/moved.
Future wok:
- improve behavior when closing/deleting a channel, it's already slightly buggy on live, it's rare enough that it's not a big issue, but should be improved
- improve page objects used in chat
- move more endpoints to the API
- finish temporarily skipped tests
- extract more code from the `chat` service
- use glimmer for `chat-messages`
- separate concerns in `chat-live-pane`
- eventually add js tests for `chat-api`, `chat-channels-manager` and `chat-subscriptions-manager`, they are indirectly heavy tested through system tests but it would be nice to at least test the public API
<!-- NOTE: All pull requests should have tests (rspec in Ruby, qunit in JavaScript). If your code does not include test coverage, please include an explanation of why it was omitted. -->
2022-12-21 20:21:02 +08:00
|
|
|
|
context "when pressing escape" do
|
|
|
|
|
it "cancels editing" do
|
|
|
|
|
chat.visit_channel(channel_1)
|
|
|
|
|
channel.edit_message(message_2)
|
2023-04-25 16:23:03 +08:00
|
|
|
|
find(".chat-composer__input").send_keys(:escape)
|
DEV: start glimmer-ification and optimisations of chat plugin (#19531)
Note this is a very large PR, and some of it could have been splited, but keeping it one chunk made it to merge conflicts and to revert if necessary. Actual new code logic is also not that much, as most of the changes are removing js tests, adding system specs or moving things around.
To make it possible this commit is doing the following changes:
- converting (and adding new) existing js acceptances tests into system tests. This change was necessary to ensure as little regressions as possible while changing paradigm
- moving away from store. Using glimmer and tracked properties requires to have class objects everywhere and as a result works well with models. However store/adapters are suffering from many bugs and limitations. As a workaround the `chat-api` and `chat-channels-manager` are an answer to this problem by encapsulating backend calls and frontend storage logic; while still using js models.
- dropping `appEvents` as much as possible. Using tracked properties and a better local storage of channel models, allows to be much more reactive and doesn’t require arbitrary manual updates everywhere in the app.
- while working on replacing store, the existing work of a chat api (backend) has been continued to support more cases.
- removing code from the `chat` service to separate concerns, `chat-subscriptions-manager` and `chat-channels-manager`, being the largest examples of where the code has been rewritten/moved.
Future wok:
- improve behavior when closing/deleting a channel, it's already slightly buggy on live, it's rare enough that it's not a big issue, but should be improved
- improve page objects used in chat
- move more endpoints to the API
- finish temporarily skipped tests
- extract more code from the `chat` service
- use glimmer for `chat-messages`
- separate concerns in `chat-live-pane`
- eventually add js tests for `chat-api`, `chat-channels-manager` and `chat-subscriptions-manager`, they are indirectly heavy tested through system tests but it would be nice to at least test the public API
<!-- NOTE: All pull requests should have tests (rspec in Ruby, qunit in JavaScript). If your code does not include test coverage, please include an explanation of why it was omitted. -->
2022-12-21 20:21:02 +08:00
|
|
|
|
|
|
|
|
|
expect(page).to have_no_selector(".chat-composer-message-details .chat-reply__username")
|
2023-04-25 16:23:03 +08:00
|
|
|
|
expect(find(".chat-composer__input").value).to eq("")
|
2023-04-07 15:55:55 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context "when closing edited message" do
|
|
|
|
|
it "cancels editing" do
|
|
|
|
|
chat.visit_channel(channel_1)
|
|
|
|
|
channel.edit_message(message_2)
|
|
|
|
|
find(".cancel-message-action").click
|
|
|
|
|
|
|
|
|
|
expect(page).to have_no_selector(".chat-composer-message-details .chat-reply__username")
|
2023-04-25 16:23:03 +08:00
|
|
|
|
expect(find(".chat-composer__input").value).to eq("")
|
DEV: start glimmer-ification and optimisations of chat plugin (#19531)
Note this is a very large PR, and some of it could have been splited, but keeping it one chunk made it to merge conflicts and to revert if necessary. Actual new code logic is also not that much, as most of the changes are removing js tests, adding system specs or moving things around.
To make it possible this commit is doing the following changes:
- converting (and adding new) existing js acceptances tests into system tests. This change was necessary to ensure as little regressions as possible while changing paradigm
- moving away from store. Using glimmer and tracked properties requires to have class objects everywhere and as a result works well with models. However store/adapters are suffering from many bugs and limitations. As a workaround the `chat-api` and `chat-channels-manager` are an answer to this problem by encapsulating backend calls and frontend storage logic; while still using js models.
- dropping `appEvents` as much as possible. Using tracked properties and a better local storage of channel models, allows to be much more reactive and doesn’t require arbitrary manual updates everywhere in the app.
- while working on replacing store, the existing work of a chat api (backend) has been continued to support more cases.
- removing code from the `chat` service to separate concerns, `chat-subscriptions-manager` and `chat-channels-manager`, being the largest examples of where the code has been rewritten/moved.
Future wok:
- improve behavior when closing/deleting a channel, it's already slightly buggy on live, it's rare enough that it's not a big issue, but should be improved
- improve page objects used in chat
- move more endpoints to the API
- finish temporarily skipped tests
- extract more code from the `chat` service
- use glimmer for `chat-messages`
- separate concerns in `chat-live-pane`
- eventually add js tests for `chat-api`, `chat-channels-manager` and `chat-subscriptions-manager`, they are indirectly heavy tested through system tests but it would be nice to at least test the public API
<!-- NOTE: All pull requests should have tests (rspec in Ruby, qunit in JavaScript). If your code does not include test coverage, please include an explanation of why it was omitted. -->
2022-12-21 20:21:02 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context "when adding an emoji through the picker" do
|
|
|
|
|
before do
|
|
|
|
|
channel_1.add(current_user)
|
|
|
|
|
sign_in(current_user)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "adds the emoji to the composer" do
|
|
|
|
|
chat.visit_channel(channel_1)
|
2022-12-23 15:41:10 +08:00
|
|
|
|
channel.open_action_menu
|
|
|
|
|
channel.click_action_button("emoji")
|
DEV: start glimmer-ification and optimisations of chat plugin (#19531)
Note this is a very large PR, and some of it could have been splited, but keeping it one chunk made it to merge conflicts and to revert if necessary. Actual new code logic is also not that much, as most of the changes are removing js tests, adding system specs or moving things around.
To make it possible this commit is doing the following changes:
- converting (and adding new) existing js acceptances tests into system tests. This change was necessary to ensure as little regressions as possible while changing paradigm
- moving away from store. Using glimmer and tracked properties requires to have class objects everywhere and as a result works well with models. However store/adapters are suffering from many bugs and limitations. As a workaround the `chat-api` and `chat-channels-manager` are an answer to this problem by encapsulating backend calls and frontend storage logic; while still using js models.
- dropping `appEvents` as much as possible. Using tracked properties and a better local storage of channel models, allows to be much more reactive and doesn’t require arbitrary manual updates everywhere in the app.
- while working on replacing store, the existing work of a chat api (backend) has been continued to support more cases.
- removing code from the `chat` service to separate concerns, `chat-subscriptions-manager` and `chat-channels-manager`, being the largest examples of where the code has been rewritten/moved.
Future wok:
- improve behavior when closing/deleting a channel, it's already slightly buggy on live, it's rare enough that it's not a big issue, but should be improved
- improve page objects used in chat
- move more endpoints to the API
- finish temporarily skipped tests
- extract more code from the `chat` service
- use glimmer for `chat-messages`
- separate concerns in `chat-live-pane`
- eventually add js tests for `chat-api`, `chat-channels-manager` and `chat-subscriptions-manager`, they are indirectly heavy tested through system tests but it would be nice to at least test the public API
<!-- NOTE: All pull requests should have tests (rspec in Ruby, qunit in JavaScript). If your code does not include test coverage, please include an explanation of why it was omitted. -->
2022-12-21 20:21:02 +08:00
|
|
|
|
find("[data-emoji='grimacing']").click(wait: 0.5)
|
|
|
|
|
|
2023-04-25 16:23:03 +08:00
|
|
|
|
expect(find(".chat-composer__input").value).to eq(":grimacing:")
|
DEV: start glimmer-ification and optimisations of chat plugin (#19531)
Note this is a very large PR, and some of it could have been splited, but keeping it one chunk made it to merge conflicts and to revert if necessary. Actual new code logic is also not that much, as most of the changes are removing js tests, adding system specs or moving things around.
To make it possible this commit is doing the following changes:
- converting (and adding new) existing js acceptances tests into system tests. This change was necessary to ensure as little regressions as possible while changing paradigm
- moving away from store. Using glimmer and tracked properties requires to have class objects everywhere and as a result works well with models. However store/adapters are suffering from many bugs and limitations. As a workaround the `chat-api` and `chat-channels-manager` are an answer to this problem by encapsulating backend calls and frontend storage logic; while still using js models.
- dropping `appEvents` as much as possible. Using tracked properties and a better local storage of channel models, allows to be much more reactive and doesn’t require arbitrary manual updates everywhere in the app.
- while working on replacing store, the existing work of a chat api (backend) has been continued to support more cases.
- removing code from the `chat` service to separate concerns, `chat-subscriptions-manager` and `chat-channels-manager`, being the largest examples of where the code has been rewritten/moved.
Future wok:
- improve behavior when closing/deleting a channel, it's already slightly buggy on live, it's rare enough that it's not a big issue, but should be improved
- improve page objects used in chat
- move more endpoints to the API
- finish temporarily skipped tests
- extract more code from the `chat` service
- use glimmer for `chat-messages`
- separate concerns in `chat-live-pane`
- eventually add js tests for `chat-api`, `chat-channels-manager` and `chat-subscriptions-manager`, they are indirectly heavy tested through system tests but it would be nice to at least test the public API
<!-- NOTE: All pull requests should have tests (rspec in Ruby, qunit in JavaScript). If your code does not include test coverage, please include an explanation of why it was omitted. -->
2022-12-21 20:21:02 +08:00
|
|
|
|
end
|
2023-04-13 15:38:54 +08:00
|
|
|
|
|
|
|
|
|
it "removes denied emojis from insert emoji picker" do
|
|
|
|
|
SiteSetting.emoji_deny_list = "monkey|peach"
|
|
|
|
|
|
|
|
|
|
chat.visit_channel(channel_1)
|
|
|
|
|
channel.open_action_menu
|
|
|
|
|
channel.click_action_button("emoji")
|
|
|
|
|
|
|
|
|
|
expect(page).to have_no_selector("[data-emoji='monkey']")
|
|
|
|
|
expect(page).to have_no_selector("[data-emoji='peach']")
|
|
|
|
|
end
|
DEV: start glimmer-ification and optimisations of chat plugin (#19531)
Note this is a very large PR, and some of it could have been splited, but keeping it one chunk made it to merge conflicts and to revert if necessary. Actual new code logic is also not that much, as most of the changes are removing js tests, adding system specs or moving things around.
To make it possible this commit is doing the following changes:
- converting (and adding new) existing js acceptances tests into system tests. This change was necessary to ensure as little regressions as possible while changing paradigm
- moving away from store. Using glimmer and tracked properties requires to have class objects everywhere and as a result works well with models. However store/adapters are suffering from many bugs and limitations. As a workaround the `chat-api` and `chat-channels-manager` are an answer to this problem by encapsulating backend calls and frontend storage logic; while still using js models.
- dropping `appEvents` as much as possible. Using tracked properties and a better local storage of channel models, allows to be much more reactive and doesn’t require arbitrary manual updates everywhere in the app.
- while working on replacing store, the existing work of a chat api (backend) has been continued to support more cases.
- removing code from the `chat` service to separate concerns, `chat-subscriptions-manager` and `chat-channels-manager`, being the largest examples of where the code has been rewritten/moved.
Future wok:
- improve behavior when closing/deleting a channel, it's already slightly buggy on live, it's rare enough that it's not a big issue, but should be improved
- improve page objects used in chat
- move more endpoints to the API
- finish temporarily skipped tests
- extract more code from the `chat` service
- use glimmer for `chat-messages`
- separate concerns in `chat-live-pane`
- eventually add js tests for `chat-api`, `chat-channels-manager` and `chat-subscriptions-manager`, they are indirectly heavy tested through system tests but it would be nice to at least test the public API
<!-- NOTE: All pull requests should have tests (rspec in Ruby, qunit in JavaScript). If your code does not include test coverage, please include an explanation of why it was omitted. -->
2022-12-21 20:21:02 +08:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context "when adding an emoji through the autocomplete" do
|
|
|
|
|
before do
|
|
|
|
|
channel_1.add(current_user)
|
|
|
|
|
sign_in(current_user)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "adds the emoji to the composer" do
|
|
|
|
|
chat.visit_channel(channel_1)
|
2023-04-25 16:23:03 +08:00
|
|
|
|
find(".chat-composer__input").fill_in(with: ":gri")
|
DEV: start glimmer-ification and optimisations of chat plugin (#19531)
Note this is a very large PR, and some of it could have been splited, but keeping it one chunk made it to merge conflicts and to revert if necessary. Actual new code logic is also not that much, as most of the changes are removing js tests, adding system specs or moving things around.
To make it possible this commit is doing the following changes:
- converting (and adding new) existing js acceptances tests into system tests. This change was necessary to ensure as little regressions as possible while changing paradigm
- moving away from store. Using glimmer and tracked properties requires to have class objects everywhere and as a result works well with models. However store/adapters are suffering from many bugs and limitations. As a workaround the `chat-api` and `chat-channels-manager` are an answer to this problem by encapsulating backend calls and frontend storage logic; while still using js models.
- dropping `appEvents` as much as possible. Using tracked properties and a better local storage of channel models, allows to be much more reactive and doesn’t require arbitrary manual updates everywhere in the app.
- while working on replacing store, the existing work of a chat api (backend) has been continued to support more cases.
- removing code from the `chat` service to separate concerns, `chat-subscriptions-manager` and `chat-channels-manager`, being the largest examples of where the code has been rewritten/moved.
Future wok:
- improve behavior when closing/deleting a channel, it's already slightly buggy on live, it's rare enough that it's not a big issue, but should be improved
- improve page objects used in chat
- move more endpoints to the API
- finish temporarily skipped tests
- extract more code from the `chat` service
- use glimmer for `chat-messages`
- separate concerns in `chat-live-pane`
- eventually add js tests for `chat-api`, `chat-channels-manager` and `chat-subscriptions-manager`, they are indirectly heavy tested through system tests but it would be nice to at least test the public API
<!-- NOTE: All pull requests should have tests (rspec in Ruby, qunit in JavaScript). If your code does not include test coverage, please include an explanation of why it was omitted. -->
2022-12-21 20:21:02 +08:00
|
|
|
|
find(".emoji-shortname", text: "grimacing").click
|
|
|
|
|
|
2023-04-25 16:23:03 +08:00
|
|
|
|
expect(find(".chat-composer__input").value).to eq(":grimacing: ")
|
DEV: start glimmer-ification and optimisations of chat plugin (#19531)
Note this is a very large PR, and some of it could have been splited, but keeping it one chunk made it to merge conflicts and to revert if necessary. Actual new code logic is also not that much, as most of the changes are removing js tests, adding system specs or moving things around.
To make it possible this commit is doing the following changes:
- converting (and adding new) existing js acceptances tests into system tests. This change was necessary to ensure as little regressions as possible while changing paradigm
- moving away from store. Using glimmer and tracked properties requires to have class objects everywhere and as a result works well with models. However store/adapters are suffering from many bugs and limitations. As a workaround the `chat-api` and `chat-channels-manager` are an answer to this problem by encapsulating backend calls and frontend storage logic; while still using js models.
- dropping `appEvents` as much as possible. Using tracked properties and a better local storage of channel models, allows to be much more reactive and doesn’t require arbitrary manual updates everywhere in the app.
- while working on replacing store, the existing work of a chat api (backend) has been continued to support more cases.
- removing code from the `chat` service to separate concerns, `chat-subscriptions-manager` and `chat-channels-manager`, being the largest examples of where the code has been rewritten/moved.
Future wok:
- improve behavior when closing/deleting a channel, it's already slightly buggy on live, it's rare enough that it's not a big issue, but should be improved
- improve page objects used in chat
- move more endpoints to the API
- finish temporarily skipped tests
- extract more code from the `chat` service
- use glimmer for `chat-messages`
- separate concerns in `chat-live-pane`
- eventually add js tests for `chat-api`, `chat-channels-manager` and `chat-subscriptions-manager`, they are indirectly heavy tested through system tests but it would be nice to at least test the public API
<!-- NOTE: All pull requests should have tests (rspec in Ruby, qunit in JavaScript). If your code does not include test coverage, please include an explanation of why it was omitted. -->
2022-12-21 20:21:02 +08:00
|
|
|
|
end
|
2023-04-13 15:38:54 +08:00
|
|
|
|
|
|
|
|
|
it "doesn't suggest denied emojis and aliases" do
|
|
|
|
|
SiteSetting.emoji_deny_list = "peach|poop"
|
|
|
|
|
chat.visit_channel(channel_1)
|
|
|
|
|
|
2023-04-25 16:23:03 +08:00
|
|
|
|
find(".chat-composer__input").fill_in(with: ":peac")
|
2023-04-13 15:38:54 +08:00
|
|
|
|
expect(page).to have_no_selector(".emoji-shortname", text: "peach")
|
|
|
|
|
|
2023-04-25 16:23:03 +08:00
|
|
|
|
find(".chat-composer__input").fill_in(with: ":hank") # alias
|
2023-04-13 15:38:54 +08:00
|
|
|
|
expect(page).to have_no_selector(".emoji-shortname", text: "poop")
|
|
|
|
|
end
|
DEV: start glimmer-ification and optimisations of chat plugin (#19531)
Note this is a very large PR, and some of it could have been splited, but keeping it one chunk made it to merge conflicts and to revert if necessary. Actual new code logic is also not that much, as most of the changes are removing js tests, adding system specs or moving things around.
To make it possible this commit is doing the following changes:
- converting (and adding new) existing js acceptances tests into system tests. This change was necessary to ensure as little regressions as possible while changing paradigm
- moving away from store. Using glimmer and tracked properties requires to have class objects everywhere and as a result works well with models. However store/adapters are suffering from many bugs and limitations. As a workaround the `chat-api` and `chat-channels-manager` are an answer to this problem by encapsulating backend calls and frontend storage logic; while still using js models.
- dropping `appEvents` as much as possible. Using tracked properties and a better local storage of channel models, allows to be much more reactive and doesn’t require arbitrary manual updates everywhere in the app.
- while working on replacing store, the existing work of a chat api (backend) has been continued to support more cases.
- removing code from the `chat` service to separate concerns, `chat-subscriptions-manager` and `chat-channels-manager`, being the largest examples of where the code has been rewritten/moved.
Future wok:
- improve behavior when closing/deleting a channel, it's already slightly buggy on live, it's rare enough that it's not a big issue, but should be improved
- improve page objects used in chat
- move more endpoints to the API
- finish temporarily skipped tests
- extract more code from the `chat` service
- use glimmer for `chat-messages`
- separate concerns in `chat-live-pane`
- eventually add js tests for `chat-api`, `chat-channels-manager` and `chat-subscriptions-manager`, they are indirectly heavy tested through system tests but it would be nice to at least test the public API
<!-- NOTE: All pull requests should have tests (rspec in Ruby, qunit in JavaScript). If your code does not include test coverage, please include an explanation of why it was omitted. -->
2022-12-21 20:21:02 +08:00
|
|
|
|
end
|
|
|
|
|
|
2023-02-03 02:04:52 +08:00
|
|
|
|
context "when opening emoji picker through more button of the autocomplete" do
|
|
|
|
|
before do
|
|
|
|
|
channel_1.add(current_user)
|
|
|
|
|
sign_in(current_user)
|
|
|
|
|
end
|
|
|
|
|
|
2023-04-12 16:51:00 +08:00
|
|
|
|
xit "prefills the emoji picker filter input" do
|
2023-02-03 02:04:52 +08:00
|
|
|
|
chat.visit_channel(channel_1)
|
2023-04-25 16:23:03 +08:00
|
|
|
|
find(".chat-composer__input").fill_in(with: ":gri")
|
2023-02-03 02:04:52 +08:00
|
|
|
|
|
|
|
|
|
click_link(I18n.t("js.composer.more_emoji"))
|
|
|
|
|
|
|
|
|
|
expect(find(".chat-emoji-picker .dc-filter-input").value).to eq("gri")
|
|
|
|
|
end
|
2023-02-03 06:49:36 +08:00
|
|
|
|
|
2023-04-26 19:02:19 +08:00
|
|
|
|
xit "filters with the prefilled input" do
|
2023-02-03 06:49:36 +08:00
|
|
|
|
chat.visit_channel(channel_1)
|
2023-04-25 16:23:03 +08:00
|
|
|
|
find(".chat-composer__input").fill_in(with: ":fr")
|
2023-02-03 06:49:36 +08:00
|
|
|
|
|
|
|
|
|
click_link(I18n.t("js.composer.more_emoji"))
|
|
|
|
|
|
|
|
|
|
expect(page).to have_selector(".chat-emoji-picker [data-emoji='fr']")
|
|
|
|
|
expect(page).to have_no_selector(".chat-emoji-picker [data-emoji='grinning']")
|
|
|
|
|
end
|
2023-02-03 02:04:52 +08:00
|
|
|
|
end
|
|
|
|
|
|
DEV: start glimmer-ification and optimisations of chat plugin (#19531)
Note this is a very large PR, and some of it could have been splited, but keeping it one chunk made it to merge conflicts and to revert if necessary. Actual new code logic is also not that much, as most of the changes are removing js tests, adding system specs or moving things around.
To make it possible this commit is doing the following changes:
- converting (and adding new) existing js acceptances tests into system tests. This change was necessary to ensure as little regressions as possible while changing paradigm
- moving away from store. Using glimmer and tracked properties requires to have class objects everywhere and as a result works well with models. However store/adapters are suffering from many bugs and limitations. As a workaround the `chat-api` and `chat-channels-manager` are an answer to this problem by encapsulating backend calls and frontend storage logic; while still using js models.
- dropping `appEvents` as much as possible. Using tracked properties and a better local storage of channel models, allows to be much more reactive and doesn’t require arbitrary manual updates everywhere in the app.
- while working on replacing store, the existing work of a chat api (backend) has been continued to support more cases.
- removing code from the `chat` service to separate concerns, `chat-subscriptions-manager` and `chat-channels-manager`, being the largest examples of where the code has been rewritten/moved.
Future wok:
- improve behavior when closing/deleting a channel, it's already slightly buggy on live, it's rare enough that it's not a big issue, but should be improved
- improve page objects used in chat
- move more endpoints to the API
- finish temporarily skipped tests
- extract more code from the `chat` service
- use glimmer for `chat-messages`
- separate concerns in `chat-live-pane`
- eventually add js tests for `chat-api`, `chat-channels-manager` and `chat-subscriptions-manager`, they are indirectly heavy tested through system tests but it would be nice to at least test the public API
<!-- NOTE: All pull requests should have tests (rspec in Ruby, qunit in JavaScript). If your code does not include test coverage, please include an explanation of why it was omitted. -->
2022-12-21 20:21:02 +08:00
|
|
|
|
context "when typing on keyboard" do
|
|
|
|
|
before do
|
|
|
|
|
channel_1.add(current_user)
|
|
|
|
|
sign_in(current_user)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "propagates keys to composer" do
|
|
|
|
|
chat.visit_channel(channel_1)
|
|
|
|
|
|
|
|
|
|
find("body").send_keys("b")
|
|
|
|
|
|
2023-04-25 16:23:03 +08:00
|
|
|
|
expect(find(".chat-composer__input").value).to eq("b")
|
DEV: start glimmer-ification and optimisations of chat plugin (#19531)
Note this is a very large PR, and some of it could have been splited, but keeping it one chunk made it to merge conflicts and to revert if necessary. Actual new code logic is also not that much, as most of the changes are removing js tests, adding system specs or moving things around.
To make it possible this commit is doing the following changes:
- converting (and adding new) existing js acceptances tests into system tests. This change was necessary to ensure as little regressions as possible while changing paradigm
- moving away from store. Using glimmer and tracked properties requires to have class objects everywhere and as a result works well with models. However store/adapters are suffering from many bugs and limitations. As a workaround the `chat-api` and `chat-channels-manager` are an answer to this problem by encapsulating backend calls and frontend storage logic; while still using js models.
- dropping `appEvents` as much as possible. Using tracked properties and a better local storage of channel models, allows to be much more reactive and doesn’t require arbitrary manual updates everywhere in the app.
- while working on replacing store, the existing work of a chat api (backend) has been continued to support more cases.
- removing code from the `chat` service to separate concerns, `chat-subscriptions-manager` and `chat-channels-manager`, being the largest examples of where the code has been rewritten/moved.
Future wok:
- improve behavior when closing/deleting a channel, it's already slightly buggy on live, it's rare enough that it's not a big issue, but should be improved
- improve page objects used in chat
- move more endpoints to the API
- finish temporarily skipped tests
- extract more code from the `chat` service
- use glimmer for `chat-messages`
- separate concerns in `chat-live-pane`
- eventually add js tests for `chat-api`, `chat-channels-manager` and `chat-subscriptions-manager`, they are indirectly heavy tested through system tests but it would be nice to at least test the public API
<!-- NOTE: All pull requests should have tests (rspec in Ruby, qunit in JavaScript). If your code does not include test coverage, please include an explanation of why it was omitted. -->
2022-12-21 20:21:02 +08:00
|
|
|
|
|
|
|
|
|
find("body").send_keys("b")
|
|
|
|
|
|
2023-04-25 16:23:03 +08:00
|
|
|
|
expect(find(".chat-composer__input").value).to eq("bb")
|
DEV: start glimmer-ification and optimisations of chat plugin (#19531)
Note this is a very large PR, and some of it could have been splited, but keeping it one chunk made it to merge conflicts and to revert if necessary. Actual new code logic is also not that much, as most of the changes are removing js tests, adding system specs or moving things around.
To make it possible this commit is doing the following changes:
- converting (and adding new) existing js acceptances tests into system tests. This change was necessary to ensure as little regressions as possible while changing paradigm
- moving away from store. Using glimmer and tracked properties requires to have class objects everywhere and as a result works well with models. However store/adapters are suffering from many bugs and limitations. As a workaround the `chat-api` and `chat-channels-manager` are an answer to this problem by encapsulating backend calls and frontend storage logic; while still using js models.
- dropping `appEvents` as much as possible. Using tracked properties and a better local storage of channel models, allows to be much more reactive and doesn’t require arbitrary manual updates everywhere in the app.
- while working on replacing store, the existing work of a chat api (backend) has been continued to support more cases.
- removing code from the `chat` service to separate concerns, `chat-subscriptions-manager` and `chat-channels-manager`, being the largest examples of where the code has been rewritten/moved.
Future wok:
- improve behavior when closing/deleting a channel, it's already slightly buggy on live, it's rare enough that it's not a big issue, but should be improved
- improve page objects used in chat
- move more endpoints to the API
- finish temporarily skipped tests
- extract more code from the `chat` service
- use glimmer for `chat-messages`
- separate concerns in `chat-live-pane`
- eventually add js tests for `chat-api`, `chat-channels-manager` and `chat-subscriptions-manager`, they are indirectly heavy tested through system tests but it would be nice to at least test the public API
<!-- NOTE: All pull requests should have tests (rspec in Ruby, qunit in JavaScript). If your code does not include test coverage, please include an explanation of why it was omitted. -->
2022-12-21 20:21:02 +08:00
|
|
|
|
|
|
|
|
|
find("body").send_keys(:enter) # special case
|
|
|
|
|
|
2023-04-25 16:23:03 +08:00
|
|
|
|
expect(find(".chat-composer__input").value).to eq("bb")
|
DEV: start glimmer-ification and optimisations of chat plugin (#19531)
Note this is a very large PR, and some of it could have been splited, but keeping it one chunk made it to merge conflicts and to revert if necessary. Actual new code logic is also not that much, as most of the changes are removing js tests, adding system specs or moving things around.
To make it possible this commit is doing the following changes:
- converting (and adding new) existing js acceptances tests into system tests. This change was necessary to ensure as little regressions as possible while changing paradigm
- moving away from store. Using glimmer and tracked properties requires to have class objects everywhere and as a result works well with models. However store/adapters are suffering from many bugs and limitations. As a workaround the `chat-api` and `chat-channels-manager` are an answer to this problem by encapsulating backend calls and frontend storage logic; while still using js models.
- dropping `appEvents` as much as possible. Using tracked properties and a better local storage of channel models, allows to be much more reactive and doesn’t require arbitrary manual updates everywhere in the app.
- while working on replacing store, the existing work of a chat api (backend) has been continued to support more cases.
- removing code from the `chat` service to separate concerns, `chat-subscriptions-manager` and `chat-channels-manager`, being the largest examples of where the code has been rewritten/moved.
Future wok:
- improve behavior when closing/deleting a channel, it's already slightly buggy on live, it's rare enough that it's not a big issue, but should be improved
- improve page objects used in chat
- move more endpoints to the API
- finish temporarily skipped tests
- extract more code from the `chat` service
- use glimmer for `chat-messages`
- separate concerns in `chat-live-pane`
- eventually add js tests for `chat-api`, `chat-channels-manager` and `chat-subscriptions-manager`, they are indirectly heavy tested through system tests but it would be nice to at least test the public API
<!-- NOTE: All pull requests should have tests (rspec in Ruby, qunit in JavaScript). If your code does not include test coverage, please include an explanation of why it was omitted. -->
2022-12-21 20:21:02 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
2023-04-26 16:05:48 +08:00
|
|
|
|
|
|
|
|
|
context "when pasting link over selected text" do
|
|
|
|
|
before do
|
|
|
|
|
channel_1.add(current_user)
|
|
|
|
|
sign_in(current_user)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "outputs a markdown link" do
|
|
|
|
|
modifier = /darwin/i =~ RbConfig::CONFIG["host_os"] ? :command : :control
|
|
|
|
|
select_text = <<-JS
|
|
|
|
|
const element = document.querySelector(arguments[0]);
|
|
|
|
|
element.focus();
|
|
|
|
|
element.setSelectionRange(0, element.value.length)
|
|
|
|
|
JS
|
|
|
|
|
|
|
|
|
|
chat.visit_channel(channel_1)
|
|
|
|
|
|
|
|
|
|
find("body").send_keys("https://www.discourse.org")
|
|
|
|
|
page.execute_script(select_text, ".chat-composer__input")
|
|
|
|
|
|
|
|
|
|
page.send_keys [modifier, "c"]
|
|
|
|
|
page.send_keys [:backspace]
|
|
|
|
|
|
|
|
|
|
find("body").send_keys("discourse")
|
|
|
|
|
page.execute_script(select_text, ".chat-composer__input")
|
|
|
|
|
|
|
|
|
|
page.send_keys [modifier, "v"]
|
|
|
|
|
|
|
|
|
|
expect(find(".chat-composer__input").value).to eq("[discourse](https://www.discourse.org)")
|
|
|
|
|
end
|
|
|
|
|
end
|
2023-04-26 23:35:35 +08:00
|
|
|
|
|
|
|
|
|
context "when posting a message with length equal to minimum length" do
|
|
|
|
|
before do
|
|
|
|
|
SiteSetting.chat_minimum_message_length = 1
|
|
|
|
|
channel_1.add(current_user)
|
|
|
|
|
sign_in(current_user)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "works" do
|
|
|
|
|
chat.visit_channel(channel_1)
|
|
|
|
|
find("body").send_keys("1")
|
|
|
|
|
channel.click_send_message
|
|
|
|
|
|
|
|
|
|
expect(channel).to have_message(text: "1")
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context "when posting a message with length superior to minimum length" do
|
|
|
|
|
before do
|
|
|
|
|
SiteSetting.chat_minimum_message_length = 2
|
|
|
|
|
channel_1.add(current_user)
|
|
|
|
|
sign_in(current_user)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "doesn’t allow to send" do
|
|
|
|
|
chat.visit_channel(channel_1)
|
|
|
|
|
find("body").send_keys("1")
|
|
|
|
|
|
2023-04-28 16:24:49 +08:00
|
|
|
|
expect(page).to have_css(".chat-composer.is-send-disabled")
|
2023-04-26 23:35:35 +08:00
|
|
|
|
end
|
|
|
|
|
end
|
DEV: start glimmer-ification and optimisations of chat plugin (#19531)
Note this is a very large PR, and some of it could have been splited, but keeping it one chunk made it to merge conflicts and to revert if necessary. Actual new code logic is also not that much, as most of the changes are removing js tests, adding system specs or moving things around.
To make it possible this commit is doing the following changes:
- converting (and adding new) existing js acceptances tests into system tests. This change was necessary to ensure as little regressions as possible while changing paradigm
- moving away from store. Using glimmer and tracked properties requires to have class objects everywhere and as a result works well with models. However store/adapters are suffering from many bugs and limitations. As a workaround the `chat-api` and `chat-channels-manager` are an answer to this problem by encapsulating backend calls and frontend storage logic; while still using js models.
- dropping `appEvents` as much as possible. Using tracked properties and a better local storage of channel models, allows to be much more reactive and doesn’t require arbitrary manual updates everywhere in the app.
- while working on replacing store, the existing work of a chat api (backend) has been continued to support more cases.
- removing code from the `chat` service to separate concerns, `chat-subscriptions-manager` and `chat-channels-manager`, being the largest examples of where the code has been rewritten/moved.
Future wok:
- improve behavior when closing/deleting a channel, it's already slightly buggy on live, it's rare enough that it's not a big issue, but should be improved
- improve page objects used in chat
- move more endpoints to the API
- finish temporarily skipped tests
- extract more code from the `chat` service
- use glimmer for `chat-messages`
- separate concerns in `chat-live-pane`
- eventually add js tests for `chat-api`, `chat-channels-manager` and `chat-subscriptions-manager`, they are indirectly heavy tested through system tests but it would be nice to at least test the public API
<!-- NOTE: All pull requests should have tests (rspec in Ruby, qunit in JavaScript). If your code does not include test coverage, please include an explanation of why it was omitted. -->
2022-12-21 20:21:02 +08:00
|
|
|
|
end
|