diff --git a/hat/assets/js/apps/Iaso/domains/users/components/PermissionSwitch.tsx b/hat/assets/js/apps/Iaso/domains/users/components/PermissionSwitch.tsx index ee5b76301e..d476865698 100644 --- a/hat/assets/js/apps/Iaso/domains/users/components/PermissionSwitch.tsx +++ b/hat/assets/js/apps/Iaso/domains/users/components/PermissionSwitch.tsx @@ -21,7 +21,7 @@ const PermissionSwitch: React.FunctionComponent = ({ if (!settings.row.original.group) { return ( { diff --git a/hat/assets/js/cypress/fixtures/permissions/grouped.json b/hat/assets/js/cypress/fixtures/permissions/grouped.json new file mode 100644 index 0000000000..276e090e38 --- /dev/null +++ b/hat/assets/js/cypress/fixtures/permissions/grouped.json @@ -0,0 +1,232 @@ +{ + "permissions": { + "forms": [ + { + "id": 380, + "name": "Formulaires", + "codename": "iaso_forms" + }, + { + "id": 469, + "name": "Soumissions", + "codename": "iaso_submissions" + }, + { + "id": 532, + "name": "Editer soumissions", + "codename": "iaso_update_submission" + }, + { + "id": 622, + "name": "Completeness stats", + "codename": "iaso_completeness_stats" + } + ], + "org_units": [ + { + "id": 383, + "name": "Unités d'organistations", + "codename": "iaso_org_units" + }, + { + "id": 384, + "name": "Correspondances sources", + "codename": "iaso_links" + }, + { + "id": 399, + "name": "Sources", + "codename": "iaso_sources" + }, + { + "id": 669, + "name": "Org unit types", + "codename": "iaso_org_unit_types" + }, + { + "id": 674, + "name": "Org unit groups", + "codename": "iaso_org_unit_groups" + }, + { + "id": 694, + "name": "Write data source", + "codename": "iaso_write_sources" + }, + { + "id": 782, + "name": "Org unit change request review", + "codename": "iaso_org_unit_change_request_review" + }, + { + "id": 828, + "name": "Editer le Registre", + "codename": "iaso_registry_write" + }, + { + "id": 829, + "name": "Lire le Registre", + "codename": "iaso_registry_read" + } + ], + "entities": [ + { + "id": 575, + "name": "Entities", + "codename": "iaso_entities" + }, + { + "id": 640, + "name": "Workflows", + "codename": "iaso_workflows" + }, + { + "id": 655, + "name": "Read Entity duplicates", + "codename": "iaso_entity_duplicates_read" + }, + { + "id": 656, + "name": "Write Entity duplicates", + "codename": "iaso_entity_duplicates_write" + }, + { + "id": 693, + "name": "Write entity type", + "codename": "iaso_entity_type_write" + } + ], + "dhis2_mapping": [ + { + "id": 381, + "name": "Correspondances avec DHIS2", + "codename": "iaso_mappings" + } + ], + "external_storage": [ + { + "id": 588, + "name": "Strorages", + "codename": "iaso_storages" + } + ], + "planning": [ + { + "id": 540, + "name": "Attributions", + "codename": "iaso_assignments" + } + ], + "embedded_links": [ + { + "id": 435, + "name": "Pages", + "codename": "iaso_pages" + }, + { + "id": 695, + "name": "Write page", + "codename": "iaso_page_write" + } + ], + "polio": [ + { + "id": 464, + "name": "Polio", + "codename": "iaso_polio" + }, + { + "id": 483, + "name": "Polio config", + "codename": "iaso_polio_config" + }, + { + "id": 553, + "name": "Budget Polio", + "codename": "iaso_polio_budget" + }, + { + "id": 641, + "name": "Budget Polio Admin", + "codename": "iaso_polio_budget_admin" + }, + { + "id": 696, + "name": "Polio Vaccine Authorizations Read Only", + "codename": "iaso_polio_vaccine_authorizations_read_only" + }, + { + "id": 697, + "name": "Polio Vaccine Authorizations Admin", + "codename": "iaso_polio_vaccine_authorizations_admin" + }, + { + "id": 709, + "name": "Polio notifications", + "codename": "iaso_polio_notifications" + }, + { + "id": 710, + "name": "Polio Vaccine Supply Chain Read", + "codename": "iaso_polio_vaccine_supply_chain_read" + }, + { + "id": 711, + "name": "Polio Vaccine Supply Chain Write", + "codename": "iaso_polio_vaccine_supply_chain_write" + }, + { + "id": 783, + "name": "Polio Vaccine Stock Management Read", + "codename": "iaso_polio_vaccine_stock_management_read" + }, + { + "id": 784, + "name": "Polio Vaccine Stock Management Write", + "codename": "iaso_polio_vaccine_stock_management_write" + } + ], + "admin": [ + { + "id": 385, + "name": "Utilisateurs", + "codename": "iaso_users" + }, + { + "id": 398, + "name": "Projets", + "codename": "iaso_projects" + }, + { + "id": 408, + "name": "Tâches", + "codename": "iaso_data_tasks" + }, + { + "id": 539, + "name": "Equipes", + "codename": "iaso_teams" + }, + { + "id": 650, + "name": "Reports", + "codename": "iaso_reports" + }, + { + "id": 675, + "name": "Manage user roles", + "codename": "iaso_user_roles" + }, + { + "id": 692, + "name": "Users managed", + "codename": "iaso_users_managed" + }, + { + "id": 708, + "name": "modules", + "codename": "iaso_modules" + } + ] + } +} \ No newline at end of file diff --git a/hat/assets/js/cypress/fixtures/permissions/list.json b/hat/assets/js/cypress/fixtures/permissions/list.json index 6ce746fea4..8319578646 100644 --- a/hat/assets/js/cypress/fixtures/permissions/list.json +++ b/hat/assets/js/cypress/fixtures/permissions/list.json @@ -1,9 +1,24 @@ { "permissions": [ { - "id": 382, - "name": "Complétude des données", - "codename": "iaso_completeness" + "id": 540, + "name": "Attributions", + "codename": "iaso_assignments" + }, + { + "id": 553, + "name": "Budget Polio", + "codename": "iaso_polio_budget" + }, + { + "id": 641, + "name": "Budget Polio Admin", + "codename": "iaso_polio_budget_admin" + }, + { + "id": 622, + "name": "Completeness stats", + "codename": "iaso_completeness_stats" }, { "id": 381, @@ -15,31 +30,121 @@ "name": "Correspondances sources", "codename": "iaso_links" }, + { + "id": 828, + "name": "Editer le Registre", + "codename": "iaso_registry_write" + }, + { + "id": 532, + "name": "Editer soumissions", + "codename": "iaso_update_submission" + }, + { + "id": 575, + "name": "Entities", + "codename": "iaso_entities" + }, + { + "id": 539, + "name": "Equipes", + "codename": "iaso_teams" + }, { "id": 380, "name": "Formulaires", "codename": "iaso_forms" }, + { + "id": 829, + "name": "Lire le Registre", + "codename": "iaso_registry_read" + }, + { + "id": 675, + "name": "Manage user roles", + "codename": "iaso_user_roles" + }, + { + "id": 782, + "name": "Org unit change request review", + "codename": "iaso_org_unit_change_request_review" + }, + { + "id": 674, + "name": "Org unit groups", + "codename": "iaso_org_unit_groups" + }, + { + "id": 669, + "name": "Org unit types", + "codename": "iaso_org_unit_types" + }, { "id": 435, "name": "Pages", "codename": "iaso_pages" }, { - "id": 460, + "id": 464, "name": "Polio", "codename": "iaso_polio" }, + { + "id": 697, + "name": "Polio Vaccine Authorizations Admin", + "codename": "iaso_polio_vaccine_authorizations_admin" + }, + { + "id": 696, + "name": "Polio Vaccine Authorizations Read Only", + "codename": "iaso_polio_vaccine_authorizations_read_only" + }, + { + "id": 783, + "name": "Polio Vaccine Stock Management Read", + "codename": "iaso_polio_vaccine_stock_management_read" + }, + { + "id": 784, + "name": "Polio Vaccine Stock Management Write", + "codename": "iaso_polio_vaccine_stock_management_write" + }, + { + "id": 710, + "name": "Polio Vaccine Supply Chain Read", + "codename": "iaso_polio_vaccine_supply_chain_read" + }, + { + "id": 711, + "name": "Polio Vaccine Supply Chain Write", + "codename": "iaso_polio_vaccine_supply_chain_write" + }, { "id": 483, "name": "Polio config", "codename": "iaso_polio_config" }, + { + "id": 709, + "name": "Polio notifications", + "codename": "iaso_polio_notifications" + }, { "id": 398, "name": "Projets", "codename": "iaso_projects" }, + { + "id": 655, + "name": "Read Entity duplicates", + "codename": "iaso_entity_duplicates_read" + }, + { + "id": 650, + "name": "Reports", + "codename": "iaso_reports" + }, { "id": 469, "name": "Soumissions", @@ -50,6 +155,11 @@ "name": "Sources", "codename": "iaso_sources" }, + { + "id": 588, + "name": "Strorages", + "codename": "iaso_storages" + }, { "id": 408, "name": "Tâches", @@ -57,13 +167,48 @@ }, { "id": 383, - "name": "Unités d'organisations", + "name": "Unités d'organistations", "codename": "iaso_org_units" }, + { + "id": 692, + "name": "Users managed", + "codename": "iaso_users_managed" + }, { "id": 385, "name": "Utilisateurs", "codename": "iaso_users" + }, + { + "id": 640, + "name": "Workflows", + "codename": "iaso_workflows" + }, + { + "id": 656, + "name": "Write Entity duplicates", + "codename": "iaso_entity_duplicates_write" + }, + { + "id": 694, + "name": "Write data source", + "codename": "iaso_write_sources" + }, + { + "id": 693, + "name": "Write entity type", + "codename": "iaso_entity_type_write" + }, + { + "id": 695, + "name": "Write page", + "codename": "iaso_page_write" + }, + { + "id": 708, + "name": "modules", + "codename": "iaso_modules" } ] -} +} \ No newline at end of file diff --git a/hat/assets/js/cypress/integration/02 - forms/list.spec.js b/hat/assets/js/cypress/integration/02 - forms/list.spec.js index 08cafb92e6..43da9898a9 100644 --- a/hat/assets/js/cypress/integration/02 - forms/list.spec.js +++ b/hat/assets/js/cypress/integration/02 - forms/list.spec.js @@ -1,12 +1,12 @@ /// +import * as Permission from '../../../apps/Iaso/utils/permissions.ts'; +import { search, searchWithForbiddenChars } from '../../constants/search'; import listFixture from '../../fixtures/forms/list.json'; import superUser from '../../fixtures/profiles/me/superuser.json'; -import { search, searchWithForbiddenChars } from '../../constants/search'; import { testSearchField } from '../../support/testSearchField'; -import { testTopBar } from '../../support/testTopBar'; import { testTablerender } from '../../support/testTableRender'; -import * as Permission from '../../../apps/Iaso/utils/permissions.ts'; +import { testTopBar } from '../../support/testTopBar'; const siteBaseUrl = Cypress.env('siteBaseUrl'); @@ -188,7 +188,7 @@ describe('Forms', () => { const actionCol = row.find('td').last(); actionCol.find('button').should('have.length', 3); }); - it('should display 2 buttons if user has iaso_submissions permission', () => { + it('should display 1 buttons if user has iaso_submissions permission', () => { goToPage({ ...superUser, permissions: [Permission.SUBMISSIONS], @@ -197,7 +197,7 @@ describe('Forms', () => { table = cy.get('table'); row = table.find('tbody').find('tr').eq(0); const actionCol = row.find('td').last(); - actionCol.find('button').should('have.length', 2); + actionCol.find('button').should('have.length', 1); }); }); }); diff --git a/hat/assets/js/cypress/integration/03 - Users/list.spec.js b/hat/assets/js/cypress/integration/03 - Users/list.spec.js index 2e70e9de8d..ecf6e44e19 100644 --- a/hat/assets/js/cypress/integration/03 - Users/list.spec.js +++ b/hat/assets/js/cypress/integration/03 - Users/list.spec.js @@ -1,10 +1,10 @@ /// import { search, searchWithForbiddenChars } from '../../constants/search'; +import orgUnits from '../../fixtures/orgunits/list.json'; import listFixture from '../../fixtures/profiles/list.json'; import superUser from '../../fixtures/profiles/me/superuser.json'; import { testSearchField } from '../../support/testSearchField'; -import orgUnits from '../../fixtures/orgunits/list.json'; const siteBaseUrl = Cypress.env('siteBaseUrl'); const baseUrl = `${siteBaseUrl}/dashboard/settings/users`; @@ -37,6 +37,9 @@ const goToPage = ( cy.intercept('GET', '/api/permissions', { fixture: 'permissions/list.json', }); + cy.intercept('GET', '/api/permissions/grouped_permissions', { + fixture: 'permissions/grouped.json', + }); cy.intercept('GET', '/api/v2/orgunittypes/**', { fixture: 'orgunittypes/list.json', }); @@ -178,7 +181,7 @@ describe('Users', () => { cy.testInputValue(`#user_roles`, ''); cy.testInputValue('#language', ''); cy.get('#user-dialog-tabs').find('button').eq(1).click(); - cy.get('.permission-checkbox').each($el => { + cy.get('[data-test="permission-checkbox"] input').each($el => { expect($el).to.not.be.checked; }); }); @@ -206,7 +209,7 @@ describe('Users', () => { cy.get('.MuiDialogActions-root').find('button').first().click(); openDialogForUserIndex(1); cy.get('#user-dialog-tabs').find('button').eq(1).click(); - cy.get('.permission-checkbox').each($el => { + cy.get('[data-test="permission-checkbox"] input').each($el => { expect($el).to.not.be.checked; }); cy.get('.MuiDialogActions-root').find('button').first().click(); @@ -311,7 +314,7 @@ describe('Users', () => { order: 'user__username', orgUnitTypes: '11', page: '1', - permissions: 'iaso_completeness,iaso_mappings', + permissions: 'iaso_assignments,iaso_polio_budget', projects: '1,2', search: 'ZELDA', teams: '25,26',