@@ -26,7 +26,10 @@ This test suite is dedicated to tests which verify the basic operations surround
2626
2727import { fileURLToPath } from 'url' ;
2828
29- import { createDomainObjectWithDefaults } from '../../../../appActions.js' ;
29+ import {
30+ createDomainObjectWithDefaults ,
31+ renameCurrentObjectFromBrowseBar
32+ } from '../../../../appActions.js' ;
3033import { copy , paste , selectAll } from '../../../../helper/hotkeys/hotkeys.js' ;
3134import * as nbUtils from '../../../../helper/notebookUtils.js' ;
3235import { expect , streamToString , test } from '../../../../pluginFixtures.js' ;
@@ -596,4 +599,61 @@ test.describe('Notebook entry tests', () => {
596599 await expect ( await page . locator ( `text="${ TEST_TEXT . repeat ( 1 ) } "` ) . count ( ) ) . toEqual ( 1 ) ;
597600 await expect ( await page . locator ( `text="${ TEST_TEXT . repeat ( 2 ) } "` ) . count ( ) ) . toEqual ( 0 ) ;
598601 } ) ;
602+
603+ test ( 'When changing the name of a notebook in the browse bar, new notebook changes are not lost' , async ( {
604+ page
605+ } ) => {
606+ const TEST_TEXT = 'Do not lose me!' ;
607+ const FIRST_NEW_NAME = 'New Name' ;
608+ const SECOND_NEW_NAME = 'Second New Name' ;
609+
610+ await page . goto ( notebookObject . url ) ;
611+
612+ await page . getByLabel ( 'Expand My Items folder' ) . click ( ) ;
613+
614+ await renameCurrentObjectFromBrowseBar ( page , FIRST_NEW_NAME ) ;
615+
616+ // verify the name change in tree and browse bar
617+ await verifyNameChange ( page , FIRST_NEW_NAME ) ;
618+
619+ // enter one entry
620+ await enterAndCommitTextEntry ( page , TEST_TEXT ) ;
621+
622+ // verify the entry is present
623+ await expect ( await page . locator ( `text="${ TEST_TEXT } "` ) . count ( ) ) . toEqual ( 1 ) ;
624+
625+ // change the name
626+ await renameCurrentObjectFromBrowseBar ( page , SECOND_NEW_NAME ) ;
627+
628+ // verify the name change in tree and browse bar
629+ await verifyNameChange ( page , SECOND_NEW_NAME ) ;
630+
631+ // verify the entry is still present
632+ await expect ( await page . locator ( `text="${ TEST_TEXT } "` ) . count ( ) ) . toEqual ( 1 ) ;
633+ } ) ;
599634} ) ;
635+
636+ /**
637+ * Enter text into the last notebook entry and commit it.
638+ *
639+ * @param {import('@playwright/test').Page } page
640+ * @param {string } text
641+ */
642+ async function enterAndCommitTextEntry ( page , text ) {
643+ await nbUtils . addNotebookEntry ( page ) ;
644+ await nbUtils . enterTextInLastEntry ( page , text ) ;
645+ await nbUtils . commitEntry ( page ) ;
646+ }
647+
648+ /**
649+ * Verify the name change in the tree and browse bar.
650+ *
651+ * @param {import('@playwright/test').Page } page
652+ * @param {string } newName
653+ */
654+ async function verifyNameChange ( page , newName ) {
655+ await expect (
656+ page . getByRole ( 'treeitem' ) . locator ( '.is-navigated-object .c-tree__item__name' )
657+ ) . toHaveText ( newName ) ;
658+ await expect ( page . getByLabel ( 'Browse bar object name' ) ) . toHaveText ( newName ) ;
659+ }
0 commit comments