From ff20b5dfed329a190acf8bf1421c66b7353ed1ea Mon Sep 17 00:00:00 2001 From: Jamie V Date: Thu, 5 Dec 2024 14:02:41 -0800 Subject: [PATCH 1/8] moving rename methods to appActions --- e2e/appActions.js | 30 +++++++++++++++++++++++ e2e/tests/functional/renaming.e2e.spec.js | 30 ----------------------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/e2e/appActions.js b/e2e/appActions.js index 99ee63cdb5d..a0bf6329431 100644 --- a/e2e/appActions.js +++ b/e2e/appActions.js @@ -682,6 +682,34 @@ async function linkParameterToObject(page, parameterName, objectName) { await page.getByLabel('Save').click(); } +/** + * @param {import('@playwright/test').Page} page + * @param {string} myItemsFolderName + * @param {string} url + * @param {string} newName + */ +async function renameObjectFromContextMenu(page, url, newName) { + await openObjectTreeContextMenu(page, url); + await page.getByRole('menuitem', { name: 'Edit Properties' }).click(); + const nameInput = page.getByLabel('Title', { exact: true }); + await nameInput.fill(''); + await nameInput.fill(newName); + await page.getByRole('button', { name: 'Save' }).click(); +} + +/** + * Open the given `domainObject`'s context menu from the object tree. + * Expands the path to the object and scrolls to it if necessary. + * + * @param {import('@playwright/test').Page} page + * @param {string} url the url to the object + */ +async function openObjectTreeContextMenu(page, url) { + await page.goto(url); + await page.getByLabel('Show selected item in tree').click(); + await page.getByRole('button', { name: 'More actions' }).click(); +} + export { createDomainObjectWithDefaults, createExampleTelemetryObject, @@ -693,6 +721,8 @@ export { linkParameterToObject, navigateToObjectWithFixedTimeBounds, navigateToObjectWithRealTime, + openObjectTreeContextMenu, + renameObjectFromContextMenu, setEndOffset, setFixedIndependentTimeConductorBounds, setFixedTimeMode, diff --git a/e2e/tests/functional/renaming.e2e.spec.js b/e2e/tests/functional/renaming.e2e.spec.js index 80641fb29bb..efe3c87923c 100644 --- a/e2e/tests/functional/renaming.e2e.spec.js +++ b/e2e/tests/functional/renaming.e2e.spec.js @@ -73,33 +73,3 @@ test.describe('Renaming objects', () => { expect(title).toBe(clock.name); }); }); - -/** - * @param {import('@playwright/test').Page} page - * @param {string} myItemsFolderName - * @param {string} url - * @param {string} newName - */ -async function renameObjectFromContextMenu(page, url, newName) { - await openObjectTreeContextMenu(page, url); - await page.locator('li:text("Edit Properties")').click(); - const nameInput = page.getByLabel('Title', { exact: true }); - await nameInput.fill(''); - await nameInput.fill(newName); - await page.locator('[aria-label="Save"]').click(); -} - -/** - * Open the given `domainObject`'s context menu from the object tree. - * Expands the path to the object and scrolls to it if necessary. - * - * @param {import('@playwright/test').Page} page - * @param {string} url the url to the object - */ -async function openObjectTreeContextMenu(page, url) { - await page.goto(url); - await page.getByLabel('Show selected item in tree').click(); - await page.locator('.is-navigated-object').click({ - button: 'right' - }); -} From 4db626c311326bfbf84ab50a1b562e0b9e29c2c4 Mon Sep 17 00:00:00 2001 From: Jamie V Date: Thu, 5 Dec 2024 14:04:38 -0800 Subject: [PATCH 2/8] importing back into original test --- e2e/tests/functional/renaming.e2e.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/tests/functional/renaming.e2e.spec.js b/e2e/tests/functional/renaming.e2e.spec.js index efe3c87923c..3d6fd5c75a5 100644 --- a/e2e/tests/functional/renaming.e2e.spec.js +++ b/e2e/tests/functional/renaming.e2e.spec.js @@ -24,7 +24,7 @@ This test suite is dedicated to tests for renaming objects, and their global application effects. */ -import { createDomainObjectWithDefaults } from '../../appActions.js'; +import { createDomainObjectWithDefaults, renameObjectFromContextMenu } from '../../appActions.js'; import { expect, test } from '../../baseFixtures.js'; test.describe('Renaming objects', () => { From 7533f81cf2d154ef1a225188da33e550960a1e2c Mon Sep 17 00:00:00 2001 From: Jamie V Date: Thu, 5 Dec 2024 14:29:46 -0800 Subject: [PATCH 3/8] reverting --- e2e/tests/functional/renaming.e2e.spec.js | 32 ++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/e2e/tests/functional/renaming.e2e.spec.js b/e2e/tests/functional/renaming.e2e.spec.js index 3d6fd5c75a5..80641fb29bb 100644 --- a/e2e/tests/functional/renaming.e2e.spec.js +++ b/e2e/tests/functional/renaming.e2e.spec.js @@ -24,7 +24,7 @@ This test suite is dedicated to tests for renaming objects, and their global application effects. */ -import { createDomainObjectWithDefaults, renameObjectFromContextMenu } from '../../appActions.js'; +import { createDomainObjectWithDefaults } from '../../appActions.js'; import { expect, test } from '../../baseFixtures.js'; test.describe('Renaming objects', () => { @@ -73,3 +73,33 @@ test.describe('Renaming objects', () => { expect(title).toBe(clock.name); }); }); + +/** + * @param {import('@playwright/test').Page} page + * @param {string} myItemsFolderName + * @param {string} url + * @param {string} newName + */ +async function renameObjectFromContextMenu(page, url, newName) { + await openObjectTreeContextMenu(page, url); + await page.locator('li:text("Edit Properties")').click(); + const nameInput = page.getByLabel('Title', { exact: true }); + await nameInput.fill(''); + await nameInput.fill(newName); + await page.locator('[aria-label="Save"]').click(); +} + +/** + * Open the given `domainObject`'s context menu from the object tree. + * Expands the path to the object and scrolls to it if necessary. + * + * @param {import('@playwright/test').Page} page + * @param {string} url the url to the object + */ +async function openObjectTreeContextMenu(page, url) { + await page.goto(url); + await page.getByLabel('Show selected item in tree').click(); + await page.locator('.is-navigated-object').click({ + button: 'right' + }); +} From c55e1229458771eaa58542fa1a5c1a1bf220f9b7 Mon Sep 17 00:00:00 2001 From: Jamie V Date: Thu, 5 Dec 2024 16:11:06 -0800 Subject: [PATCH 4/8] add the ability to change the name in the browse bar --- e2e/appActions.js | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) diff --git a/e2e/appActions.js b/e2e/appActions.js index a0bf6329431..7bb82726f20 100644 --- a/e2e/appActions.js +++ b/e2e/appActions.js @@ -683,31 +683,18 @@ async function linkParameterToObject(page, parameterName, objectName) { } /** + * Rename the currently viewed `domainObject` from the browse bar. + * * @param {import('@playwright/test').Page} page - * @param {string} myItemsFolderName - * @param {string} url * @param {string} newName */ -async function renameObjectFromContextMenu(page, url, newName) { - await openObjectTreeContextMenu(page, url); - await page.getByRole('menuitem', { name: 'Edit Properties' }).click(); - const nameInput = page.getByLabel('Title', { exact: true }); +async function renameCurrentObjectFromBrowseBar(page, newName) { + const nameInput = page.getByLabel('Browse bar object name'); + await nameInput.click(); await nameInput.fill(''); await nameInput.fill(newName); - await page.getByRole('button', { name: 'Save' }).click(); -} - -/** - * Open the given `domainObject`'s context menu from the object tree. - * Expands the path to the object and scrolls to it if necessary. - * - * @param {import('@playwright/test').Page} page - * @param {string} url the url to the object - */ -async function openObjectTreeContextMenu(page, url) { - await page.goto(url); - await page.getByLabel('Show selected item in tree').click(); - await page.getByRole('button', { name: 'More actions' }).click(); + // Click the browse bar container to save changes + await page.getByLabel('Browse bar', { exact: true }).click(); } export { @@ -721,8 +708,7 @@ export { linkParameterToObject, navigateToObjectWithFixedTimeBounds, navigateToObjectWithRealTime, - openObjectTreeContextMenu, - renameObjectFromContextMenu, + renameCurrentObjectFromBrowseBar, setEndOffset, setFixedIndependentTimeConductorBounds, setFixedTimeMode, From 94ebcdf6199e64b7a5aaba6677d0537578220035 Mon Sep 17 00:00:00 2001 From: Jamie V Date: Thu, 5 Dec 2024 16:11:46 -0800 Subject: [PATCH 5/8] add test to verify entries are not being lost --- .../plugins/notebook/notebook.e2e.spec.js | 62 ++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/e2e/tests/functional/plugins/notebook/notebook.e2e.spec.js b/e2e/tests/functional/plugins/notebook/notebook.e2e.spec.js index 070a99058e9..c6aaa9e99a1 100644 --- a/e2e/tests/functional/plugins/notebook/notebook.e2e.spec.js +++ b/e2e/tests/functional/plugins/notebook/notebook.e2e.spec.js @@ -26,7 +26,10 @@ This test suite is dedicated to tests which verify the basic operations surround import { fileURLToPath } from 'url'; -import { createDomainObjectWithDefaults } from '../../../../appActions.js'; +import { + createDomainObjectWithDefaults, + renameCurrentObjectFromBrowseBar +} from '../../../../appActions.js'; import { copy, paste, selectAll } from '../../../../helper/hotkeys/hotkeys.js'; import * as nbUtils from '../../../../helper/notebookUtils.js'; import { expect, streamToString, test } from '../../../../pluginFixtures.js'; @@ -596,4 +599,61 @@ test.describe('Notebook entry tests', () => { await expect(await page.locator(`text="${TEST_TEXT.repeat(1)}"`).count()).toEqual(1); await expect(await page.locator(`text="${TEST_TEXT.repeat(2)}"`).count()).toEqual(0); }); + + test('When changing the name of a notebook in the browse bar, new notebook changes are not lost', async ({ + page + }) => { + const TEST_TEXT = 'Do not lose me!'; + const FIRST_NEW_NAME = 'New Name'; + const SECOND_NEW_NAME = 'Second New Name'; + + await page.goto(notebookObject.url); + + await page.getByLabel('Expand My Items folder').click(); + + await renameCurrentObjectFromBrowseBar(page, FIRST_NEW_NAME); + + // verify the name change in tree and browse bar + await verifyNameChange(page, FIRST_NEW_NAME); + + // enter one entry + await enterAndCommitTextEntry(page, TEST_TEXT); + + // verify the entry is present + await expect(await page.locator(`text="${TEST_TEXT}"`).count()).toEqual(1); + + // change the name + await renameCurrentObjectFromBrowseBar(page, SECOND_NEW_NAME); + + // verify the name change in tree and browse bar + await verifyNameChange(page, SECOND_NEW_NAME); + + // verify the entry is still present + await expect(await page.locator(`text="${TEST_TEXT}"`).count()).toEqual(1); + }); }); + +/** + * Enter text into the last notebook entry and commit it. + * + * @param {import('@playwright/test').Page} page + * @param {string} text + */ +async function enterAndCommitTextEntry(page, text) { + await nbUtils.addNotebookEntry(page); + await nbUtils.enterTextInLastEntry(page, text); + await nbUtils.commitEntry(page); +} + +/** + * Verify the name change in the tree and browse bar. + * + * @param {import('@playwright/test').Page} page + * @param {string} newName + */ +async function verifyNameChange(page, newName) { + await expect( + page.getByRole('treeitem').locator('.is-navigated-object .c-tree__item__name') + ).toHaveText(newName); + await expect(page.getByLabel('Browse bar object name')).toHaveText(newName); +} From cd0be47d065d79112fef4b4d6af5bc322451aadd Mon Sep 17 00:00:00 2001 From: Jamie V Date: Thu, 5 Dec 2024 16:14:29 -0800 Subject: [PATCH 6/8] addding aria labels for tests --- src/ui/layout/BrowseBar.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ui/layout/BrowseBar.vue b/src/ui/layout/BrowseBar.vue index 088f60e01c2..59dad57a316 100644 --- a/src/ui/layout/BrowseBar.vue +++ b/src/ui/layout/BrowseBar.vue @@ -20,7 +20,7 @@ at runtime from the About dialog for additional information. -->