mirror of
https://github.com/discourse/discourse.git
synced 2025-06-04 07:47:16 +08:00
FIX: prevents setPanel to also set separated mode (#23227)
This could happen after you had already change the separation mode and would cause unexpected bugs. This PR also adds more tests around using switch buttons with chat.
This commit is contained in:
@ -24,7 +24,6 @@ export default class SidebarState extends Service {
|
|||||||
|
|
||||||
setPanel(name) {
|
setPanel(name) {
|
||||||
this.currentPanelKey = name;
|
this.currentPanelKey = name;
|
||||||
this.setSeparatedMode();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get currentPanel() {
|
get currentPanel() {
|
||||||
|
@ -1014,6 +1014,7 @@ acceptance("Sidebar - Plugin API", function (needs) {
|
|||||||
"new-panel"
|
"new-panel"
|
||||||
);
|
);
|
||||||
api.setSidebarPanel("new-panel");
|
api.setSidebarPanel("new-panel");
|
||||||
|
api.setSeparatedSidebarMode();
|
||||||
});
|
});
|
||||||
|
|
||||||
await visit("/");
|
await visit("/");
|
||||||
|
@ -124,19 +124,27 @@ RSpec.describe "Separate sidebar mode", type: :system do
|
|||||||
|
|
||||||
expect(sidebar_component).to have_switch_button("chat")
|
expect(sidebar_component).to have_switch_button("chat")
|
||||||
expect(header_component).to have_open_chat_button
|
expect(header_component).to have_open_chat_button
|
||||||
|
expect(sidebar_component).to have_section("Categories")
|
||||||
expect(sidebar_component).to have_no_section("chat-channels")
|
expect(sidebar_component).to have_no_section("chat-channels")
|
||||||
|
|
||||||
chat_page.open_from_header
|
chat_page.open_from_header
|
||||||
|
|
||||||
expect(sidebar_component).to have_no_switch_button
|
expect(sidebar_component).to have_no_switch_button
|
||||||
expect(header_component).to have_open_chat_button
|
expect(header_component).to have_open_chat_button
|
||||||
|
expect(sidebar_component).to have_section("Categories")
|
||||||
expect(sidebar_component).to have_no_section("chat-channels")
|
expect(sidebar_component).to have_no_section("chat-channels")
|
||||||
|
|
||||||
chat_drawer_page.close
|
chat_drawer_page.close
|
||||||
|
|
||||||
expect(sidebar_component).to have_switch_button("chat")
|
expect(sidebar_component).to have_switch_button("chat")
|
||||||
expect(header_component).to have_open_chat_button
|
expect(header_component).to have_open_chat_button
|
||||||
|
expect(sidebar_component).to have_section("Categories")
|
||||||
expect(sidebar_component).to have_no_section("chat-channels")
|
expect(sidebar_component).to have_no_section("chat-channels")
|
||||||
|
|
||||||
|
sidebar_component.switch_to_chat
|
||||||
|
|
||||||
|
expect(sidebar_component).to have_no_section("chat-channels")
|
||||||
|
expect(sidebar_component).to have_section("Categories")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -164,6 +172,16 @@ RSpec.describe "Separate sidebar mode", type: :system do
|
|||||||
expect(header_component).to have_open_chat_button
|
expect(header_component).to have_open_chat_button
|
||||||
expect(sidebar_component).to have_no_section("chat-channels")
|
expect(sidebar_component).to have_no_section("chat-channels")
|
||||||
expect(sidebar_component).to have_section("Categories")
|
expect(sidebar_component).to have_section("Categories")
|
||||||
|
|
||||||
|
sidebar_component.switch_to_chat
|
||||||
|
|
||||||
|
expect(sidebar_component).to have_section("chat-channels")
|
||||||
|
expect(sidebar_component).to have_no_section("Categories")
|
||||||
|
|
||||||
|
sidebar_component.switch_to_main
|
||||||
|
|
||||||
|
expect(sidebar_component).to have_no_section("chat-channels")
|
||||||
|
expect(sidebar_component).to have_section("Categories")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -199,6 +217,11 @@ RSpec.describe "Separate sidebar mode", type: :system do
|
|||||||
expect(header_component).to have_open_chat_button
|
expect(header_component).to have_open_chat_button
|
||||||
expect(sidebar_component).to have_section("Categories")
|
expect(sidebar_component).to have_section("Categories")
|
||||||
expect(sidebar_component).to have_section("chat-channels")
|
expect(sidebar_component).to have_section("chat-channels")
|
||||||
|
|
||||||
|
sidebar_component.switch_to_chat
|
||||||
|
|
||||||
|
expect(sidebar_component).to have_section("Categories")
|
||||||
|
expect(sidebar_component).to have_section("chat-channels")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -226,6 +249,16 @@ RSpec.describe "Separate sidebar mode", type: :system do
|
|||||||
expect(header_component).to have_open_chat_button
|
expect(header_component).to have_open_chat_button
|
||||||
expect(sidebar_component).to have_section("chat-channels")
|
expect(sidebar_component).to have_section("chat-channels")
|
||||||
expect(sidebar_component).to have_section("Categories")
|
expect(sidebar_component).to have_section("Categories")
|
||||||
|
|
||||||
|
sidebar_component.switch_to_chat
|
||||||
|
|
||||||
|
expect(sidebar_component).to have_section("chat-channels")
|
||||||
|
expect(sidebar_component).to have_no_section("Categories")
|
||||||
|
|
||||||
|
sidebar_component.switch_to_main
|
||||||
|
|
||||||
|
expect(sidebar_component).to have_section("chat-channels")
|
||||||
|
expect(sidebar_component).to have_section("Categories")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -34,6 +34,10 @@ module PageObjects
|
|||||||
find(".sidebar__panel-switch-button[data-key='chat']").click
|
find(".sidebar__panel-switch-button[data-key='chat']").click
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def switch_to_main
|
||||||
|
find(".sidebar__panel-switch-button[data-key='main']").click
|
||||||
|
end
|
||||||
|
|
||||||
def has_no_section?(name)
|
def has_no_section?(name)
|
||||||
has_no_css?(".sidebar-sections [data-section-name='#{name.parameterize}']")
|
has_no_css?(".sidebar-sections [data-section-name='#{name.parameterize}']")
|
||||||
end
|
end
|
||||||
|
Reference in New Issue
Block a user