From b869b7152a90f5d6e231471e5f2971ea2bb4a9ca Mon Sep 17 00:00:00 2001 From: Philip Fulcher Date: Tue, 1 Nov 2022 14:39:25 -0600 Subject: [PATCH] chore(graph): change select by directory behavior when some projects are selected --- graph/client-e2e/src/integration/app.spec.ts | 11 +++++++++-- graph/client/src/app/sidebar/project-list.tsx | 6 +++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/graph/client-e2e/src/integration/app.spec.ts b/graph/client-e2e/src/integration/app.spec.ts index 6d15e2458f07aa..243af9c5680d34 100644 --- a/graph/client-e2e/src/integration/app.spec.ts +++ b/graph/client-e2e/src/integration/app.spec.ts @@ -231,18 +231,25 @@ describe('graph-client', () => { }); describe('toggle all projects in folder button', () => { - it('should uncheck all projects in folder if at least one project checked', () => { + 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', 0); + 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', () => { diff --git a/graph/client/src/app/sidebar/project-list.tsx b/graph/client/src/app/sidebar/project-list.tsx index ac1526134f0f97..b2327727673c6e 100644 --- a/graph/client/src/app/sidebar/project-list.tsx +++ b/graph/client/src/app/sidebar/project-list.tsx @@ -199,7 +199,7 @@ function SubProjectList({ } } - const someProjectsSelected = projects.some((project) => project.isSelected); + const allProjectsSelected = projects.every((project) => project.isSelected); return ( <> @@ -211,13 +211,13 @@ function SubProjectList({ toggleAllProjects(someProjectsSelected)} + onClick={() => toggleAllProjects(allProjectsSelected)} >