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 "Channel - Info - Settings page", 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
|
|
|
|
let(:chat_page) { PageObjects::Pages::Chat.new }
|
|
|
|
|
fab!(:current_user) { Fabricate(:user) }
|
|
|
|
|
fab!(:channel_1) { Fabricate(:category_channel) }
|
|
|
|
|
|
|
|
|
|
before do
|
|
|
|
|
chat_system_bootstrap
|
|
|
|
|
sign_in(current_user)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context "as unauthorized user" do
|
|
|
|
|
before { SiteSetting.chat_allowed_groups = Fabricate(:group).id }
|
|
|
|
|
|
|
|
|
|
it "redirects to home page" do
|
|
|
|
|
chat_page.visit_channel_settings(channel_1)
|
|
|
|
|
|
|
|
|
|
expect(page).to have_current_path("/latest")
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context "as authorized user" do
|
|
|
|
|
context "as not member" do
|
|
|
|
|
it "redirects to about tab" do
|
|
|
|
|
chat_page.visit_channel_settings(channel_1)
|
|
|
|
|
|
2023-01-27 20:58:12 +08:00
|
|
|
|
expect(page).to have_current_path("/chat/c/#{channel_1.slug}/#{channel_1.id}/info/about")
|
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
|
|
|
|
|
|
|
|
|
|
it "doesn’t have settings tab" do
|
|
|
|
|
chat_page.visit_channel_settings(channel_1)
|
|
|
|
|
|
|
|
|
|
expect(page).to have_no_selector(".chat-tabs-list__item[aria-controls='settings-tab']")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context "as an admin" do
|
|
|
|
|
before { sign_in(Fabricate(:admin)) }
|
|
|
|
|
|
|
|
|
|
it "shows settings tab" do
|
|
|
|
|
chat_page.visit_channel_settings(channel_1)
|
|
|
|
|
|
|
|
|
|
expect(page).to have_selector(".chat-tabs-list__item[aria-controls='settings-tab']")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "can navigate to settings tab" do
|
|
|
|
|
chat_page.visit_channel_settings(channel_1)
|
|
|
|
|
|
|
|
|
|
expect(page).to have_current_path(
|
2023-01-27 20:58:12 +08:00
|
|
|
|
"/chat/c/#{channel_1.slug}/#{channel_1.id}/info/settings",
|
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 "as a member" do
|
|
|
|
|
before { channel_1.add(current_user) }
|
|
|
|
|
|
|
|
|
|
context "when visitng the settings of a recently joined channel" do
|
|
|
|
|
fab!(:channel_2) { Fabricate(:category_channel) }
|
|
|
|
|
|
|
|
|
|
it "is correctly populated" do
|
|
|
|
|
chat_page.visit_browse
|
|
|
|
|
find(
|
|
|
|
|
".chat-channel-card[data-channel-id='#{channel_2.id}'] .toggle-channel-membership-button",
|
|
|
|
|
).click
|
|
|
|
|
|
|
|
|
|
expect(
|
|
|
|
|
page.find(".chat-channel-card[data-channel-id='#{channel_2.id}']"),
|
|
|
|
|
).to have_content(I18n.t("js.chat.joined").upcase)
|
|
|
|
|
|
|
|
|
|
find(
|
|
|
|
|
".chat-channel-card[data-channel-id='#{channel_2.id}'] .chat-channel-card__setting",
|
|
|
|
|
).click
|
|
|
|
|
|
|
|
|
|
expect(page).to have_content(I18n.t("js.chat.notification_levels.mention"))
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "can mute channel" do
|
|
|
|
|
chat_page.visit_channel_settings(channel_1)
|
|
|
|
|
membership = channel_1.membership_for(current_user)
|
|
|
|
|
|
|
|
|
|
expect {
|
|
|
|
|
find(".channel-settings-view__muted-selector").click
|
|
|
|
|
find(".channel-settings-view__muted-selector [data-name='On']").click
|
|
|
|
|
expect(page).to have_content(I18n.t("js.chat.settings.saved"))
|
|
|
|
|
}.to change { membership.reload.muted }.from(false).to(true)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "can change desktop notification level" do
|
|
|
|
|
chat_page.visit_channel_settings(channel_1)
|
|
|
|
|
membership = channel_1.membership_for(current_user)
|
|
|
|
|
|
|
|
|
|
expect {
|
|
|
|
|
find(".channel-settings-view__desktop-notification-level-selector").click
|
|
|
|
|
find(
|
|
|
|
|
".channel-settings-view__desktop-notification-level-selector [data-name='Never']",
|
|
|
|
|
).click
|
|
|
|
|
expect(page).to have_content(I18n.t("js.chat.settings.saved"))
|
|
|
|
|
}.to change { membership.reload.desktop_notification_level }.from("mention").to("never")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "can change mobile notification level" do
|
|
|
|
|
chat_page.visit_channel_settings(channel_1)
|
|
|
|
|
membership = channel_1.membership_for(current_user)
|
|
|
|
|
|
|
|
|
|
expect {
|
|
|
|
|
find(".channel-settings-view__mobile-notification-level-selector").click
|
|
|
|
|
find(
|
|
|
|
|
".channel-settings-view__mobile-notification-level-selector [data-name='Never']",
|
|
|
|
|
).click
|
|
|
|
|
expect(page).to have_content(I18n.t("js.chat.settings.saved"))
|
|
|
|
|
}.to change { membership.reload.mobile_notification_level }.from("mention").to("never")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "doesn’t show admin section" do
|
|
|
|
|
chat_page.visit_channel_settings(channel_1)
|
|
|
|
|
|
|
|
|
|
expect(page).to have_no_content(I18n.t("js.chat.settings.admin_title"))
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context "as an admin" do
|
|
|
|
|
before { sign_in(Fabricate(:admin)) }
|
|
|
|
|
|
|
|
|
|
it "shows admin section" do
|
|
|
|
|
chat_page.visit_channel_settings(channel_1)
|
|
|
|
|
|
|
|
|
|
expect(page).to have_content(I18n.t("js.chat.settings.admin_title"))
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "can change auto join setting" do
|
|
|
|
|
chat_page.visit_channel_settings(channel_1)
|
|
|
|
|
|
|
|
|
|
expect {
|
|
|
|
|
find(".channel-settings-view__auto-join-selector").click
|
|
|
|
|
find(".channel-settings-view__auto-join-selector [data-name='Yes']").click
|
|
|
|
|
find("#dialog-holder .btn-primary").click
|
|
|
|
|
expect(page).to have_content(I18n.t("js.chat.settings.saved"))
|
|
|
|
|
}.to change { channel_1.reload.auto_join_users }.from(false).to(true)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "can change allow channel wide mentions" do
|
|
|
|
|
chat_page.visit_channel_settings(channel_1)
|
|
|
|
|
|
|
|
|
|
expect {
|
|
|
|
|
find(".channel-settings-view__channel-wide-mentions-selector").click
|
|
|
|
|
find(".channel-settings-view__channel-wide-mentions-selector [data-name='No']").click
|
|
|
|
|
expect(page).to have_content(I18n.t("js.chat.settings.saved"))
|
|
|
|
|
}.to change { channel_1.reload.allow_channel_wide_mentions }.from(true).to(false)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "can close channel" do
|
|
|
|
|
chat_page.visit_channel_settings(channel_1)
|
|
|
|
|
|
|
|
|
|
expect {
|
|
|
|
|
click_button(I18n.t("js.chat.channel_settings.close_channel"))
|
|
|
|
|
find("#chat-channel-toggle-btn").click
|
|
|
|
|
expect(page).to have_content(I18n.t("js.chat.channel_status.closed_header"))
|
|
|
|
|
}.to change { channel_1.reload.status }.from("open").to("closed")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
it "can delete channel" do
|
|
|
|
|
chat_page.visit_channel_settings(channel_1)
|
|
|
|
|
|
|
|
|
|
click_button(I18n.t("js.chat.channel_settings.delete_channel"))
|
|
|
|
|
fill_in("channel-delete-confirm-name", with: channel_1.title)
|
|
|
|
|
find_button("chat-confirm-delete-channel", disabled: false).click
|
|
|
|
|
expect(page).to have_content(I18n.t("js.chat.channel_delete.process_started"))
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
context "when confirmation name is wrong" do
|
|
|
|
|
it "doesn’t delete submission" do
|
|
|
|
|
chat_page.visit_channel_settings(channel_1)
|
|
|
|
|
find(".delete-btn").click
|
|
|
|
|
fill_in("channel-delete-confirm-name", with: channel_1.title + "wrong")
|
|
|
|
|
|
|
|
|
|
expect(page).to have_button("chat-confirm-delete-channel", disabled: true)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|