From 853fcdda9779db006cb77e5e6150f3c44b59cdf6 Mon Sep 17 00:00:00 2001
From: Raimund Klein <770876+Chessray@users.noreply.github.com>
Date: Mon, 8 Jul 2024 07:52:40 -0400
Subject: [PATCH] AB#1163: Add tests
---
client/src/pages/locations/Show.js | 1 +
client/src/pages/organizations/Show.js | 1 +
client/src/pages/people/Show.js | 1 +
client/src/pages/positions/Show.js | 1 +
.../webdriver/baseSpecs/showLocation.spec.js | 15 +++++++++++++++
.../webdriver/baseSpecs/showOrganization.spec.js | 15 +++++++++++++++
.../tests/webdriver/baseSpecs/showPerson.spec.js | 15 +++++++++++++++
.../webdriver/baseSpecs/showPosition.spec.js | 15 +++++++++++++++
.../webdriver/pages/location/showLocation.page.js | 8 ++++++++
.../webdriver/pages/showOrganization.page.js | 8 ++++++++
client/tests/webdriver/pages/showPerson.page.js | 8 ++++++++
client/tests/webdriver/pages/showPosition.page.js | 8 ++++++++
12 files changed, 96 insertions(+)
diff --git a/client/src/pages/locations/Show.js b/client/src/pages/locations/Show.js
index 03d304ec36..885d836ff0 100644
--- a/client/src/pages/locations/Show.js
+++ b/client/src/pages/locations/Show.js
@@ -98,6 +98,7 @@ const LocationShow = ({ pageDispatchers }) => {
<>
{isAdmin && (
{
<>
{isAdmin && (
{
<>
{isAdmin && (
{
<>
{isAdmin && (
{
await (await ShowLocation.getReportCollection()).waitForExist()
await (await ShowLocation.getReportCollection()).waitForDisplayed()
expect(await ShowLocation.getReportSummaries()).to.have.lengthOf.above(0)
+
+ await ShowLocation.logout()
+ })
+ })
+
+ describe("When on the show page of a location as admin", () => {
+ it("We can select to merge it with another location", async() => {
+ await ShowLocation.openAsAdminUser(LOCATION_WITH_ATTACHMENTS_UUID)
+ await (await ShowLocation.getMergeButton()).click()
+ // eslint-disable-next-line no-unused-expressions
+ expect(await MergeLocations.getTitle()).to.exist
+ expect(
+ await (await MergeLocations.getLeftLocationField()).getValue()
+ ).to.contain("Antarctica")
})
})
})
diff --git a/client/tests/webdriver/baseSpecs/showOrganization.spec.js b/client/tests/webdriver/baseSpecs/showOrganization.spec.js
index 4e5ddaf243..1ca83d4650 100644
--- a/client/tests/webdriver/baseSpecs/showOrganization.spec.js
+++ b/client/tests/webdriver/baseSpecs/showOrganization.spec.js
@@ -1,5 +1,6 @@
import { expect } from "chai"
import Home from "../pages/home.page"
+import MergeOrganizations from "../pages/mergeOrganizations.page"
import Search from "../pages/search.page"
import ShowOrganization from "../pages/showOrganization.page"
@@ -140,6 +141,20 @@ describe("Show organization page", () => {
await expect(await browser.getUrl()).to.include(
"/attachments/9ac41246-25ac-457c-b7d6-946c5f625f1f"
)
+
+ await ShowOrganization.logout()
+ })
+ })
+
+ describe("When on the show page of an organization as admin", () => {
+ it("We can select to merge it with another organization", async() => {
+ await ShowOrganization.openAsAdminUser(ORGANIZATION_UUID)
+ await (await ShowOrganization.getMergeButton()).click()
+ // eslint-disable-next-line no-unused-expressions
+ expect(await MergeOrganizations.getTitle()).to.exist
+ expect(
+ await (await MergeOrganizations.getLeftOrganizationField()).getValue()
+ ).to.contain("EF 2.2")
})
})
})
diff --git a/client/tests/webdriver/baseSpecs/showPerson.spec.js b/client/tests/webdriver/baseSpecs/showPerson.spec.js
index f4a18b6000..8c8fb8f8ea 100644
--- a/client/tests/webdriver/baseSpecs/showPerson.spec.js
+++ b/client/tests/webdriver/baseSpecs/showPerson.spec.js
@@ -1,4 +1,5 @@
import { expect } from "chai"
+import MergePeople from "../pages/mergePeople.page"
import ShowPerson from "../pages/showPerson.page"
const PERSON_UUID = "df9c7381-56ac-4bc5-8e24-ec524bccd7e9"
@@ -38,6 +39,20 @@ describe("Show person page", () => {
await expect(await browser.getUrl()).to.include(
"/attachments/13318e42-a0a3-438f-8ed5-dc16b1ef17bc"
)
+
+ await ShowPerson.logout()
+ })
+ })
+
+ describe("When on the show page of a person as admin", () => {
+ it("We can select to merge them with another person", async() => {
+ await ShowPerson.openAsAdminUser(PERSON_WITH_AG_UUID)
+ await (await ShowPerson.getMergeButton()).click()
+ // eslint-disable-next-line no-unused-expressions
+ expect(await MergePeople.getTitle()).to.exist
+ expect(
+ await (await MergePeople.getLeftPersonField()).getValue()
+ ).to.contain("BRATTON, Creed")
})
})
})
diff --git a/client/tests/webdriver/baseSpecs/showPosition.spec.js b/client/tests/webdriver/baseSpecs/showPosition.spec.js
index b6b6022aa0..6134f38475 100644
--- a/client/tests/webdriver/baseSpecs/showPosition.spec.js
+++ b/client/tests/webdriver/baseSpecs/showPosition.spec.js
@@ -1,4 +1,5 @@
import { expect } from "chai"
+import MergePositions from "../pages/mergePositions.page"
import ShowPosition from "../pages/showPosition.page"
const POSITION_WITH_AG_UUID = "05c42ce0-34a0-4391-8b2f-c4cd85ee6b47" // EF 5.1 Advisor Quality Assurance
@@ -20,6 +21,20 @@ describe("Show position page", () => {
await expect(await browser.getUrl()).to.include(
"/authorizationGroups/ab1a7d99-4529-44b1-a118-bdee3ca8296b"
)
+
+ await ShowPosition.logout()
+ })
+ })
+
+ describe("When on the show page of a position as admin", () => {
+ it("We can select to merge it with another position", async() => {
+ await ShowPosition.openAsAdminUser(POSITION_WITH_AG_UUID)
+ await (await ShowPosition.getMergeButton()).click()
+ // eslint-disable-next-line no-unused-expressions
+ expect(await MergePositions.getTitle()).to.exist
+ expect(
+ await (await MergePositions.getLeftPositionField()).getValue()
+ ).to.contain("EF 5.1 Advisor Quality Assurance")
})
})
})
diff --git a/client/tests/webdriver/pages/location/showLocation.page.js b/client/tests/webdriver/pages/location/showLocation.page.js
index ca3650c6de..4ec64ba97e 100644
--- a/client/tests/webdriver/pages/location/showLocation.page.js
+++ b/client/tests/webdriver/pages/location/showLocation.page.js
@@ -7,6 +7,10 @@ class ShowLocation extends Page {
await super.open(PAGE_URL.replace(":uuid", uuid))
}
+ async openAsAdminUser(uuid) {
+ await super.openAsAdminUser(PAGE_URL.replace(":uuid", uuid))
+ }
+
async getEditButton() {
return browser.$('//a[text()="Edit"]')
}
@@ -38,5 +42,9 @@ class ShowLocation extends Page {
async getReportSummaries() {
return (await this.getReportCollection()).$$("div.report-summary")
}
+
+ async getMergeButton() {
+ return browser.$('a[id="mergeWithOther"]')
+ }
}
export default new ShowLocation()
diff --git a/client/tests/webdriver/pages/showOrganization.page.js b/client/tests/webdriver/pages/showOrganization.page.js
index b2a871fe65..bde41b2875 100644
--- a/client/tests/webdriver/pages/showOrganization.page.js
+++ b/client/tests/webdriver/pages/showOrganization.page.js
@@ -7,6 +7,14 @@ class ShowOrganization extends Page {
await super.open(PAGE_URL.replace(":uuid", uuid))
}
+ async openAsAdminUser(uuid) {
+ await super.openAsAdminUser(PAGE_URL.replace(":uuid", uuid))
+ }
+
+ async getMergeButton() {
+ return browser.$('a[id="mergeWithOther"]')
+ }
+
async getCreateSubOrganizationButton() {
return browser.$('//a[text()="Create sub-organization"]')
}
diff --git a/client/tests/webdriver/pages/showPerson.page.js b/client/tests/webdriver/pages/showPerson.page.js
index 86010c9187..dbad90261e 100644
--- a/client/tests/webdriver/pages/showPerson.page.js
+++ b/client/tests/webdriver/pages/showPerson.page.js
@@ -7,6 +7,14 @@ class ShowPerson extends Page {
await super.open(PAGE_URL.replace(":uuid", uuid))
}
+ async openAsAdminUser(uuid) {
+ await super.openAsAdminUser(PAGE_URL.replace(":uuid", uuid))
+ }
+
+ async getMergeButton() {
+ return browser.$('a[id="mergeWithOther"]')
+ }
+
async getEditButton() {
return browser.$("div a.edit-person")
}
diff --git a/client/tests/webdriver/pages/showPosition.page.js b/client/tests/webdriver/pages/showPosition.page.js
index f51e71d6ad..6dacef64d3 100644
--- a/client/tests/webdriver/pages/showPosition.page.js
+++ b/client/tests/webdriver/pages/showPosition.page.js
@@ -7,10 +7,18 @@ class ShowPosition extends Page {
await super.open(PAGE_URL.replace(":uuid", uuid))
}
+ async openAsAdminUser(uuid) {
+ await super.openAsAdminUser(PAGE_URL.replace(":uuid", uuid))
+ }
+
async getAuthorizationGroupsTable() {
return browser.$("#authorizationGroups table")
}
+ async getMergeButton() {
+ return browser.$('a[id="mergeWithOther"]')
+ }
+
async getAuthorizationGroup(i) {
const agTable = await this.getAuthorizationGroupsTable()
return agTable.$(`tbody tr:nth-child(${i}) td:first-child a`)