From 79d1df39b7deb4e96aa79af90f847859b4176a37 Mon Sep 17 00:00:00 2001 From: Khalid Adil Date: Wed, 31 Aug 2022 12:11:09 -0500 Subject: [PATCH] Add check to hide any old popup items when showing a new one (#5680) * Add check to hide any old popup items when showing a new one * Use more deterministic selector * Hover first to "slow down" e2e actions while in headless mode * Add notebook tests * Combine the section tests * Set focused image when timestamp prop is passed in * Unused var * Create timestrip with imagery child * Add equality check for hovered image and view large image url * Cleanup * add annotation and checks * [e2e] Minor locator improvements * Update button title * skipping with context Co-authored-by: John Hill Co-authored-by: Jesse Mazzella --- .../plugins/notebook/notebook.e2e.spec.js | 63 +++++++++++++++++-- src/plugins/notebook/components/PopupMenu.vue | 6 +- 2 files changed, 64 insertions(+), 5 deletions(-) diff --git a/e2e/tests/functional/plugins/notebook/notebook.e2e.spec.js b/e2e/tests/functional/plugins/notebook/notebook.e2e.spec.js index 51dfd42995..228e3fcd46 100644 --- a/e2e/tests/functional/plugins/notebook/notebook.e2e.spec.js +++ b/e2e/tests/functional/plugins/notebook/notebook.e2e.spec.js @@ -27,6 +27,7 @@ This test suite is dedicated to tests which verify the basic operations surround // FIXME: Remove this eslint exception once tests are implemented // eslint-disable-next-line no-unused-vars const { test, expect } = require('../../../../baseFixtures'); +const { createDomainObjectWithDefaults } = require('../../../../appActions'); test.describe('Notebook CRUD Operations', () => { test.fixme('Can create a Notebook Object', async ({ page }) => { @@ -67,10 +68,32 @@ test.describe('Default Notebook', () => { test.describe('Notebook section tests', () => { //The following test cases are associated with Notebook Sections - test.fixme('New sections are automatically named Unnamed Section with Unnamed Page', async ({ page }) => { - //Create new notebook A - //Add section - //Verify new section and new page details + test.beforeEach(async ({ page }) => { + //Navigate to baseURL + await page.goto('./', { waitUntil: 'networkidle' }); + + // Create Notebook + await createDomainObjectWithDefaults(page, { + type: 'Notebook', + name: "Test Notebook" + }); + }); + test('Default and new sections are automatically named Unnamed Section with Unnamed Page', async ({ page }) => { + // Check that the default section and page are created and the name matches the defaults + const defaultSectionName = await page.locator('.c-notebook__sections .c-list__item__name').textContent(); + expect(defaultSectionName).toBe('Unnamed Section'); + const defaultPageName = await page.locator('.c-notebook__pages .c-list__item__name').textContent(); + expect(defaultPageName).toBe('Unnamed Page'); + + // Expand sidebar and add a section + await page.locator('.c-notebook__toggle-nav-button').click(); + await page.locator('.js-sidebar-sections .c-icon-button.icon-plus').click(); + + // Check that new section and page within the new section match the defaults + const newSectionName = await page.locator('.c-notebook__sections .c-list__item__name').nth(1).textContent(); + expect(newSectionName).toBe('Unnamed Section'); + const newPageName = await page.locator('.c-notebook__pages .c-list__item__name').textContent(); + expect(newPageName).toBe('Unnamed Page'); }); test.fixme('Section selection operations and associated behavior', async ({ page }) => { //Create new notebook A @@ -107,6 +130,38 @@ test.describe('Notebook section tests', () => { test.describe('Notebook page tests', () => { //The following test cases are associated with Notebook Pages + test.beforeEach(async ({ page }) => { + //Navigate to baseURL + await page.goto('./', { waitUntil: 'networkidle' }); + + // Create Notebook + await createDomainObjectWithDefaults(page, { + type: 'Notebook', + name: "Test Notebook" + }); + }); + //Test will need to be implemented after a refactor in #5713 + // eslint-disable-next-line playwright/no-skipped-test + test.skip('Delete page popup is removed properly on clicking dropdown again', async ({ page }) => { + test.info().annotations.push({ + type: 'issue', + description: 'https://github.com/nasa/openmct/issues/5713' + }); + // Expand sidebar and add a second page + await page.locator('.c-notebook__toggle-nav-button').click(); + await page.locator('text=Page Add >> button').click(); + + // Click on the 2nd page dropdown button and expect the Delete Page option to appear + await page.locator('button[title="Open context menu"]').nth(2).click(); + await expect(page.locator('text=Delete Page')).toBeEnabled(); + // Clicking on the same page a second time causes the same Delete Page option to recreate + await page.locator('button[title="Open context menu"]').nth(2).click(); + await expect(page.locator('text=Delete Page')).toBeEnabled(); + // Clicking on the first page causes the first delete button to detach and recreate on the first page + await page.locator('button[title="Open context menu"]').nth(1).click(); + const numOfDeletePagePopups = await page.locator('li[title="Delete Page"]').count(); + expect(numOfDeletePagePopups).toBe(1); + }); test.fixme('Page selection operations and associated behavior', async ({ page }) => { //Create new notebook A //Delete existing Page diff --git a/src/plugins/notebook/components/PopupMenu.vue b/src/plugins/notebook/components/PopupMenu.vue index 3fb392432c..36fde27861 100644 --- a/src/plugins/notebook/components/PopupMenu.vue +++ b/src/plugins/notebook/components/PopupMenu.vue @@ -1,7 +1,7 @@