Skip to content

Commit

Permalink
Fix client-side e2s tests, checking super-user permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
midmarch committed Mar 15, 2023
1 parent 22427e8 commit 51d8cd7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
2 changes: 1 addition & 1 deletion client/src/pages/organizations/Laydown.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ const OrganizationLaydown = ({ organization, refetch }) => {
)
}
>
<PositionTable positions={organization.administratingPositions} />
<PositionTable positions={organization.administratingPositions} id="superUserTable"/>
<EditAdministratingPositionsModal
organization={organization}
showModal={showAdministratingPositionsModal}
Expand Down
31 changes: 14 additions & 17 deletions client/tests/e2e/permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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",
Expand Down Expand Up @@ -123,12 +123,9 @@ 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(
Expand All @@ -143,8 +140,8 @@ validateUserCannotEditOtherUser(
"super user cannot edit people from the organizations their position is not administrating",
"jacob",
"rebecca",
"CTR BECCABON, Rebecca",
"EF 2.2 Final Reviewer"
"CIV ANDERSON, Andrew",
"EF 1 Manager"
)

test.serial("checking regular user permissions", async t => {
Expand Down Expand Up @@ -234,12 +231,12 @@ 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(
Expand Down Expand Up @@ -332,7 +329,7 @@ function validateUserCannotEditOtherUser(
}

async function findSuperUserLink(t, desiredSuperUserName) {
const $superUserLinks = await t.context.$$("[name=superUsers] p a")
const $superUserLinks = await t.context.$$("[id=superUserTable] tbody tr td:nth-child(4) span a")
let $foundLink
for (const $superUserLink of $superUserLinks) {
const superUserName = await $superUserLink.getText()
Expand Down
3 changes: 2 additions & 1 deletion insertBaseData-psql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,8 @@ INSERT INTO "organizationAdministrativePositions" ("organizationUuid", "position
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
Expand Down

0 comments on commit 51d8cd7

Please sign in to comment.