From 78b409dbc4379d6ebadc1b7094bdc2e0d85d0526 Mon Sep 17 00:00:00 2001 From: midmarch Date: Wed, 8 Mar 2023 14:51:36 +0100 Subject: [PATCH] Remove "Super users" from organization detail / preview page Changes: - Dictionary: Rename label "Administrating positions" to "Assigned Super Users" - Remove Super-user listing of organisation positions. - DB-test-data: Andrew ('EF 1 Manager') is a super-user of 'EF 1' organisation. - e2e-tests: Adapt (fix) tests Resolves #4281 --- anet-dictionary.yml | 4 +- .../previews/OrganizationPreview.js | 37 +---------- client/src/pages/organizations/Laydown.js | 5 +- client/src/pages/organizations/Show.js | 41 +----------- client/tests/e2e/permissions.js | 55 ++++++++-------- insertBaseData-psql.sql | 64 ++++++++++--------- testDictionaries/no-custom-fields.yml | 4 +- 7 files changed, 72 insertions(+), 138 deletions(-) diff --git a/anet-dictionary.yml b/anet-dictionary.yml index 08055fd4cd..1b03bd8618 100644 --- a/anet-dictionary.yml +++ b/anet-dictionary.yml @@ -1199,7 +1199,7 @@ fields: location: filter: [ADVISOR_LOCATION] administratingPositions: - label: Administrating positions + label: Assigned Super Users placeholder: Search for a position... principal: @@ -1428,7 +1428,7 @@ fields: location: filter: [PRINCIPAL_LOCATION] administratingPositions: - label: Administrating positions + label: Assigned Super Users placeholder: Search for a position... superUser: diff --git a/client/src/components/previews/OrganizationPreview.js b/client/src/components/previews/OrganizationPreview.js index 29a19611af..c9e9dcc60a 100644 --- a/client/src/components/previews/OrganizationPreview.js +++ b/client/src/components/previews/OrganizationPreview.js @@ -3,7 +3,7 @@ import API from "api" import { PreviewField } from "components/FieldHelper" import LinkTo from "components/LinkTo" import Model from "components/Model" -import { Organization, Position } from "models" +import { Organization } from "models" import OrganizationLaydown from "pages/organizations/Laydown" import OrganizationTasks from "pages/organizations/OrganizationTasks" import PropTypes from "prop-types" @@ -109,14 +109,6 @@ const OrganizationPreview = ({ className, uuid }) => { ? Settings.fields.principal.org : Settings.fields.advisor.org - const superUsers = organization.positions.filter( - pos => - pos.status !== Model.STATUS.INACTIVE && - (!pos.person || pos.person.status !== Model.STATUS.INACTIVE) && - (pos.type === Position.TYPE.SUPER_USER || - pos.type === Position.TYPE.ADMINISTRATOR) - ) - return (
@@ -156,33 +148,6 @@ const OrganizationPreview = ({ className, uuid }) => { /> )} - {organization.isAdvisorOrg() && ( - - {superUsers.map(position => ( -

- {position.person ? ( - - ) : ( - - - - (Unfilled) - - )} -

- ))} - {superUsers.length === 0 && ( -

- No super users -

- )} - - } - /> - )} - {organization?.childrenOrgs?.length > 0 && ( { ) } > - + { ? Settings.fields.principal.org : Settings.fields.advisor.org - const superUsers = organization.positions.filter( - pos => - pos.status !== Model.STATUS.INACTIVE && - (!pos.person || pos.person.status !== Model.STATUS.INACTIVE) && - (pos.type === Position.TYPE.SUPER_USER || - pos.type === Position.TYPE.ADMINISTRATOR) - ) const myOrg = currentUser && currentUser.position ? currentUser.position.organization @@ -409,38 +402,6 @@ const OrganizationShow = ({ pageDispatchers }) => { /> )} - {organization.isAdvisorOrg() && ( - - {superUsers.map(position => ( -

- {position.person ? ( - - ) : ( - - - - (Unfilled) - - )} -

- ))} - {superUsers.length === 0 && ( -

- No super users -

- )} - - } - /> - )} - {organization.childrenOrgs && organization.childrenOrgs.length > 0 && ( { +test.serial("checking super-user permissions", async t => { t.plan(13) const { @@ -28,8 +28,8 @@ test.serial("checking super user permissions", async t => { const $tooltip = await $("#role_ADVISOR_tooltip") t.regex( await $tooltip.getAttribute("title"), - /^Super users cannot create .*$/, - "Expected tooltip for super users" + /^Super-users cannot create .*$/, + "Expected tooltip for super-users" ) // Cancel Create Person @@ -54,7 +54,7 @@ test.serial("checking super user permissions", async t => { await validateUserCanEditUserForCurrentPage(t) - // User is super user, they may edit position of type super user for + // User is super-user, they may edit position of type super-user for // the organization their position is administrating await editAndSavePositionFromCurrentUserPage(t, true) @@ -69,12 +69,12 @@ test.serial("checking super user permissions", async t => { await validateUserCanEditUserForCurrentPage(t) - // User is super user, they may edit position of type super user for + // User is super-user, they may edit position of type super-user for // the organization their position is administrating await editAndSavePositionFromCurrentUserPage(t, true) - // User is super user, they may edit positions only for - // the organization their position is administrating + // User is super-user, they may edit positions only for + // organizations their position is assigned to const $otherOrgPositionLink = await getFromSearchResults( t, "EF 1 Manager", @@ -89,7 +89,7 @@ test.serial("checking super user permissions", async t => { await assertElementNotPresent( t, ".edit-position", - "super user should not be able to edit positions of the organization their position is not administrating", + "super-user should not be able to edit positions of the organization their position is not administrating", shortWaitMs ) @@ -123,16 +123,15 @@ test.serial("checking super user permissions", async t => { await $ownOrgPositionLink.click() await t.context.driver.wait(t.context.until.stalenessOf($ownOrgPositionLink)) - await assertElementNotPresent( - t, - ".edit-position", - "super user should not be able to edit positions of the organization their position is not administrating", - shortWaitMs + const $editPositionButton = await $(".edit-position") + await t.context.driver.wait( + t.context.until.elementIsVisible($editPositionButton) ) + t.pass('Jacob should be able to edit his own organization ("EF 2.2")') }) validateUserCannotEditOtherUser( - "super user cannot edit administrator", + "super-user cannot edit administrator", "rebecca", "arthur", "CIV DMIN, Arthur", @@ -140,11 +139,11 @@ validateUserCannotEditOtherUser( ) validateUserCannotEditOtherUser( - "super user cannot edit people from the organizations their position is not administrating", + "super-user cannot edit people from the organizations their position is not administrating", "jacob", - "rebecca", - "CTR BECCABON, Rebecca", - "EF 2.2 Final Reviewer" + "andrew", + "CIV ANDERSON, Andrew", + "EF 1 Manager" ) test.serial("checking regular user permissions", async t => { @@ -175,7 +174,7 @@ test.serial("checking regular user permissions", async t => { }) validateUserCannotEditOtherUser( - "Regular user cannot edit super user people or positions", + "Regular user cannot edit super-user people or positions", "jack", "rebecca", "CTR BECCABON, Rebecca", @@ -234,12 +233,14 @@ test.serial("checking admin permissions", async t => { await t.context.pageHelpers.clickMenuLinksButton() await t.context.pageHelpers.clickMyOrgLink() - const $arthurLink = await findSuperUserLink(t, "CIV DMIN, Arthur") - await $arthurLink.click() - await t.context.driver.wait(t.context.until.stalenessOf($arthurLink)) + + const element = await t.context.driver.findElement( + By.linkText("CIV DMIN, Arthur") + ) + await element.click() await validateUserCanEditUserForCurrentPage(t) - // User is admin, and can therefore edit an admin position type + // User is admin, and can therefore edit (its own) admin position type await editAndSavePositionFromCurrentUserPage(t, true) const $principalOrgLink = await getFromSearchResults( @@ -278,7 +279,7 @@ test.serial("admins can edit superusers and their positions", async t => { await t.context.driver.wait(t.context.until.stalenessOf($rebeccaPersonLink)) await validateUserCanEditUserForCurrentPage(t) - // User is admin, and can therefore edit a super user position type + // User is admin, and can therefore edit a super-user position type await editAndSavePositionFromCurrentUserPage(t, true) await t.context.logout() @@ -332,7 +333,9 @@ function validateUserCannotEditOtherUser( } async function findSuperUserLink(t, desiredSuperUserName) { - const $superUserLinks = await t.context.$$("[name=superUsers] p a") + const $superUserLinks = await t.context.$$( + "[id=super-user-table] tbody tr td:nth-child(4) span a" + ) let $foundLink for (const $superUserLink of $superUserLinks) { const superUserName = await $superUserLink.getText() @@ -424,7 +427,7 @@ async function validateSuperUserPrincipalOrgPermissions(t) { await assertElementNotPresent( t, "#editButton", - "Super users should not be able to edit principal organizations", + "Super-users should not be able to edit principal organizations", shortWaitMs ) } diff --git a/insertBaseData-psql.sql b/insertBaseData-psql.sql index a20e7cd6a2..84d59abb91 100644 --- a/insertBaseData-psql.sql +++ b/insertBaseData-psql.sql @@ -299,44 +299,44 @@ INSERT INTO organizations(uuid, "shortName", "longName", type, "createdAt", "upd VALUES ('70193ee9-05b4-4aac-80b5-75609825db9f', 'LNG','Linguistic', 0, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); INSERT INTO organizations(uuid, "shortName", "longName", type, "createdAt", "updatedAt") VALUES (uuid_generate_v4(), 'EF 1', 'Planning Programming, Budgeting and Execution', 0, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); - INSERT INTO organizations(uuid, "shortName", "longName", type, "parentOrgUuid", "createdAt", "updatedAt") - VALUES (uuid_generate_v4(), 'EF 1.1', '', 0, (SELECT uuid from organizations WHERE "shortName" ='EF 1'), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); - INSERT INTO organizations(uuid, "shortName", "longName", type, "parentOrgUuid", "createdAt", "updatedAt") - VALUES (uuid_generate_v4(), 'EF 1.2', '', 0, (SELECT uuid from organizations WHERE "shortName" ='EF 1'), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); +INSERT INTO organizations(uuid, "shortName", "longName", type, "parentOrgUuid", "createdAt", "updatedAt") + VALUES (uuid_generate_v4(), 'EF 1.1', '', 0, (SELECT uuid from organizations WHERE "shortName" ='EF 1'), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); +INSERT INTO organizations(uuid, "shortName", "longName", type, "parentOrgUuid", "createdAt", "updatedAt") + VALUES (uuid_generate_v4(), 'EF 1.2', '', 0, (SELECT uuid from organizations WHERE "shortName" ='EF 1'), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); INSERT INTO organizations(uuid, "shortName", "longName", type, "createdAt", "updatedAt") VALUES (uuid_generate_v4(), 'EF 2', '',0, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); - INSERT INTO organizations(uuid, "shortName", "longName", type, "parentOrgUuid", "createdAt", "updatedAt") - VALUES (uuid_generate_v4(), 'EF 2.1', '', 0, (SELECT uuid from organizations WHERE "shortName" ='EF 2'), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); - INSERT INTO organizations(uuid, "shortName", "longName", type, "parentOrgUuid", "createdAt", "updatedAt") - VALUES ('ccbee4bb-08b8-42df-8cb5-65e8172f657b', 'EF 2.2', '', 0, (SELECT uuid from organizations WHERE "shortName" ='EF 2'), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); +INSERT INTO organizations(uuid, "shortName", "longName", type, "parentOrgUuid", "createdAt", "updatedAt") + VALUES (uuid_generate_v4(), 'EF 2.1', '', 0, (SELECT uuid from organizations WHERE "shortName" ='EF 2'), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); +INSERT INTO organizations(uuid, "shortName", "longName", type, "parentOrgUuid", "createdAt", "updatedAt") + VALUES ('ccbee4bb-08b8-42df-8cb5-65e8172f657b', 'EF 2.2', '', 0, (SELECT uuid from organizations WHERE "shortName" ='EF 2'), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); INSERT INTO organizations(uuid, "shortName", "longName", type, "createdAt", "updatedAt") VALUES (uuid_generate_v4(), 'EF 3', '', 0, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); INSERT INTO organizations(uuid, "shortName", "longName", type, "createdAt", "updatedAt") - VALUES (uuid_generate_v4(), 'EF 4', '', 0, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); - INSERT INTO organizations(uuid, "shortName", "longName", type, "parentOrgUuid", "createdAt", "updatedAt") - VALUES (uuid_generate_v4(), 'EF 4.1', '', 0 , (SELECT uuid FROM organizations WHERE "shortName" = 'EF 4'), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); - INSERT INTO organizations(uuid, "shortName", "longName", type, "parentOrgUuid", "createdAt", "updatedAt") - VALUES (uuid_generate_v4(), 'EF 4.2', '', 0 , (SELECT uuid FROM organizations WHERE "shortName" = 'EF 4'), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); - INSERT INTO organizations(uuid, "shortName", "longName", type, "parentOrgUuid", "createdAt", "updatedAt") - VALUES (uuid_generate_v4(), 'EF 4.3', '', 0 , (SELECT uuid FROM organizations WHERE "shortName" = 'EF 4'), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); - INSERT INTO organizations(uuid, "shortName", "longName", type, "parentOrgUuid", "createdAt", "updatedAt") - VALUES (uuid_generate_v4(), 'EF 4.4', '', 0 , (SELECT uuid FROM organizations WHERE "shortName" = 'EF 4'), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); + VALUES (uuid_generate_v4(), 'EF 4', '', 0, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); +INSERT INTO organizations(uuid, "shortName", "longName", type, "parentOrgUuid", "createdAt", "updatedAt") + VALUES (uuid_generate_v4(), 'EF 4.1', '', 0 , (SELECT uuid FROM organizations WHERE "shortName" = 'EF 4'), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); +INSERT INTO organizations(uuid, "shortName", "longName", type, "parentOrgUuid", "createdAt", "updatedAt") + VALUES (uuid_generate_v4(), 'EF 4.2', '', 0 , (SELECT uuid FROM organizations WHERE "shortName" = 'EF 4'), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); +INSERT INTO organizations(uuid, "shortName", "longName", type, "parentOrgUuid", "createdAt", "updatedAt") + VALUES (uuid_generate_v4(), 'EF 4.3', '', 0 , (SELECT uuid FROM organizations WHERE "shortName" = 'EF 4'), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); +INSERT INTO organizations(uuid, "shortName", "longName", type, "parentOrgUuid", "createdAt", "updatedAt") + VALUES (uuid_generate_v4(), 'EF 4.4', '', 0 , (SELECT uuid FROM organizations WHERE "shortName" = 'EF 4'), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); INSERT INTO organizations(uuid, "shortName", "longName", type, "createdAt", "updatedAt") VALUES (uuid_generate_v4(), 'EF 5', '', 0, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); - INSERT INTO organizations(uuid, "shortName", "longName", type, "parentOrgUuid", "createdAt", "updatedAt") - VALUES (N'7f939a44-b9e4-48e0-98f5-7d0ea38a6ecf', 'EF 5.1', '', 0 , (SELECT uuid FROM organizations WHERE "shortName" = 'EF 5'), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); - INSERT INTO organizations(uuid, "shortName", "longName", type, "parentOrgUuid", "createdAt", "updatedAt") - VALUES (uuid_generate_v4(), 'EF 5.2', '', 0 , (SELECT uuid FROM organizations WHERE "shortName" = 'EF 5'), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); - INSERT INTO organizations(uuid, "shortName", "longName", type, "parentOrgUuid", "createdAt", "updatedAt") - VALUES (uuid_generate_v4(), 'EF 5.3', '', 0 , (SELECT uuid FROM organizations WHERE "shortName" = 'EF 5'), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); - INSERT INTO organizations(uuid, "shortName", "longName", type, "parentOrgUuid", "createdAt", "updatedAt") - VALUES (uuid_generate_v4(), 'EF 5.4', '', 0 , (SELECT uuid FROM organizations WHERE "shortName" = 'EF 5'), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); +INSERT INTO organizations(uuid, "shortName", "longName", type, "parentOrgUuid", "createdAt", "updatedAt") + VALUES (N'7f939a44-b9e4-48e0-98f5-7d0ea38a6ecf', 'EF 5.1', '', 0 , (SELECT uuid FROM organizations WHERE "shortName" = 'EF 5'), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); +INSERT INTO organizations(uuid, "shortName", "longName", type, "parentOrgUuid", "createdAt", "updatedAt") + VALUES (uuid_generate_v4(), 'EF 5.2', '', 0 , (SELECT uuid FROM organizations WHERE "shortName" = 'EF 5'), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); +INSERT INTO organizations(uuid, "shortName", "longName", type, "parentOrgUuid", "createdAt", "updatedAt") + VALUES (uuid_generate_v4(), 'EF 5.3', '', 0 , (SELECT uuid FROM organizations WHERE "shortName" = 'EF 5'), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); +INSERT INTO organizations(uuid, "shortName", "longName", type, "parentOrgUuid", "createdAt", "updatedAt") + VALUES (uuid_generate_v4(), 'EF 5.4', '', 0 , (SELECT uuid FROM organizations WHERE "shortName" = 'EF 5'), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); INSERT INTO organizations(uuid, "shortName", "longName", type, "createdAt", "updatedAt") - VALUES (uuid_generate_v4(), 'EF 6', '', 0, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); - INSERT INTO organizations(uuid, "shortName", "longName", type, "parentOrgUuid", "createdAt", "updatedAt") - VALUES (uuid_generate_v4(), 'EF 6.1', '', 0 , (SELECT uuid FROM organizations WHERE "shortName" = 'EF 6'), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); - INSERT INTO organizations(uuid, "shortName", "longName", type, "parentOrgUuid", "createdAt", "updatedAt") - VALUES (uuid_generate_v4(), 'EF 6.2', '', 0 , (SELECT uuid FROM organizations WHERE "shortName" = 'EF 6'), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); + VALUES (uuid_generate_v4(), 'EF 6', '', 0, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); +INSERT INTO organizations(uuid, "shortName", "longName", type, "parentOrgUuid", "createdAt", "updatedAt") + VALUES (uuid_generate_v4(), 'EF 6.1', '', 0 , (SELECT uuid FROM organizations WHERE "shortName" = 'EF 6'), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); +INSERT INTO organizations(uuid, "shortName", "longName", type, "parentOrgUuid", "createdAt", "updatedAt") + VALUES (uuid_generate_v4(), 'EF 6.2', '', 0 , (SELECT uuid FROM organizations WHERE "shortName" = 'EF 6'), CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); INSERT INTO organizations(uuid, "shortName", "longName", type, "createdAt", "updatedAt") VALUES (uuid_generate_v4(), 'EF7', '', 0, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP); INSERT INTO organizations(uuid, "shortName", "longName", type, "createdAt", "updatedAt") @@ -372,8 +372,10 @@ UPDATE positions SET "organizationUuid" = (SELECT uuid FROM organizations WHERE -- Assign responsible positions for organizations INSERT INTO "organizationAdministrativePositions" ("organizationUuid", "positionUuid") VALUES + ((SELECT uuid FROM organizations WHERE "shortName" = 'EF 1'), (SELECT uuid FROM positions WHERE name = 'EF 1 Manager')), ((SELECT uuid FROM organizations WHERE "shortName" = 'EF 2.1'), (SELECT uuid FROM positions WHERE name = 'EF 2.1 SuperUser')), - ((SELECT uuid FROM organizations WHERE "shortName" = 'EF 2.2'), (SELECT uuid FROM positions WHERE name = 'EF 2.2 Final Reviewer')); + ((SELECT uuid FROM organizations WHERE "shortName" = 'EF 2.2'), (SELECT uuid FROM positions WHERE name = 'EF 2.2 Super User')), + ((SELECT uuid FROM organizations WHERE "shortName" = 'EF 2.2'), (SELECT uuid FROM positions WHERE name = 'EF 2.2 Final Reviewer')); -- Create the EF 1.1 approval process diff --git a/testDictionaries/no-custom-fields.yml b/testDictionaries/no-custom-fields.yml index d7c6b3a419..9613aeff7e 100644 --- a/testDictionaries/no-custom-fields.yml +++ b/testDictionaries/no-custom-fields.yml @@ -721,7 +721,7 @@ fields: location: filter: [ADVISOR_LOCATION] administratingPositions: - label: Administrating positions + label: Assigned Super Users placeholder: Search for a position... principal: @@ -940,7 +940,7 @@ fields: location: filter: [PRINCIPAL_LOCATION] administratingPositions: - label: Administrating positions + label: Assigned Super Users placeholder: Search for a position... superUser: