Skip to content

Commit

Permalink
AB#1163: Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Chessray committed Jul 9, 2024
1 parent 7b9d1a3 commit 853fcdd
Show file tree
Hide file tree
Showing 12 changed files with 96 additions and 0 deletions.
1 change: 1 addition & 0 deletions client/src/pages/locations/Show.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ const LocationShow = ({ pageDispatchers }) => {
<>
{isAdmin && (
<Link
id="mergeWithOther"
to="/admin/merge/locations"
state={{ initialLeftUuid: location.uuid }}
className="btn btn-outline-secondary"
Expand Down
1 change: 1 addition & 0 deletions client/src/pages/organizations/Show.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ const OrganizationShow = ({ pageDispatchers }) => {
<>
{isAdmin && (
<Link
id="mergeWithOther"
to="/admin/merge/organizations"
state={{ initialLeftUuid: organization.uuid }}
className="btn btn-outline-secondary"
Expand Down
1 change: 1 addition & 0 deletions client/src/pages/people/Show.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ const PersonShow = ({ pageDispatchers }) => {
<>
{isAdmin && (
<Link
id="mergeWithOther"
to="/admin/merge/people"
state={{ initialLeftUuid: person.uuid }}
className="btn btn-outline-secondary"
Expand Down
1 change: 1 addition & 0 deletions client/src/pages/positions/Show.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ const PositionShow = ({ pageDispatchers }) => {
<>
{isAdmin && (
<Link
id="mergeWithOther"
to="/admin/merge/positions"
state={{ initialLeftUuid: position.uuid }}
className="btn btn-outline-secondary"
Expand Down
15 changes: 15 additions & 0 deletions client/tests/webdriver/baseSpecs/showLocation.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { expect } from "chai"
import ShowLocation from "../pages/location/showLocation.page"
import MergeLocations from "../pages/mergeLocations.page"

const LOCATION_WITH_ATTACHMENTS_UUID = "e5b3a4b9-acf7-4c79-8224-f248b9a7215d" // Antarctica
const LOCATION_WITH_ORGANIZATIONS_UUID = "9c982685-5946-4dad-a7ee-0f5a12f5e170" // Wishingwells Park
Expand Down Expand Up @@ -56,6 +57,20 @@ describe("Show location page", () => {
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")
})
})
})
15 changes: 15 additions & 0 deletions client/tests/webdriver/baseSpecs/showOrganization.spec.js
Original file line number Diff line number Diff line change
@@ -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"

Expand Down Expand Up @@ -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")
})
})
})
15 changes: 15 additions & 0 deletions client/tests/webdriver/baseSpecs/showPerson.spec.js
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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")
})
})
})
15 changes: 15 additions & 0 deletions client/tests/webdriver/baseSpecs/showPosition.spec.js
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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")
})
})
})
8 changes: 8 additions & 0 deletions client/tests/webdriver/pages/location/showLocation.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"]')
}
Expand Down Expand Up @@ -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()
8 changes: 8 additions & 0 deletions client/tests/webdriver/pages/showOrganization.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"]')
}
Expand Down
8 changes: 8 additions & 0 deletions client/tests/webdriver/pages/showPerson.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down
8 changes: 8 additions & 0 deletions client/tests/webdriver/pages/showPosition.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`)
Expand Down

0 comments on commit 853fcdd

Please sign in to comment.