@@ -52,6 +52,7 @@ import {
5252 showChannelList ,
5353 showChannelPane ,
5454} from "@posthog/ui/features/canvas/stores/channelPaneStore" ;
55+ import { useCurrentChannelStore } from "@posthog/ui/features/canvas/stores/currentChannelStore" ;
5556import { useSidebarStore } from "@posthog/ui/features/sidebar/sidebarStore" ;
5657import { ChannelsList } from "./ChannelsList" ;
5758
@@ -81,6 +82,16 @@ describe("ChannelsList", () => {
8182 useSidebarStore . setState ( { collapsedSections : new Set ( ) } ) ;
8283 } ) ;
8384
85+ it ( "opens a space in the sidebar without navigating the main window" , async ( ) => {
86+ const user = userEvent . setup ( ) ;
87+ renderList ( ) ;
88+
89+ await user . click ( screen . getByText ( "engineering" ) ) ;
90+
91+ expect ( useCurrentChannelStore . getState ( ) . currentChannelId ) . toBe ( ENG . id ) ;
92+ expect ( mocks . navigate ) . not . toHaveBeenCalled ( ) ;
93+ } ) ;
94+
8495 it ( "pins #me above the channels, with its ⌘1 shortcut" , ( ) => {
8596 renderList ( ) ;
8697 const me = screen . getByText ( "me" ) ;
@@ -182,10 +193,8 @@ describe("ChannelsList", () => {
182193 await user . type ( screen . getByLabelText ( "Search spaces" ) , "eng" ) ;
183194 await user . keyboard ( "{Enter}" ) ;
184195
185- expect ( mocks . navigate ) . toHaveBeenCalledWith ( {
186- to : "/website/$channelId" ,
187- params : { channelId : ENG . id } ,
188- } ) ;
196+ expect ( useCurrentChannelStore . getState ( ) . currentChannelId ) . toBe ( ENG . id ) ;
197+ expect ( mocks . navigate ) . not . toHaveBeenCalled ( ) ;
189198 } ) ;
190199
191200 it ( "moves the highlight with the arrow keys" , async ( ) => {
@@ -197,10 +206,8 @@ describe("ChannelsList", () => {
197206 await user . type ( screen . getByLabelText ( "Search spaces" ) , "e" ) ;
198207 await user . keyboard ( "{ArrowDown}{Enter}" ) ;
199208
200- expect ( mocks . navigate ) . toHaveBeenCalledWith ( {
201- to : "/website/$channelId" ,
202- params : { channelId : ENG . id } ,
203- } ) ;
209+ expect ( useCurrentChannelStore . getState ( ) . currentChannelId ) . toBe ( ENG . id ) ;
210+ expect ( mocks . navigate ) . not . toHaveBeenCalled ( ) ;
204211 } ) ;
205212
206213 // Base UI's clear button is a tabIndex=-1 decoration by default, which left
@@ -247,10 +254,8 @@ describe("ChannelsList", () => {
247254 await user . click ( screen . getByLabelText ( "Search spaces" ) ) ;
248255 await user . keyboard ( "{ArrowDown}{Enter}" ) ;
249256
250- expect ( mocks . navigate ) . toHaveBeenCalledWith ( {
251- to : "/website/$channelId" ,
252- params : { channelId : ENG . id } ,
253- } ) ;
257+ expect ( useCurrentChannelStore . getState ( ) . currentChannelId ) . toBe ( ENG . id ) ;
258+ expect ( mocks . navigate ) . not . toHaveBeenCalled ( ) ;
254259 } ) ;
255260
256261 // Base UI resets the highlight when the pointer leaves a row, and
@@ -266,10 +271,8 @@ describe("ChannelsList", () => {
266271 await user . unhover ( row ) ;
267272 await user . keyboard ( "{Enter}" ) ;
268273
269- expect ( mocks . navigate ) . toHaveBeenCalledWith ( {
270- to : "/website/$channelId" ,
271- params : { channelId : ENG . id } ,
272- } ) ;
274+ expect ( useCurrentChannelStore . getState ( ) . currentChannelId ) . toBe ( ENG . id ) ;
275+ expect ( mocks . navigate ) . not . toHaveBeenCalled ( ) ;
273276 } ) ;
274277
275278 // A kept-mounted collapsed row would still be an option, so ↓ would walk
@@ -323,10 +326,8 @@ describe("ChannelsList", () => {
323326 // it would have been the row after it.
324327 await user . keyboard ( "{ArrowDown}{Enter}" ) ;
325328
326- expect ( mocks . navigate ) . toHaveBeenCalledWith ( {
327- to : "/website/$channelId" ,
328- params : { channelId : ENG . id } ,
329- } ) ;
329+ expect ( useCurrentChannelStore . getState ( ) . currentChannelId ) . toBe ( ENG . id ) ;
330+ expect ( mocks . navigate ) . not . toHaveBeenCalled ( ) ;
330331 } ) ;
331332
332333 it ( "selects a stale query so the next keystroke replaces it" , async ( ) => {
0 commit comments