diff --git a/graph/client-e2e/src/integration/app.spec.ts b/graph/client-e2e/src/integration/app.spec.ts index a002605ca2..85533e97f4 100644 --- a/graph/client-e2e/src/integration/app.spec.ts +++ b/graph/client-e2e/src/integration/app.spec.ts @@ -12,12 +12,13 @@ import { getSelectProjectsMessage, getTextFilterInput, getTextFilterReset, + getToggleAllButtonForFolder, getUncheckedProjectItems, getUnfocusProjectButton, } from '../support/app.po'; -import * as nxExamplesJson from '../fixtures/nx-examples.json'; import * as affectedJson from '../fixtures/affected.json'; +import * as nxExamplesJson from '../fixtures/nx-examples.json'; describe('graph-client', () => { before(() => { @@ -229,6 +230,28 @@ describe('graph-client', () => { }); }); + describe('toggle all projects in folder button', () => { + it('should check all projects in folder if at least one project checked', () => { + cy.contains('shared-product-state').scrollIntoView().should('be.visible'); + cy.get('[data-project="shared-product-state"]').should('be.visible'); + cy.get('[data-project="shared-product-state"]').click({ force: true }); + getToggleAllButtonForFolder('shared/product').click({ force: true }); + getCheckedProjectItems().should('have.length', 4); + }); + + it('should check all projects in folder if no projects checked yet', () => { + getToggleAllButtonForFolder('shared').click({ force: true }); + getCheckedProjectItems().should('have.length', 5); + }); + + it('should uncheck all projects in folder if all projects checked yet', () => { + getToggleAllButtonForFolder('shared').click({ force: true }); + getCheckedProjectItems().should('have.length', 5); + getToggleAllButtonForFolder('shared').click({ force: true }); + getCheckedProjectItems().should('have.length', 0); + }); + }); + describe('image download button', () => { it('should be hidden initally', () => { getImageDownloadButton().should('have.class', 'opacity-0'); diff --git a/graph/client-e2e/src/support/app.po.ts b/graph/client-e2e/src/support/app.po.ts index 25d230a03f..33c5a80199 100644 --- a/graph/client-e2e/src/support/app.po.ts +++ b/graph/client-e2e/src/support/app.po.ts @@ -32,3 +32,6 @@ export const getImageDownloadButton = () => export const getFocusButtonForProject = (projectName: string) => cy.get(`[data-cy="focus-button-${projectName}"]`); + +export const getToggleAllButtonForFolder = (folderName: string) => + cy.get(`[data-cy="toggle-folder-visibility-button-${folderName}"]`); diff --git a/graph/client/src/app/sidebar/project-list.tsx b/graph/client/src/app/sidebar/project-list.tsx index e88736e3d4..b232772767 100644 --- a/graph/client/src/app/sidebar/project-list.tsx +++ b/graph/client/src/app/sidebar/project-list.tsx @@ -187,12 +187,41 @@ function SubProjectList({ } } + function toggleAllProjects(currentlySelected: boolean) { + if (currentlySelected) { + projects.forEach((project) => + deselectProject(project.projectGraphNode.name) + ); + } else { + projects.forEach((project) => + selectProject(project.projectGraphNode.name) + ); + } + } + + const allProjectsSelected = projects.every((project) => project.isSelected); + return ( <> {headerText !== '' ? ( -

- {headerText} -

+
+

+ {headerText} +

+ + toggleAllProjects(allProjectsSelected)} + > + + +
) : null}