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
|
|
|
|
|
2023-06-07 09:26:58 +08:00
|
|
|
RSpec.describe "Shortcuts | sidebar", type: :system do
|
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
|
|
|
fab!(:current_user) { Fabricate(:admin) }
|
|
|
|
|
|
|
|
let(:chat) { PageObjects::Pages::Chat.new }
|
2024-11-21 05:24:26 +08:00
|
|
|
let(:sidebar_page) { PageObjects::Pages::Sidebar.new }
|
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
|
|
|
|
|
|
|
before do
|
|
|
|
SiteSetting.navigation_menu = "sidebar"
|
|
|
|
chat_system_bootstrap
|
|
|
|
sign_in(current_user)
|
|
|
|
end
|
|
|
|
|
2024-11-18 08:18:58 +08:00
|
|
|
context "when using Alt+Up/Down arrows" do
|
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
|
|
|
fab!(:channel_1) { Fabricate(:chat_channel) }
|
|
|
|
fab!(:dm_channel_1) { Fabricate(:direct_message_channel, users: [current_user]) }
|
|
|
|
|
|
|
|
before { channel_1.add(current_user) }
|
|
|
|
|
|
|
|
context "when on homepage" do
|
|
|
|
it "does nothing" do
|
|
|
|
visit("/")
|
|
|
|
find("body").send_keys(%i[alt arrow_down])
|
|
|
|
|
2024-11-21 05:24:26 +08:00
|
|
|
expect(sidebar_page).to have_no_active_channel(channel_1)
|
|
|
|
expect(sidebar_page).to have_no_active_channel(dm_channel_1)
|
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
|
|
|
|
|
|
|
|
context "when on chat page" do
|
|
|
|
it "navigates through the channels" do
|
|
|
|
chat.visit_channel(channel_1)
|
2024-11-21 05:24:26 +08:00
|
|
|
expect(sidebar_page).to have_active_channel(channel_1)
|
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(%i[alt arrow_down])
|
|
|
|
|
2024-11-21 05:24:26 +08:00
|
|
|
expect(sidebar_page).to have_active_channel(dm_channel_1)
|
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(%i[alt arrow_down])
|
|
|
|
|
2024-11-21 05:24:26 +08:00
|
|
|
expect(sidebar_page).to have_active_channel(channel_1)
|
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(%i[alt arrow_up])
|
|
|
|
|
2024-11-21 05:24:26 +08:00
|
|
|
expect(sidebar_page).to have_active_channel(dm_channel_1)
|
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
|
2024-11-18 08:18:58 +08:00
|
|
|
|
|
|
|
context "when using Alt+Shift+Up/Down arrows" do
|
2024-11-21 05:24:26 +08:00
|
|
|
fab!(:channel_1) { Fabricate(:chat_channel, name: "Channel 1") }
|
|
|
|
fab!(:channel_2) { Fabricate(:chat_channel, name: "Channel 2") }
|
|
|
|
fab!(:channel_3) { Fabricate(:chat_channel, name: "Channel 3") }
|
2024-11-21 08:41:02 +08:00
|
|
|
fab!(:channel_4) { Fabricate(:chat_channel, name: "Channel 4") }
|
2024-11-18 08:18:58 +08:00
|
|
|
fab!(:dm_channel_1) { Fabricate(:direct_message_channel, users: [current_user]) }
|
2024-11-21 05:24:26 +08:00
|
|
|
fab!(:other_user) { Fabricate(:user) }
|
|
|
|
fab!(:dm_channel_2) { Fabricate(:direct_message_channel, users: [current_user, other_user]) }
|
2024-11-18 08:18:58 +08:00
|
|
|
|
|
|
|
before do
|
|
|
|
channel_1.add(current_user)
|
|
|
|
channel_2.add(current_user)
|
2024-11-21 05:24:26 +08:00
|
|
|
channel_3.add(current_user)
|
2024-11-21 08:41:02 +08:00
|
|
|
channel_4.add(current_user)
|
2024-11-18 08:18:58 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
context "when on homepage" do
|
|
|
|
it "does nothing" do
|
|
|
|
visit("/")
|
|
|
|
find("body").send_keys(%i[alt shift arrow_down])
|
|
|
|
|
2024-11-21 05:24:26 +08:00
|
|
|
expect(sidebar_page).to have_no_active_channel(channel_1)
|
|
|
|
expect(sidebar_page).to have_no_active_channel(channel_2)
|
|
|
|
expect(sidebar_page).to have_no_active_channel(dm_channel_1)
|
|
|
|
expect(sidebar_page).to have_no_active_channel(dm_channel_2)
|
2024-11-18 08:18:58 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when on chat page" do
|
|
|
|
it "does nothing when no channels have activity" do
|
|
|
|
chat.visit_channel(channel_1)
|
2024-11-21 05:24:26 +08:00
|
|
|
expect(sidebar_page).to have_active_channel(channel_1)
|
2024-11-18 08:18:58 +08:00
|
|
|
|
|
|
|
find("body").send_keys(%i[alt shift arrow_down])
|
|
|
|
|
2024-11-21 05:24:26 +08:00
|
|
|
expect(sidebar_page).to have_active_channel(channel_1)
|
2024-11-18 08:18:58 +08:00
|
|
|
|
|
|
|
find("body").send_keys(%i[alt shift arrow_down])
|
|
|
|
|
2024-11-21 05:24:26 +08:00
|
|
|
expect(sidebar_page).to have_active_channel(channel_1)
|
2024-11-18 08:18:58 +08:00
|
|
|
|
|
|
|
find("body").send_keys(%i[alt shift arrow_up])
|
|
|
|
|
2024-11-21 05:24:26 +08:00
|
|
|
expect(sidebar_page).to have_active_channel(channel_1)
|
2024-11-18 08:18:58 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "navigates through the channels with activity" do
|
2024-11-21 05:24:26 +08:00
|
|
|
chat.visit_channel(channel_1)
|
|
|
|
expect(sidebar_page).to have_active_channel(channel_1)
|
|
|
|
|
2024-11-18 08:18:58 +08:00
|
|
|
Fabricate(:chat_message, chat_channel: channel_2, message: "hello!", use_service: true)
|
2024-11-21 05:24:26 +08:00
|
|
|
expect(sidebar_page).to have_unread_channel(channel_2)
|
2024-11-18 08:18:58 +08:00
|
|
|
|
|
|
|
Fabricate(
|
|
|
|
:chat_message,
|
|
|
|
chat_channel: dm_channel_2,
|
|
|
|
message: "hello here!",
|
|
|
|
use_service: true,
|
|
|
|
)
|
2024-11-21 05:24:26 +08:00
|
|
|
expect(sidebar_page).to have_unread_channel(dm_channel_2)
|
2024-11-18 08:18:58 +08:00
|
|
|
|
|
|
|
find("body").send_keys(%i[alt shift arrow_down])
|
|
|
|
|
2024-11-21 05:24:26 +08:00
|
|
|
expect(sidebar_page).to have_active_channel(channel_2)
|
|
|
|
expect(sidebar_page).to have_no_unread_channel(channel_2)
|
2024-11-18 08:18:58 +08:00
|
|
|
|
|
|
|
find("body").send_keys(%i[alt shift arrow_down])
|
|
|
|
|
2024-11-21 05:24:26 +08:00
|
|
|
expect(sidebar_page).to have_active_channel(dm_channel_2)
|
|
|
|
expect(sidebar_page).to have_no_unread_channel(dm_channel_2)
|
2024-11-18 08:18:58 +08:00
|
|
|
|
|
|
|
Fabricate(
|
|
|
|
:chat_message,
|
|
|
|
chat_channel: channel_1,
|
|
|
|
message: "hello again!",
|
|
|
|
use_service: true,
|
|
|
|
)
|
2024-11-21 05:24:26 +08:00
|
|
|
expect(sidebar_page).to have_unread_channel(channel_1)
|
2024-11-18 08:18:58 +08:00
|
|
|
|
|
|
|
find("body").send_keys(%i[alt shift arrow_up])
|
|
|
|
|
2024-11-21 05:24:26 +08:00
|
|
|
expect(sidebar_page).to have_active_channel(channel_1)
|
|
|
|
expect(sidebar_page).to have_no_unread_channel(channel_1)
|
2024-11-18 08:18:58 +08:00
|
|
|
|
|
|
|
Fabricate(:chat_message, chat_channel: dm_channel_1, message: "bye now!", use_service: true)
|
2024-11-21 05:24:26 +08:00
|
|
|
expect(sidebar_page).to have_unread_channel(dm_channel_1)
|
2024-11-18 08:18:58 +08:00
|
|
|
|
|
|
|
find("body").send_keys(%i[alt shift arrow_up])
|
|
|
|
|
2024-11-21 05:24:26 +08:00
|
|
|
expect(sidebar_page).to have_active_channel(dm_channel_1)
|
|
|
|
expect(sidebar_page).to have_no_unread_channel(dm_channel_1)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "remembers where the current channel is, even if that channel is unread" do
|
2024-11-21 08:41:02 +08:00
|
|
|
chat.visit_channel(channel_3)
|
|
|
|
expect(sidebar_page).to have_active_channel(channel_3)
|
|
|
|
|
|
|
|
Fabricate(:chat_message, chat_channel: channel_2, message: "hello!", use_service: true)
|
|
|
|
expect(sidebar_page).to have_unread_channel(channel_2)
|
|
|
|
|
|
|
|
Fabricate(:chat_message, chat_channel: channel_4, message: "yes, hello!", use_service: true)
|
|
|
|
expect(sidebar_page).to have_unread_channel(channel_4)
|
|
|
|
|
|
|
|
find("body").send_keys(%i[alt shift arrow_down])
|
|
|
|
|
|
|
|
expect(sidebar_page).to have_active_channel(channel_4)
|
|
|
|
expect(sidebar_page).to have_no_unread_channel(channel_4)
|
|
|
|
|
|
|
|
Fabricate(
|
|
|
|
:chat_message,
|
|
|
|
chat_channel: channel_3,
|
|
|
|
message: "hello, here, too!",
|
|
|
|
use_service: true,
|
|
|
|
)
|
|
|
|
expect(sidebar_page).to have_unread_channel(channel_3)
|
|
|
|
|
|
|
|
find("body").send_keys(%i[alt shift arrow_up])
|
|
|
|
|
|
|
|
expect(sidebar_page).to have_active_channel(channel_3)
|
|
|
|
expect(sidebar_page).to have_no_unread_channel(channel_3)
|
|
|
|
|
|
|
|
Fabricate(
|
|
|
|
:chat_message,
|
|
|
|
chat_channel: channel_4,
|
|
|
|
message: "okay, byebye!",
|
|
|
|
use_service: true,
|
|
|
|
)
|
|
|
|
expect(sidebar_page).to have_unread_channel(channel_4)
|
|
|
|
|
|
|
|
find("body").send_keys(%i[alt shift arrow_up])
|
|
|
|
|
|
|
|
expect(sidebar_page).to have_active_channel(channel_2)
|
|
|
|
expect(sidebar_page).to have_no_unread_channel(channel_2)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "handles the shortcut being pressed quickly" do
|
2024-11-21 05:24:26 +08:00
|
|
|
chat.visit_channel(channel_2)
|
|
|
|
expect(sidebar_page).to have_active_channel(channel_2)
|
|
|
|
|
|
|
|
Fabricate(:chat_message, chat_channel: channel_1, message: "hello!", use_service: true)
|
|
|
|
expect(sidebar_page).to have_unread_channel(channel_1)
|
|
|
|
|
2024-11-21 08:41:02 +08:00
|
|
|
Fabricate(:chat_message, chat_channel: channel_4, message: "howdy!", use_service: true)
|
|
|
|
expect(sidebar_page).to have_unread_channel(channel_4)
|
2024-11-21 05:24:26 +08:00
|
|
|
|
2024-11-21 08:41:02 +08:00
|
|
|
find("body").send_keys(%i[alt shift arrow_up])
|
2024-11-21 05:24:26 +08:00
|
|
|
find("body").send_keys(%i[alt shift arrow_down])
|
|
|
|
|
2024-11-21 08:41:02 +08:00
|
|
|
expect(sidebar_page).to have_active_channel(channel_4)
|
2024-11-18 08:18:58 +08:00
|
|
|
end
|
|
|
|
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
|