2022-11-04 10:06:24 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2023-06-06 21:26:58 -04:00
|
|
|
RSpec.describe "Navigation", type: :system do
|
2023-11-09 17:47:59 -05:00
|
|
|
fab!(:category)
|
|
|
|
fab!(:topic)
|
2022-11-07 03:04:43 -05:00
|
|
|
fab!(:post) { Fabricate(:post, topic: topic) }
|
2023-06-27 19:58:47 -04:00
|
|
|
fab!(:current_user) { Fabricate(:admin) }
|
2023-11-09 17:47:59 -05:00
|
|
|
fab!(:category_channel)
|
2022-11-11 00:39:15 -05:00
|
|
|
fab!(:category_channel_2) { Fabricate(:category_channel) }
|
2022-11-04 10:06:24 -04:00
|
|
|
fab!(:message) { Fabricate(:chat_message, chat_channel: category_channel) }
|
2022-11-07 08:48:18 -05:00
|
|
|
let(:chat_page) { PageObjects::Pages::Chat.new }
|
2023-06-27 19:58:47 -04:00
|
|
|
let(:thread_page) { PageObjects::Pages::ChatThread.new }
|
|
|
|
let(:thread_list_page) { PageObjects::Components::Chat::ThreadList.new }
|
|
|
|
let(:channel_page) { PageObjects::Pages::ChatChannel.new }
|
|
|
|
let(:side_panel_page) { PageObjects::Pages::ChatSidePanel.new }
|
2022-11-08 17:58:11 -05:00
|
|
|
let(:sidebar_page) { PageObjects::Pages::Sidebar.new }
|
2023-07-10 21:40:37 -04:00
|
|
|
let(:sidebar_component) { PageObjects::Components::NavigationMenu::Sidebar.new }
|
2022-11-11 00:39:15 -05:00
|
|
|
let(:chat_drawer_page) { PageObjects::Pages::ChatDrawer.new }
|
2022-11-04 10:06:24 -04:00
|
|
|
|
|
|
|
before do
|
2024-03-18 03:35:07 -04:00
|
|
|
current_user.upsert_custom_fields(::Chat::LAST_CHAT_CHANNEL_ID => category_channel.id)
|
2023-06-27 19:58:47 -04:00
|
|
|
chat_system_bootstrap(current_user, [category_channel, category_channel_2])
|
2023-08-18 14:33:07 -04:00
|
|
|
current_user.user_option.update(
|
|
|
|
chat_separate_sidebar_mode: UserOption.chat_separate_sidebar_modes[:never],
|
|
|
|
)
|
2023-06-27 19:58:47 -04:00
|
|
|
sign_in(current_user)
|
2022-11-04 10:06:24 -04:00
|
|
|
end
|
|
|
|
|
2022-11-25 09:12:32 -05:00
|
|
|
context "when clicking chat icon and drawer is viewing channel" do
|
|
|
|
it "navigates to index" do
|
2022-12-22 11:03:27 -05:00
|
|
|
visit("/")
|
|
|
|
|
2022-11-25 09:12:32 -05:00
|
|
|
chat_page.open_from_header
|
|
|
|
chat_drawer_page.open_channel(category_channel_2)
|
|
|
|
chat_page.open_from_header
|
|
|
|
|
|
|
|
expect(page).to have_content(I18n.t("js.chat.direct_messages.title"))
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when clicking chat icon on mobile and is viewing channel" do
|
2024-01-17 04:12:55 -05:00
|
|
|
it "navigates to channels tab", mobile: true do
|
2022-11-25 09:12:32 -05:00
|
|
|
chat_page.visit_channel(category_channel_2)
|
|
|
|
chat_page.open_from_header
|
|
|
|
|
2024-01-17 04:12:55 -05:00
|
|
|
expect(page).to have_current_path("/chat/channels")
|
2022-11-25 09:12:32 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2023-12-26 04:36:26 -05:00
|
|
|
context "when clicking chat icon on mobile" do
|
|
|
|
it "has the chat title with link to chat index", mobile: true do
|
|
|
|
visit("/")
|
|
|
|
chat_page.open_from_header
|
|
|
|
|
|
|
|
expect(page).to have_title(I18n.t("js.chat.heading"))
|
|
|
|
expect(page).to have_css("a.c-heading[href='#{chat_path}']")
|
|
|
|
end
|
|
|
|
|
2023-12-29 03:55:12 -05:00
|
|
|
it "has the back to forum link with last visited url", mobile: true do
|
2023-12-26 04:36:26 -05:00
|
|
|
visit("/")
|
2023-12-29 03:55:12 -05:00
|
|
|
click_link(topic.title)
|
|
|
|
|
|
|
|
expect(page).to have_css(".fancy-title")
|
2023-12-26 04:36:26 -05:00
|
|
|
|
|
|
|
chat_page.open_from_header
|
|
|
|
|
2023-12-29 03:55:12 -05:00
|
|
|
expect(page).to have_title(I18n.t("js.chat.heading"))
|
2023-12-26 04:36:26 -05:00
|
|
|
expect(page).to have_css(".back-to-forum[href='#{topic.relative_url}']")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "hides the search icon and hamburger icon", mobile: true do
|
|
|
|
visit("/")
|
|
|
|
chat_page.open_from_header
|
|
|
|
|
|
|
|
expect(page).to have_no_css(".search-dropdown")
|
|
|
|
expect(page).to have_no_css(".hamburger-dropdown")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-11-04 10:06:24 -04:00
|
|
|
context "when visiting /chat" do
|
2022-11-07 03:04:43 -05:00
|
|
|
it "opens full page" do
|
2022-11-11 00:39:15 -05:00
|
|
|
chat_page.open
|
2022-11-04 10:06:24 -04:00
|
|
|
|
|
|
|
expect(page).to have_current_path(
|
2023-01-27 07:58:12 -05:00
|
|
|
chat.channel_path(category_channel.slug, category_channel.id),
|
2022-11-04 10:06:24 -04:00
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
2022-11-07 03:04:43 -05:00
|
|
|
|
2024-02-05 00:26:01 -05:00
|
|
|
context "when visiting mobile only routes on desktop" do
|
2024-03-18 03:35:07 -04:00
|
|
|
it "redirects /chat/channels to browse" do
|
2024-02-05 00:26:01 -05:00
|
|
|
visit("/chat/channels")
|
|
|
|
|
|
|
|
expect(page).to have_current_path(
|
|
|
|
chat.channel_path(category_channel.slug, category_channel.id),
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-11-07 03:04:43 -05:00
|
|
|
context "when opening chat" do
|
|
|
|
it "opens the drawer by default" do
|
|
|
|
visit("/")
|
2022-11-07 08:48:18 -05:00
|
|
|
chat_page.open_from_header
|
2022-11-07 03:04:43 -05:00
|
|
|
|
2022-11-25 08:15:38 -05:00
|
|
|
expect(page).to have_css(".chat-drawer.is-expanded")
|
2022-11-07 03:04:43 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when opening chat with full page as preferred mode" do
|
|
|
|
it "opens the full page" do
|
|
|
|
visit("/")
|
2022-11-07 08:48:18 -05:00
|
|
|
chat_page.open_from_header
|
2022-11-11 00:39:15 -05:00
|
|
|
chat_drawer_page.maximize
|
2022-11-07 03:04:43 -05:00
|
|
|
|
|
|
|
expect(page).to have_current_path(
|
2023-01-27 07:58:12 -05:00
|
|
|
chat.channel_path(category_channel.slug, category_channel.id),
|
2022-11-07 03:04:43 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
visit("/")
|
2022-11-07 08:48:18 -05:00
|
|
|
chat_page.open_from_header
|
2022-11-07 03:04:43 -05:00
|
|
|
|
|
|
|
expect(page).to have_current_path(
|
2023-01-27 07:58:12 -05:00
|
|
|
chat.channel_path(category_channel.slug, category_channel.id),
|
2022-11-07 03:04:43 -05:00
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when opening chat with drawer as preferred mode" do
|
|
|
|
it "opens the full page" do
|
2022-11-11 00:39:15 -05:00
|
|
|
chat_page.open
|
2022-11-07 08:48:18 -05:00
|
|
|
chat_page.minimize_full_page
|
2022-11-07 03:04:43 -05:00
|
|
|
|
2022-11-25 08:15:38 -05:00
|
|
|
expect(page).to have_css(".chat-drawer.is-expanded")
|
2022-11-07 03:04:43 -05:00
|
|
|
|
|
|
|
visit("/")
|
2022-11-07 08:48:18 -05:00
|
|
|
chat_page.open_from_header
|
2022-11-07 03:04:43 -05:00
|
|
|
|
2022-11-25 08:15:38 -05:00
|
|
|
expect(page).to have_css(".chat-drawer.is-expanded")
|
2022-11-07 03:04:43 -05:00
|
|
|
end
|
|
|
|
end
|
2022-11-07 08:48:18 -05:00
|
|
|
|
|
|
|
context "when collapsing full page with no previous state" do
|
|
|
|
it "redirects to home page" do
|
2022-11-11 00:39:15 -05:00
|
|
|
chat_page.open
|
2022-11-07 08:48:18 -05:00
|
|
|
chat_page.minimize_full_page
|
|
|
|
|
2024-04-11 08:23:07 -04:00
|
|
|
expect(page).to have_current_path("/latest")
|
2022-11-07 08:48:18 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when collapsing full page with previous state" do
|
2023-07-06 18:46:04 -04:00
|
|
|
it "redirects to previous state" do
|
2022-11-07 08:48:18 -05:00
|
|
|
visit("/t/-/#{topic.id}")
|
|
|
|
chat_page.open_from_header
|
2022-11-11 00:39:15 -05:00
|
|
|
chat_drawer_page.maximize
|
2022-11-07 08:48:18 -05:00
|
|
|
chat_page.minimize_full_page
|
|
|
|
|
|
|
|
expect(page).to have_current_path("/t/#{topic.slug}/#{topic.id}")
|
|
|
|
expect(page).to have_css(".chat-message-container[data-id='#{message.id}']")
|
|
|
|
end
|
|
|
|
end
|
2022-11-08 10:23:13 -05:00
|
|
|
|
2023-06-27 19:58:47 -04:00
|
|
|
context "when opening a thread" do
|
2023-08-24 09:22:51 -04:00
|
|
|
fab!(:thread) { Fabricate(:chat_thread, channel: category_channel, use_service: true) }
|
2023-06-27 19:58:47 -04:00
|
|
|
|
|
|
|
before do
|
|
|
|
category_channel.update!(threading_enabled: true)
|
2023-08-24 09:22:51 -04:00
|
|
|
Fabricate(:chat_message, thread: thread, use_service: true)
|
2023-06-27 19:58:47 -04:00
|
|
|
thread.add(current_user)
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when opening a thread from the thread list" do
|
2023-10-22 12:50:04 -04:00
|
|
|
xit "goes back to the thread list when clicking the back button" do
|
2024-07-30 23:04:05 -04:00
|
|
|
skip_on_ci!
|
2023-07-11 21:16:35 -04:00
|
|
|
|
2023-06-27 19:58:47 -04:00
|
|
|
visit("/chat")
|
|
|
|
chat_page.visit_channel(category_channel)
|
|
|
|
channel_page.open_thread_list
|
|
|
|
expect(thread_list_page).to have_loaded
|
|
|
|
thread_list_page.open_thread(thread)
|
|
|
|
expect(side_panel_page).to have_open_thread(thread)
|
2023-06-29 21:08:29 -04:00
|
|
|
expect(thread_page).to have_back_link_to_thread_list(category_channel)
|
2023-12-11 01:38:07 -05:00
|
|
|
thread_page.back
|
2023-07-05 19:08:59 -04:00
|
|
|
expect(page).to have_current_path("#{category_channel.relative_url}/t")
|
2023-06-27 19:58:47 -04:00
|
|
|
expect(thread_list_page).to have_loaded
|
|
|
|
end
|
|
|
|
|
|
|
|
context "for mobile" do
|
|
|
|
it "goes back to the thread list when clicking the back button", mobile: true do
|
2024-07-30 23:04:05 -04:00
|
|
|
skip_on_ci!
|
2023-07-11 21:16:35 -04:00
|
|
|
|
2023-06-27 19:58:47 -04:00
|
|
|
visit("/chat")
|
|
|
|
chat_page.visit_channel(category_channel)
|
|
|
|
channel_page.open_thread_list
|
|
|
|
expect(thread_list_page).to have_loaded
|
|
|
|
thread_list_page.open_thread(thread)
|
|
|
|
expect(side_panel_page).to have_open_thread(thread)
|
2023-06-29 21:08:29 -04:00
|
|
|
expect(thread_page).to have_back_link_to_thread_list(category_channel)
|
2023-12-11 01:38:07 -05:00
|
|
|
thread_page.back
|
2023-07-05 19:08:59 -04:00
|
|
|
expect(page).to have_current_path("#{category_channel.relative_url}/t")
|
2023-06-27 19:58:47 -04:00
|
|
|
expect(thread_list_page).to have_loaded
|
|
|
|
end
|
2023-12-11 07:44:50 -05:00
|
|
|
|
|
|
|
context "when there are unread threads" do
|
|
|
|
fab!(:thread_2) { Fabricate(:chat_thread, channel: category_channel, use_service: true) }
|
|
|
|
|
|
|
|
before { Fabricate(:chat_message, thread: thread_2, use_service: true) }
|
|
|
|
|
|
|
|
it "goes back to the thread list when clicking the back button", mobile: true do
|
2024-07-30 23:04:05 -04:00
|
|
|
skip_on_ci!
|
2023-12-19 03:27:09 -05:00
|
|
|
|
2023-12-11 07:44:50 -05:00
|
|
|
chat_page.visit_channel(category_channel)
|
|
|
|
channel_page.message_thread_indicator(thread.original_message).click
|
|
|
|
thread_page.send_message
|
|
|
|
thread_page.back
|
|
|
|
channel_page.message_thread_indicator(thread_2.original_message).click
|
|
|
|
Fabricate(:chat_message, thread: thread, use_service: true)
|
|
|
|
|
|
|
|
expect(thread_page).to have_unread_list_indicator(count: 1)
|
|
|
|
expect(thread_page).to have_back_link_to_thread_list(category_channel)
|
|
|
|
thread_page.back
|
|
|
|
expect(page).to have_current_path("#{category_channel.relative_url}/t")
|
|
|
|
end
|
|
|
|
end
|
2023-06-27 19:58:47 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when opening a thread from indicator" do
|
|
|
|
it "goes back to the thread list when clicking the back button" do
|
2024-07-30 23:04:05 -04:00
|
|
|
skip_on_ci!
|
2023-07-11 21:16:35 -04:00
|
|
|
|
2023-06-27 19:58:47 -04:00
|
|
|
visit("/chat")
|
|
|
|
chat_page.visit_channel(category_channel)
|
|
|
|
channel_page.message_thread_indicator(thread.original_message).click
|
|
|
|
expect(side_panel_page).to have_open_thread(thread)
|
2023-06-29 21:08:29 -04:00
|
|
|
expect(thread_page).to have_back_link_to_thread_list(category_channel)
|
2023-12-11 01:38:07 -05:00
|
|
|
thread_page.back
|
2023-07-05 19:08:59 -04:00
|
|
|
expect(page).to have_current_path("#{category_channel.relative_url}/t")
|
2023-06-27 19:58:47 -04:00
|
|
|
expect(thread_list_page).to have_loaded
|
|
|
|
end
|
|
|
|
|
|
|
|
context "for mobile" do
|
|
|
|
it "closes the thread and goes back to the channel when clicking the back button",
|
|
|
|
mobile: true do
|
2024-07-30 23:04:05 -04:00
|
|
|
skip_on_ci!
|
2023-07-11 21:16:35 -04:00
|
|
|
|
2023-06-27 19:58:47 -04:00
|
|
|
visit("/chat")
|
|
|
|
chat_page.visit_channel(category_channel)
|
|
|
|
channel_page.message_thread_indicator(thread.original_message).click
|
|
|
|
expect(side_panel_page).to have_open_thread(thread)
|
2023-06-29 21:08:29 -04:00
|
|
|
expect(thread_page).to have_back_link_to_channel(category_channel)
|
2023-12-11 01:38:07 -05:00
|
|
|
thread_page.back
|
2023-07-05 19:08:59 -04:00
|
|
|
expect(page).to have_current_path("#{category_channel.relative_url}")
|
2023-07-05 20:16:58 -04:00
|
|
|
expect(side_panel_page).to be_closed
|
2023-06-27 19:58:47 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-07-30 09:25:22 -04:00
|
|
|
context "when public channels are disabled" do
|
|
|
|
before { SiteSetting.enable_public_channels = false }
|
|
|
|
|
|
|
|
it "only show dms in drawer" do
|
|
|
|
visit("/")
|
|
|
|
chat_page.open_from_header
|
|
|
|
|
|
|
|
expect(page).to have_css(".direct-message-channels.center-empty-channels-list")
|
|
|
|
expect(chat_page).to have_no_messages
|
|
|
|
end
|
|
|
|
|
|
|
|
it "only show dms in desktop" do
|
|
|
|
visit("/")
|
|
|
|
chat_page.prefers_full_page
|
|
|
|
chat_page.open_from_header
|
|
|
|
|
|
|
|
expect(chat_page).to have_no_messages
|
|
|
|
expect(page).to have_css(".c-routes.--direct-messages")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-12-07 20:44:29 -05:00
|
|
|
context "when sidebar is configured as the navigation menu" 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 07:21:02 -05:00
|
|
|
before { SiteSetting.navigation_menu = "sidebar" }
|
2022-11-08 10:23:13 -05:00
|
|
|
|
|
|
|
context "when opening channel from sidebar with drawer preferred" do
|
|
|
|
it "opens channel in drawer" do
|
|
|
|
visit("/t/-/#{topic.id}")
|
|
|
|
chat_page.open_from_header
|
2022-11-11 00:39:15 -05:00
|
|
|
chat_drawer_page.close
|
2023-04-12 03:52:10 -04:00
|
|
|
sidebar_component.click_link(category_channel.name)
|
2022-11-08 10:23:13 -05:00
|
|
|
|
|
|
|
expect(page).to have_css(".chat-message-container[data-id='#{message.id}']")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when opening channel from sidebar with full page preferred" do
|
|
|
|
it "opens channel in full page" do
|
|
|
|
visit("/")
|
|
|
|
chat_page.open_from_header
|
2022-11-11 00:39:15 -05:00
|
|
|
chat_drawer_page.maximize
|
2022-11-08 10:23:13 -05:00
|
|
|
visit("/")
|
2023-04-12 03:52:10 -04:00
|
|
|
sidebar_component.click_link(category_channel.name)
|
2022-11-08 10:23:13 -05:00
|
|
|
|
|
|
|
expect(page).to have_current_path(
|
2023-01-27 07:58:12 -05:00
|
|
|
chat.channel_path(category_channel.slug, category_channel.id),
|
2022-11-08 10:23:13 -05:00
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
2022-11-08 17:58:11 -05:00
|
|
|
|
|
|
|
context "when starting draft from sidebar with full page preferred" do
|
|
|
|
it "opens draft in full page" do
|
|
|
|
visit("/")
|
|
|
|
chat_page.open_from_header
|
2022-11-11 00:39:15 -05:00
|
|
|
chat_drawer_page.maximize
|
2022-11-08 17:58:11 -05:00
|
|
|
visit("/")
|
2023-07-05 12:18:27 -04:00
|
|
|
chat_page.open_new_message
|
2022-11-08 17:58:11 -05:00
|
|
|
|
2023-07-05 12:18:27 -04:00
|
|
|
expect(chat_page.message_creator).to be_opened
|
2022-11-08 17:58:11 -05:00
|
|
|
end
|
|
|
|
end
|
2022-11-11 00:39:15 -05:00
|
|
|
|
|
|
|
context "when opening browse page from sidebar in drawer mode" do
|
|
|
|
it "opens browser page in full page" do
|
|
|
|
visit("/")
|
|
|
|
chat_page.open_from_header
|
|
|
|
sidebar_page.open_browse
|
|
|
|
|
2024-07-16 06:34:37 -04:00
|
|
|
expect(chat_drawer_page.browse).to have_channel(name: category_channel.name)
|
2022-11-11 00:39:15 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when re-opening drawer after navigating to a channel" do
|
|
|
|
it "opens drawer on correct channel" do
|
|
|
|
visit("/")
|
|
|
|
chat_page.open_from_header
|
|
|
|
chat_drawer_page.open_channel(category_channel_2)
|
2023-04-13 04:08:12 -04:00
|
|
|
chat_drawer_page.back
|
2022-11-11 00:39:15 -05:00
|
|
|
chat_drawer_page.close
|
|
|
|
chat_page.open_from_header
|
|
|
|
|
|
|
|
expect(page).to have_current_path("/")
|
2022-11-25 08:15:38 -05:00
|
|
|
expect(page).to have_css(".chat-drawer.is-expanded")
|
2022-11-11 00:39:15 -05:00
|
|
|
expect(page).to have_content(category_channel_2.title)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when re-opening full page chat after navigating to a channel" do
|
|
|
|
it "opens full page chat on correct channel" do
|
2023-07-12 21:30:24 -04:00
|
|
|
chat_channel_path = chat.channel_path(category_channel_2.slug, category_channel_2.id)
|
|
|
|
|
2022-11-11 00:39:15 -05:00
|
|
|
visit("/")
|
|
|
|
chat_page.open_from_header
|
|
|
|
chat_drawer_page.maximize
|
|
|
|
sidebar_page.open_channel(category_channel_2)
|
2024-08-08 07:52:48 -04:00
|
|
|
click_logo
|
2023-07-12 21:30:24 -04:00
|
|
|
|
2023-07-13 01:00:49 -04:00
|
|
|
expect(chat_page).to have_header_href(chat_channel_path)
|
2023-07-12 21:30:24 -04:00
|
|
|
|
2022-11-11 00:39:15 -05:00
|
|
|
chat_page.open_from_header
|
|
|
|
|
2023-07-12 21:30:24 -04:00
|
|
|
expect(page).to have_current_path(chat_channel_path)
|
2022-11-11 00:39:15 -05:00
|
|
|
expect(page).to have_content(category_channel_2.title)
|
|
|
|
end
|
|
|
|
end
|
2022-11-11 16:32:06 -05:00
|
|
|
|
|
|
|
context "when opening a channel in full page" do
|
2023-04-10 22:31:17 -04:00
|
|
|
fab!(:other_user) { Fabricate(:user) }
|
2023-06-27 19:58:47 -04:00
|
|
|
fab!(:dm_channel) { Fabricate(:direct_message_channel, users: [current_user, other_user]) }
|
2023-04-10 22:31:17 -04:00
|
|
|
|
2022-11-11 16:32:06 -05:00
|
|
|
it "activates the channel in the sidebar" do
|
2023-01-27 07:58:12 -05:00
|
|
|
visit("/chat/c/#{category_channel.slug}/#{category_channel.id}")
|
2023-04-12 03:52:10 -04:00
|
|
|
|
|
|
|
expect(sidebar_component).to have_section_link(category_channel.name, active: true)
|
2022-11-11 16:32:06 -05:00
|
|
|
end
|
2023-04-10 22:31:17 -04:00
|
|
|
|
|
|
|
it "does not have multiple channels marked active in the sidebar" do
|
|
|
|
chat_page.visit_channel(dm_channel)
|
|
|
|
|
2023-04-12 03:52:10 -04:00
|
|
|
expect(sidebar_component).to have_section_link(other_user.username, active: true)
|
|
|
|
|
|
|
|
sidebar_component.click_section_link(category_channel.name)
|
2023-04-10 22:31:17 -04:00
|
|
|
|
2023-04-12 03:52:10 -04:00
|
|
|
expect(sidebar_component).to have_section_link(category_channel.name, active: true)
|
|
|
|
expect(sidebar_component).to have_one_active_section_link
|
2023-04-10 22:31:17 -04:00
|
|
|
end
|
2022-11-11 16:32:06 -05:00
|
|
|
end
|
|
|
|
|
2022-12-05 16:42:35 -05:00
|
|
|
context "when going back to channel from channel settings in full page" do
|
|
|
|
it "activates the channel in the sidebar" do
|
2023-01-27 07:58:12 -05:00
|
|
|
visit("/chat/c/#{category_channel.slug}/#{category_channel.id}/info/settings")
|
2023-12-18 11:49:58 -05:00
|
|
|
find(".c-navbar__back-button").click
|
2022-12-05 16:42:35 -05:00
|
|
|
expect(page).to have_content(message.message)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-11-11 16:32:06 -05:00
|
|
|
context "when clicking logo from a channel in full page" do
|
|
|
|
it "deactivates the channel in the sidebar" do
|
2023-01-27 07:58:12 -05:00
|
|
|
visit("/chat/c/#{category_channel.slug}/#{category_channel.id}")
|
2024-08-08 07:52:48 -04:00
|
|
|
click_logo
|
2022-11-11 16:32:06 -05:00
|
|
|
|
2023-05-04 20:16:23 -04:00
|
|
|
expect(sidebar_component).to have_no_section_link(category_channel.name, active: true)
|
2022-11-11 16:32:06 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when opening a channel in drawer" do
|
|
|
|
it "activates the channel in the sidebar" do
|
|
|
|
visit("/")
|
|
|
|
chat_page.open_from_header
|
2023-08-24 09:22:51 -04:00
|
|
|
sidebar_component.click_section_link(category_channel.name)
|
2022-11-11 16:32:06 -05:00
|
|
|
|
2023-04-12 03:52:10 -04:00
|
|
|
expect(sidebar_component).to have_section_link(category_channel.name, active: true)
|
2022-11-11 16:32:06 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "when closing drawer in a channel" do
|
|
|
|
it "deactivates the channel in the sidebar" do
|
|
|
|
visit("/")
|
|
|
|
chat_page.open_from_header
|
2023-04-12 03:52:10 -04:00
|
|
|
|
2023-08-24 09:22:51 -04:00
|
|
|
sidebar_component.click_section_link(category_channel.name)
|
2022-11-11 16:32:06 -05:00
|
|
|
chat_drawer_page.close
|
|
|
|
|
2023-05-04 20:16:23 -04:00
|
|
|
expect(sidebar_component).to have_no_section_link(category_channel.name, active: true)
|
2022-11-11 16:32:06 -05:00
|
|
|
end
|
|
|
|
end
|
2023-08-23 07:05:15 -04:00
|
|
|
|
|
|
|
context "when exiting a thread for homepage" do
|
|
|
|
fab!(:thread) { Fabricate(:chat_thread, channel: category_channel) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
current_user.user_option.update(
|
|
|
|
chat_separate_sidebar_mode: UserOption.chat_separate_sidebar_modes[:always],
|
|
|
|
)
|
|
|
|
chat_page.prefers_full_page
|
|
|
|
category_channel.update!(threading_enabled: true)
|
|
|
|
thread.add(current_user)
|
|
|
|
end
|
|
|
|
|
2024-02-06 11:11:12 -05:00
|
|
|
it "correctly shows the thread panel" do
|
2023-08-23 07:05:15 -04:00
|
|
|
chat_page.visit_thread(thread)
|
|
|
|
|
|
|
|
expect(side_panel_page).to have_open_thread(thread)
|
|
|
|
|
2024-08-08 07:52:48 -04:00
|
|
|
click_logo
|
2023-08-23 07:05:15 -04:00
|
|
|
sidebar_component.switch_to_chat
|
|
|
|
|
2024-02-06 11:11:12 -05:00
|
|
|
expect(side_panel_page).to have_open_thread(thread)
|
2023-08-23 07:05:15 -04:00
|
|
|
end
|
|
|
|
end
|
2022-11-08 10:23:13 -05:00
|
|
|
end
|
2022-11-04 10:06:24 -04:00
|
|
|
end
|