@@ -195,6 +195,68 @@ test.describe("Room list custom sections", () => {
195195 } ) ;
196196 } ) ;
197197
198+ test . describe ( "Section editing" , ( ) => {
199+ test ( "should edit a custom section name via the section header menu" , async ( { page, app } ) => {
200+ await app . client . createRoom ( { name : "my room" } ) ;
201+ await createCustomSection ( page , "Work" ) ;
202+
203+ // Open the section header menu
204+ const sectionHeader = getSectionHeader ( page , "Work" ) ;
205+ await sectionHeader . hover ( ) ;
206+ await sectionHeader . getByRole ( "button" , { name : "More options" } ) . click ( ) ;
207+
208+ // Click "Edit section"
209+ await page . getByRole ( "menuitem" , { name : "Edit section" } ) . click ( ) ;
210+
211+ // The edit dialog should appear pre-filled with the current name
212+ const dialog = page . getByRole ( "dialog" , { name : "Edit a section" } ) ;
213+ await expect ( dialog ) . toBeVisible ( ) ;
214+ await expect ( dialog . getByRole ( "textbox" , { name : "Section name" } ) ) . toHaveValue ( "Work" ) ;
215+
216+ // Change the name and confirm
217+ await dialog . getByRole ( "textbox" , { name : "Section name" } ) . fill ( "Personal" ) ;
218+ await dialog . getByRole ( "button" , { name : "Edit section" } ) . click ( ) ;
219+
220+ // Dialog should close
221+ await expect ( dialog ) . not . toBeVisible ( ) ;
222+
223+ // Section should have the new name
224+ await expect ( getSectionHeader ( page , "Personal" ) ) . toBeVisible ( ) ;
225+ await expect ( getSectionHeader ( page , "Work" ) ) . not . toBeVisible ( ) ;
226+ } ) ;
227+ } ) ;
228+
229+ test . describe ( "Section removal" , ( ) => {
230+ test ( "should move rooms back to Chats when their section is removed" , async ( { page, app } ) => {
231+ await app . client . createRoom ( { name : "my room" } ) ;
232+ await createCustomSection ( page , "Work" ) ;
233+ await createCustomSection ( page , "Personal" ) ;
234+
235+ const roomList = getRoomList ( page ) ;
236+
237+ // Move room to Work section
238+ const roomItem = roomList . getByRole ( "row" , { name : "Open room my room" } ) ;
239+ await roomItem . hover ( ) ;
240+ await roomItem . getByRole ( "button" , { name : "More Options" } ) . click ( ) ;
241+ await page . getByRole ( "menuitem" , { name : "Move to" } ) . hover ( ) ;
242+ await page . getByRole ( "menuitem" , { name : "Work" } ) . click ( ) ;
243+ await assertRoomInSection ( page , "Work" , "my room" ) ;
244+
245+ // Remove the Work section
246+ const sectionHeader = getSectionHeader ( page , "Work" ) ;
247+ await sectionHeader . hover ( ) ;
248+ await sectionHeader . getByRole ( "button" , { name : "More options" } ) . click ( ) ;
249+ await page . getByRole ( "menuitem" , { name : "Remove section" } ) . click ( ) ;
250+ const dialog = page . getByRole ( "dialog" , { name : "Remove section?" } ) ;
251+ await dialog . getByRole ( "button" , { name : "Remove section" } ) . click ( ) ;
252+
253+ // Section should be gone
254+ await expect ( getSectionHeader ( page , "Work" ) ) . not . toBeVisible ( ) ;
255+ // Room should now be in the Chats section
256+ await assertRoomInSection ( page , "Chats" , "my room" ) ;
257+ } ) ;
258+ } ) ;
259+
198260 test . describe ( "Adding a room to a custom section" , ( ) => {
199261 test ( "should add a room to a custom section via the More Options menu" , async ( { page, app } ) => {
200262 await app . client . createRoom ( { name : "my room" } ) ;
0 commit comments