From eca90c4555c9977b1ec74cfd2fc1d312a80a0f78 Mon Sep 17 00:00:00 2001 From: asuresh-code <69875854+asuresh-code@users.noreply.github.com> Date: Wed, 4 Sep 2024 13:10:53 +0100 Subject: [PATCH] Add tooltips to all Icon buttons #633 (#875) * Added tooltip to Home breadcrumbs. Unit tests failing due to snapshot differences, need to inspect further * update snapshots for unit tests #633 * Add tooltip to Systems add icon. Update all corresponding tests #633 * add tooltips to catalogue card (select, and actions). * Add tooltips to catalogue category (add category) #633 * adjust tooltip offsets #633 * add missing tooltip icons to catalogue related dialogs #633 * updated snaphots #633 * remove offsets from tooltips #633 * added span to address Test warnings * update corresponding snapshots * update test to address CI warning on wrapping state updates in act * undo previous commit. Addresses lint errors (no-unnecessary-act) * add console.log to debug CI test statements to see what is not wrapped with act * add act() to modifyValues after console messages * try moving act to waitFor * copy format from succeeding test PR * forgot to add these changes * remove unused import * Revert "remove unused import" This reverts commit b6c9c2964430c5e97013ce6333b641e58c3f7bfa. * Revert "forgot to add these changes" This reverts commit 261fe748e95a0eba78cc8084fb3333889b70da13. * Revert "copy format from succeeding test PR" This reverts commit 8fd0e18b98e85aaf62072d2153b5f217fc1d7292. * Revert "try moving act to waitFor" This reverts commit e722b7cf42b7e67a0619e3c64bfe56a6005a2864. * Revert "add act() to modifyValues after console messages" This reverts commit 3b99cdd15469943b7d6c5993f6269be444a20ea9. * Revert "add console.log to debug CI test statements to see what is not wrapped with act" This reverts commit 02407a08b519eec5183a7b973b6959849a770d7e. * remove Home breadcrumbs to see if it's the only tooltip causing warnings * Revert "remove Home breadcrumbs to see if it's the only tooltip causing warnings" This reverts commit 89e45f0ee9a57fbc5a07ab96c488abad18876dcd. * add specific Home Labels #633 * changed implementation from a map to a function * refactor label implementation #633 * update unit snapshots and test files's aria label, and mislabeled hoem in itemDialog #633 * update e2e manufacturer test's aria label * reformat homeLocation expression --- cypress/e2e/with_api/systems/functions.ts | 2 +- .../e2e/with_mock_data/manufacturers.cy.ts | 4 +- cypress/e2e/with_mock_data/systems.cy.ts | 14 +- src/admin/admin.component.tsx | 2 +- src/catalogue/catalogue.component.tsx | 23 +- ...oguePropertiesForm.component.test.tsx.snap | 562 ++++++++++-------- ...aloguePropertyForm.component.test.tsx.snap | 126 ++-- .../category/catalogueCard.component.tsx | 51 +- ...logueCategoryDirectoryDialog.component.tsx | 2 +- .../cataloguePropertiesForm.component.tsx | 19 +- .../cataloguePropertyForm.component.tsx | 17 +- ...talogueItemsDialog.component.test.tsx.snap | 46 +- ...atalogueItemsTable.component.test.tsx.snap | 8 +- ...catalogueItemDirectoryDialog.component.tsx | 2 +- .../items/catalogueItemsDialog.component.tsx | 18 +- .../catalogueItemsLandingPage.component.tsx | 2 +- ...leteCatalogueItemDialog.component.test.tsx | 4 +- .../obsoleteCatalogueItemDialog.component.tsx | 2 +- src/items/itemDialog.component.tsx | 2 +- src/items/items.component.tsx | 2 +- src/items/itemsLandingPage.component.tsx | 2 +- .../manufacturer.component.test.tsx.snap | 62 +- .../manufacturer.component.test.tsx | 2 +- src/manufacturer/manufacturer.component.tsx | 2 +- ...manufacturerLandingPage.component.test.tsx | 4 +- .../manufacturerLandingPage.component.tsx | 2 +- .../systemItemsTable.component.test.tsx.snap | 8 +- .../systemDirectoryDialog.component.tsx | 2 +- src/systems/systemItemsDialog.component.tsx | 2 +- src/systems/systems.component.test.tsx | 4 +- src/systems/systems.component.tsx | 20 +- .../breadcrumbs.component.test.tsx.snap | 126 ++-- src/view/breadcrumbs.component.test.tsx | 2 +- src/view/breadcrumbs.component.tsx | 24 +- 34 files changed, 648 insertions(+), 522 deletions(-) diff --git a/cypress/e2e/with_api/systems/functions.ts b/cypress/e2e/with_api/systems/functions.ts index fa1b95e87..24186bc3b 100644 --- a/cypress/e2e/with_api/systems/functions.ts +++ b/cypress/e2e/with_api/systems/functions.ts @@ -13,7 +13,7 @@ export const modifySystem = ( cy.findAllByLabelText('Row Actions').eq(values.index).click(); cy.findByText('Edit').click(); } else { - cy.findByRole('button', { name: 'add system' }).click(); + cy.findByRole('button', { name: 'Add System' }).click(); } cy.findByLabelText('Name *').clear(); cy.findByLabelText('Name *').type(values.name); diff --git a/cypress/e2e/with_mock_data/manufacturers.cy.ts b/cypress/e2e/with_mock_data/manufacturers.cy.ts index 7250b2fa0..62a7319e0 100644 --- a/cypress/e2e/with_mock_data/manufacturers.cy.ts +++ b/cypress/e2e/with_mock_data/manufacturers.cy.ts @@ -348,7 +348,7 @@ describe('Manufacturer', () => { cy.findByText('Manufacturer A').click(); cy.findByText('Telephone number:').should('exist'); - cy.findByRole('button', { name: 'navigate to manufacturer home' }).click(); + cy.findByRole('button', { name: 'navigate to manufacturers home' }).click(); cy.findByText('Manufacturer A').should('exist'); cy.findByText('Manufacturer B').should('exist'); @@ -382,7 +382,7 @@ describe('Manufacturer', () => { `This manufacturer doesn't exist. Please click the Home button to navigate to the manufacturer table` ).should('exist'); - cy.findByRole('button', { name: 'navigate to manufacturer home' }).click(); + cy.findByRole('button', { name: 'navigate to manufacturers home' }).click(); cy.findByText('Manufacturer A').should('exist'); cy.findByText('Manufacturer B').should('exist'); diff --git a/cypress/e2e/with_mock_data/systems.cy.ts b/cypress/e2e/with_mock_data/systems.cy.ts index 99829e7f4..f8b2f27f9 100644 --- a/cypress/e2e/with_mock_data/systems.cy.ts +++ b/cypress/e2e/with_mock_data/systems.cy.ts @@ -259,7 +259,7 @@ describe('Systems', () => { describe('Add', () => { it('adds a root system with only required parameters', () => { - cy.findByRole('button', { name: 'add system' }).click(); + cy.findByRole('button', { name: 'Add System' }).click(); cy.findByLabelText('Name *').type('System name'); cy.startSnoopingBrowserMockedRequest(); @@ -282,7 +282,7 @@ describe('Systems', () => { }); it('adds a root system with all parameters', () => { - cy.findByRole('button', { name: 'add system' }).click(); + cy.findByRole('button', { name: 'Add System' }).click(); cy.findByLabelText('Name *').type('System name'); cy.findByLabelText('Description').type('System description'); @@ -316,7 +316,7 @@ describe('Systems', () => { it('adds a subsystem', () => { cy.visit('/systems/65328f34a40ff5301575a4e3'); - cy.findByRole('button', { name: 'add subsystem' }).click(); + cy.findByRole('button', { name: 'Add Subsystem' }).click(); cy.findByLabelText('Name *').type('System name'); cy.startSnoopingBrowserMockedRequest(); @@ -342,19 +342,19 @@ describe('Systems', () => { it('displays error message when name is not given that disappears once closed', () => { cy.visit('/systems'); - cy.findByRole('button', { name: 'add system' }).click(); + cy.findByRole('button', { name: 'Add System' }).click(); cy.findByRole('button', { name: 'Save' }).click(); cy.findByText('Please enter a name.').should('be.visible'); cy.findByRole('button', { name: 'Save' }).should('be.disabled'); cy.findByRole('button', { name: 'Cancel' }).click(); - cy.findByRole('button', { name: 'add system' }).click(); + cy.findByRole('button', { name: 'Add System' }).click(); cy.findByText('Please enter a name.').should('not.exist'); }); it('displays error message if the system has a duplicate name that disappears once closed', () => { cy.visit('/systems'); - cy.findByRole('button', { name: 'add system' }).click(); + cy.findByRole('button', { name: 'Add System' }).click(); cy.findByLabelText('Name *').type('Error 409'); cy.findByRole('button', { name: 'Save' }).click(); cy.findByText( @@ -362,7 +362,7 @@ describe('Systems', () => { ).should('be.visible'); cy.findByRole('button', { name: 'Save' }).should('be.disabled'); cy.findByRole('button', { name: 'Cancel' }).click(); - cy.findByRole('button', { name: 'add system' }).click(); + cy.findByRole('button', { name: 'Add System' }).click(); cy.findByText( 'A System with the same name already exists within the same parent System. Please enter a different name.' ).should('not.exist'); diff --git a/src/admin/admin.component.tsx b/src/admin/admin.component.tsx index 959d80e4a..87bae5d64 100644 --- a/src/admin/admin.component.tsx +++ b/src/admin/admin.component.tsx @@ -69,7 +69,7 @@ function AdminPage() { onChangeNode={navigateToAdminFunction} breadcrumbsInfo={adminBreadCrumbs} onChangeNavigateHome={() => navigateToAdminFunction(null)} - navigateHomeAriaLabel={'navigate to admin page'} + homeLocation="Admin" /> diff --git a/src/catalogue/catalogue.component.tsx b/src/catalogue/catalogue.component.tsx index 7c29623f4..a53ff01af 100644 --- a/src/catalogue/catalogue.component.tsx +++ b/src/catalogue/catalogue.component.tsx @@ -10,6 +10,7 @@ import { IconButton, LinearProgress, Typography, + Tooltip, } from '@mui/material'; import React from 'react'; import { useLocation, useNavigate } from 'react-router-dom'; @@ -75,14 +76,18 @@ const AddCategoryButton = (props: AddCatalogueButtonProps) => { return ( <> - setAddCategoryDialogOpen(true)} - disabled={props.disabled} - aria-label="add catalogue category" - > - - + + + setAddCategoryDialogOpen(true)} + disabled={props.disabled} + aria-label="add catalogue category" + > + + + + setAddCategoryDialogOpen(false)} @@ -306,7 +311,7 @@ function Catalogue() { onChangeNode={navigateToCatalogue} breadcrumbsInfo={catalogueBreadcrumbs} onChangeNavigateHome={() => navigateToCatalogue(null)} - navigateHomeAriaLabel={'navigate to catalogue home'} + homeLocation="Catalogue" /> renders correctly 1`] = `
- + +
@@ -732,27 +738,33 @@ exports[`Catalogue Properties Form > renders correctly 1`] = `
- + +
@@ -1260,27 +1272,33 @@ exports[`Catalogue Properties Form > renders correctly 1`] = `
- + +
@@ -1788,27 +1806,33 @@ exports[`Catalogue Properties Form > renders correctly 1`] = `
- + +
@@ -2190,52 +2214,64 @@ exports[`Catalogue Properties Form > renders correctly 1`] = `
- + +
- + + `; @@ -2264,7 +2300,7 @@ exports[`Catalogue Properties Form > renders correctly for migration dialog 1`] @@ -2313,8 +2349,8 @@ exports[`Catalogue Properties Form > renders correctly for migration dialog 1`]