From 39cff51db005000d0eba5387670d4bf19cba2fa0 Mon Sep 17 00:00:00 2001 From: Charles Hacskaylo Date: Fri, 10 Mar 2023 11:00:01 -0800 Subject: [PATCH] Fix Notebook enter key 6354 (#6365) * Closes #6354 Notebook Enter key adds new lines - Removed enter key handlers from Vue component. - Added "Save" button. * entry must be selected before editing * focus on newly created entry * Closes #6354 Notebook Enter key adds new lines - Removed enter key handlers from Vue component. - Added "Save" button. * do not allow edit unless entry is selected * remove css for disabled cass --------- Co-authored-by: David Tsay --- e2e/helper/notebookUtils.js | 14 ++++++++--- .../plugins/notebook/tags.e2e.spec.js | 23 ++++++++++--------- src/plugins/notebook/components/Notebook.vue | 1 + .../notebook/components/NotebookEntry.vue | 21 ++++++++++++++--- src/styles/notebook.scss | 19 +++++++++++---- 5 files changed, 57 insertions(+), 21 deletions(-) diff --git a/e2e/helper/notebookUtils.js b/e2e/helper/notebookUtils.js index 41d1d8b5cd..e6eb29dad6 100644 --- a/e2e/helper/notebookUtils.js +++ b/e2e/helper/notebookUtils.js @@ -32,9 +32,8 @@ async function enterTextEntry(page, text) { await page.locator(NOTEBOOK_DROP_AREA).click(); // enter text - await page.locator('div.c-ne__text').click(); - await page.locator('div.c-ne__text').fill(text); - await page.locator('div.c-ne__text').press('Enter'); + await page.locator('[aria-label="Notebook Entry"].is-selected div.c-ne__text').fill(text); + await commitEntry(page); } /** @@ -51,6 +50,15 @@ async function dragAndDropEmbed(page, notebookObject) { await page.click('button[title="Show selected item in tree"]'); // Drag and drop the SWG into the notebook await page.dragAndDrop(`text=${swg.name}`, NOTEBOOK_DROP_AREA); + await commitEntry(page); +} + +/** + * @private + * @param {import('@playwright/test').Page} page + */ +async function commitEntry(page) { + await page.locator('.c-ne__save-button > button').click(); } // eslint-disable-next-line no-undef diff --git a/e2e/tests/functional/plugins/notebook/tags.e2e.spec.js b/e2e/tests/functional/plugins/notebook/tags.e2e.spec.js index f1a7222a23..83f32d3cc2 100644 --- a/e2e/tests/functional/plugins/notebook/tags.e2e.spec.js +++ b/e2e/tests/functional/plugins/notebook/tags.e2e.spec.js @@ -25,7 +25,8 @@ This test suite is dedicated to tests which verify form functionality. */ const { test, expect } = require('../../../../pluginFixtures'); -const { createDomainObjectWithDefaults } = require('../../../../appActions'); +const { createDomainObjectWithDefaults, selectInspectorTab } = require('../../../../appActions'); +const nbUtils = require('../../../../helper/notebookUtils'); /** * Creates a notebook object and adds an entry. @@ -39,12 +40,7 @@ async function createNotebookAndEntry(page, iterations = 1) { const notebook = createDomainObjectWithDefaults(page, { type: 'Notebook' }); for (let iteration = 0; iteration < iterations; iteration++) { - // Create an entry - await page.locator('text=To start a new entry, click here or drag and drop any object').click(); - const entryLocator = `[aria-label="Notebook Entry Input"] >> nth = ${iteration}`; - await page.locator(entryLocator).click(); - await page.locator(entryLocator).fill(`Entry ${iteration}`); - await page.locator(entryLocator).press('Enter'); + await nbUtils.enterTextEntry(page, `Entry ${iteration}`); } return notebook; @@ -57,7 +53,7 @@ async function createNotebookAndEntry(page, iterations = 1) { */ async function createNotebookEntryAndTags(page, iterations = 1) { const notebook = await createNotebookAndEntry(page, iterations); - await page.locator('text=Annotations').click(); + await selectInspectorTab(page, 'Annotations'); for (let iteration = 0; iteration < iterations; iteration++) { // Hover and click "Add Tag" button @@ -88,7 +84,10 @@ test.describe('Tagging in Notebooks @addInit', () => { test('Can load tags', async ({ page }) => { await createNotebookAndEntry(page); - await page.locator('text=Annotations').click(); + // TODO can be removed with fix for https://github.com/nasa/openmct/issues/6411 + await page.locator('[aria-label="Notebook Entry"].is-selected div.c-ne__text').click(); + + await selectInspectorTab(page, 'Annotations'); await page.locator('button:has-text("Add Tag")').click(); @@ -247,8 +246,10 @@ test.describe('Tagging in Notebooks @addInit', () => { test('Can cancel adding a tag', async ({ page }) => { await createNotebookAndEntry(page); - // Click on Annotations tab - await page.locator('.c-inspector__tab', { hasText: "Annotations" }).click(); + // TODO can be removed with fix for https://github.com/nasa/openmct/issues/6411 + await page.locator('[aria-label="Notebook Entry"].is-selected div.c-ne__text').click(); + + await selectInspectorTab(page, 'Annotations'); // Click on the "Add Tag" button await page.locator('button:has-text("Add Tag")').click(); diff --git a/src/plugins/notebook/components/Notebook.vue b/src/plugins/notebook/components/Notebook.vue index c56b5868b4..996569006d 100644 --- a/src/plugins/notebook/components/Notebook.vue +++ b/src/plugins/notebook/components/Notebook.vue @@ -791,6 +791,7 @@ export default { this.updateDefaultNotebook(notebookStorage); const id = await addNotebookEntry(this.openmct, this.domainObject, notebookStorage, embed); this.focusEntryId = id; + this.selectedEntryId = id; this.filterAndSortEntries(); }, orientationChange() { diff --git a/src/plugins/notebook/components/NotebookEntry.vue b/src/plugins/notebook/components/NotebookEntry.vue index 2136a867bf..eaae1e02a2 100644 --- a/src/plugins/notebook/components/NotebookEntry.vue +++ b/src/plugins/notebook/components/NotebookEntry.vue @@ -25,7 +25,10 @@
+
+ +