Skip to content

Commit

Permalink
AB#1085 Extend wdio tests for location merge
Browse files Browse the repository at this point in the history
  • Loading branch information
gjvoosten committed May 29, 2024
1 parent f0c6405 commit e3c9169
Show file tree
Hide file tree
Showing 3 changed files with 173 additions and 22 deletions.
143 changes: 127 additions & 16 deletions client/tests/webdriver/baseSpecs/mergeLocations.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,26 @@ import MergeLocations from "../pages/mergeLocations.page"

const EXAMPLE_LOCATIONS = {
left: {
search: "Cabot",
name: "Cabot Tower",
fullName: "Cabot Tower 47.57001,-52.68177"
search: "Location Winner",
name: "Merge Location Winner",
fullName: "Merge Location Winner 38.58809,-28.71611",
latLon: "38.58809, -28.71611",
parentLocations: "Name Type\nPortugal Country",
planningApprovalSteps:
"Location planning approval for merge winner\nPerson Position\nOF-2 ELIZAWELL, Elizabeth EF 1.1 Advisor A",
approvalSteps:
"Location publication approval for merge winner\nPerson Position\nUnfilled EF 1.1 Advisor B"
},
right: {
search: "Fort",
name: "Fort Amherst",
fullName: "Fort Amherst 47.563763,-52.68059"
search: "Location Loser",
name: "Merge Location Loser",
fullName: "Merge Location Loser -46.4035948,51.69093",
latLon: "-46.4035948, 51.69093",
parentLocations: "Name Type\nFrench Southern Territories Country",
planningApprovalSteps:
"Location planning approval for merge loser\nPerson Position\nCIV REINTON, Reina EF 2.2 Advisor C",
approvalSteps:
"Location publication approval for merge loser\nPerson Position\nCIV ERINSON, Erin EF 2.2 Advisor D"
}
}

Expand All @@ -30,11 +42,12 @@ describe("Merge locations page", () => {
await browser.pause(500) // wait for the rendering of custom fields
await MergeLocations.waitForColumnToChange(
EXAMPLE_LOCATIONS.left.name,
"left"
"left",
"Name"
)

expect(
await (await MergeLocations.getColumnLocationName("left")).getText()
await (await MergeLocations.getColumnContent("left", "Name")).getText()
).to.eq(EXAMPLE_LOCATIONS.left.name)

await (
Expand All @@ -47,11 +60,12 @@ describe("Merge locations page", () => {
await browser.pause(500) // wait for the rendering of custom fields
await MergeLocations.waitForColumnToChange(
EXAMPLE_LOCATIONS.right.name,
"right"
"right",
"Name"
)

expect(
await (await MergeLocations.getColumnLocationName("right")).getText()
await (await MergeLocations.getColumnContent("right", "Name")).getText()
).to.eq(EXAMPLE_LOCATIONS.right.name)
})

Expand All @@ -60,11 +74,12 @@ describe("Merge locations page", () => {
await browser.pause(500) // wait for the rendering of custom fields
await MergeLocations.waitForColumnToChange(
EXAMPLE_LOCATIONS.left.name,
"mid"
"mid",
"Name"
)

expect(
await (await MergeLocations.getColumnLocationName("mid")).getText()
await (await MergeLocations.getColumnContent("mid", "Name")).getText()
).to.eq(EXAMPLE_LOCATIONS.left.name)
})

Expand All @@ -73,24 +88,120 @@ describe("Merge locations page", () => {
await browser.pause(500) // wait for the rendering of custom fields
await MergeLocations.waitForColumnToChange(
EXAMPLE_LOCATIONS.right.name,
"mid"
"mid",
"Name"
)

expect(
await (await MergeLocations.getColumnLocationName("mid")).getText()
await (await MergeLocations.getColumnContent("mid", "Name")).getText()
).to.eq(EXAMPLE_LOCATIONS.right.name)
})

it("Should be able to merge both locations when winner is left location", async() => {
it("Should be able to select from both left and right side.", async() => {
await (await MergeLocations.getSelectButton("left", "Name")).click()
await MergeLocations.waitForColumnToChange(
EXAMPLE_LOCATIONS.left.name,
"mid",
"Name"
)
expect(
await (await MergeLocations.getColumnContent("mid", "Name")).getText()
).to.eq(EXAMPLE_LOCATIONS.left.name)

await (
await MergeLocations.getSelectButton("left", "Latitude, Longitude")
).click()
await MergeLocations.waitForColumnToChange(
EXAMPLE_LOCATIONS.left.latLon,
"mid",
"Latitude, Longitude"
)
expect(
await (
await MergeLocations.getColumnContent("mid", "Latitude, Longitude")
).getText()
).to.equal(EXAMPLE_LOCATIONS.left.latLon)

await (
await MergeLocations.getSelectButton("left", "Parent locations")
).click()
await MergeLocations.waitForColumnToChange(
EXAMPLE_LOCATIONS.left.parentLocations,
"mid",
"Parent locations"
)
expect(
await (
await MergeLocations.getColumnContent("mid", "Parent locations")
).getText()
).to.equal(EXAMPLE_LOCATIONS.left.parentLocations)

await (
await MergeLocations.getSelectButton("right", "Planning Approval Steps")
).click()
await MergeLocations.waitForColumnToChange(
EXAMPLE_LOCATIONS.right.planningApprovalSteps,
"mid",
"Planning Approval Steps"
)
expect(
await (
await MergeLocations.getColumnContent("mid", "Planning Approval Steps")
).getText()
).to.equal(EXAMPLE_LOCATIONS.right.planningApprovalSteps)

await (
await MergeLocations.getSelectButton("left", "Approval Steps")
).click()
await MergeLocations.waitForColumnToChange(
EXAMPLE_LOCATIONS.left.approvalSteps,
"mid",
"Approval Steps"
)
expect(
await (
await MergeLocations.getColumnContent("mid", "Approval Steps")
).getText()
).to.equal(EXAMPLE_LOCATIONS.left.approvalSteps)
})

it("Should be able to merge both locations", async() => {
await (await MergeLocations.getUseAllButton("left")).click()
await browser.pause(500) // wait for the rendering of custom fields
await MergeLocations.waitForColumnToChange(
EXAMPLE_LOCATIONS.left.name,
"mid"
"mid",
"Name"
)

await (
await MergeLocations.getSelectButton("right", "Planning Approval Steps")
).click()
await MergeLocations.waitForColumnToChange(
EXAMPLE_LOCATIONS.right.planningApprovalSteps,
"mid",
"Planning Approval Steps"
)

await (await MergeLocations.getMergeLocationsButton()).click()

await MergeLocations.waitForSuccessAlert()

// Check the results of the merge
expect(await (await MergeLocations.getField("name")).getText()).to.equal(
EXAMPLE_LOCATIONS.left.name
)
expect(
await (await MergeLocations.getField("location")).getText()
).to.equal(EXAMPLE_LOCATIONS.left.latLon)
expect(
await (await MergeLocations.getField("parentLocations")).getText()
).to.equal(EXAMPLE_LOCATIONS.left.parentLocations)
expect(
await (await MergeLocations.getFieldset("planningApprovals")).getText()
).to.equal(`Step 1: ${EXAMPLE_LOCATIONS.right.planningApprovalSteps}`)
expect(
await (await MergeLocations.getFieldset("approvals")).getText()
).to.equal(`Step 1: ${EXAMPLE_LOCATIONS.left.approvalSteps}`)
})
})
26 changes: 21 additions & 5 deletions client/tests/webdriver/pages/mergeLocations.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@ class MergeLocations extends Page {
return browser.$(`#mid-merge-loc-col ${button} > button`)
}

async getColumnLocationName(side) {
return browser.$(
`//div[@id="${side}-merge-loc-col"]//div[text()="Name"]/following-sibling::div`
async getSelectButton(side, text) {
const buttonDiv = await browser.$(
`//div[@id="${side}-merge-loc-col"]//div[text()="${text}"]`
)
const button = await (await buttonDiv.$("..")).$("..")
return button.$("small > button")
}

async waitForAdvancedSelectLoading(compareStr) {
Expand All @@ -65,8 +67,14 @@ class MergeLocations extends Page {
)
}

async waitForColumnToChange(compareStr, side) {
const field = await this.getColumnLocationName(side)
async getColumnContent(side, text) {
return browser.$(
`//div[@id="${side}-merge-loc-col"]//div[text()="${text}"]/following-sibling::div`
)
}

async waitForColumnToChange(compareStr, side, text) {
const field = await this.getColumnContent(side, text)

await browser.waitUntil(
async() => {
Expand All @@ -93,6 +101,14 @@ class MergeLocations extends Page {
}
)
}

async getField(fieldName) {
return browser.$(`div[id="${fieldName}"]`)
}

async getFieldset(fieldName) {
return (await this.getField(fieldName)).$("fieldset")
}
}

export default new MergeLocations()
26 changes: 25 additions & 1 deletion insertBaseData-psql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ INSERT INTO "emailAddresses" (network, address, "relatedObjectType", "relatedObj

-- Create locations
INSERT INTO locations (uuid, type, name, lat, lng, "createdAt", "updatedAt") VALUES
('64795e03-ba83-4bc3-b647-d37fcb1c0694', 'PP', 'Merge Location Winner', 38.58809, -28.71611, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
('4694bb3c-275a-4e74-9197-033e8e9c53ed', 'PP', 'Merge Location Loser', -46.4035948, 51.69093, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
('e5b3a4b9-acf7-4c79-8224-f248b9a7215d', 'PA', 'Antarctica', -90, 0, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
('cc49bb27-4d8f-47a8-a9ee-af2b68b992ac', 'PP', 'St Johns Airport', 47.613442, -52.740936, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
('8c138750-91ce-41bf-9b4c-9f0ddc73608b', 'PP', 'Murray''s Hotel', 47.561517, -52.708760, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
Expand Down Expand Up @@ -187,6 +189,8 @@ INSERT INTO locations (uuid, type, name, "createdAt", "updatedAt") VALUES

-- Set up locationRelationships
INSERT INTO "locationRelationships" ("childLocationUuid", "parentLocationUuid") VALUES
('64795e03-ba83-4bc3-b647-d37fcb1c0694', (SELECT uuid FROM locations WHERE type = 'PAC' AND name = 'Portugal')),
('4694bb3c-275a-4e74-9197-033e8e9c53ed', (SELECT uuid FROM locations WHERE type = 'PAC' AND name = 'French Southern Territories')),
('e5b3a4b9-acf7-4c79-8224-f248b9a7215d', (SELECT uuid FROM locations WHERE type = 'PAC' AND name = 'Antarctica')),
('cc49bb27-4d8f-47a8-a9ee-af2b68b992ac', (SELECT uuid FROM locations WHERE type = 'PAC' AND name = 'Canada')),
('8c138750-91ce-41bf-9b4c-9f0ddc73608b', (SELECT uuid FROM locations WHERE type = 'PAC' AND name = 'Canada')),
Expand Down Expand Up @@ -621,12 +625,32 @@ INSERT INTO approvers ("approvalStepUuid", "positionUuid")
WHERE "approvalSteps".name = 'Task Owner approval'
AND "approvalSteps".type = 1;

-- Create a location approval process for a location
-- Create a location approval process for some locations
INSERT INTO "approvalSteps" (uuid, "relatedObjectUuid", name, type)
SELECT uuid_generate_v4(), (SELECT uuid FROM locations WHERE name = 'Portugal Cove Ferry Terminal'), 'Location approval', 1;
INSERT INTO approvers ("approvalStepUuid", "positionUuid") VALUES
((SELECT uuid from "approvalSteps" where name = 'Location approval'), (SELECT uuid from positions where name = 'ANET Administrator'));

INSERT INTO "approvalSteps" (uuid, "relatedObjectUuid", name, type)
SELECT uuid_generate_v4(), '64795e03-ba83-4bc3-b647-d37fcb1c0694', 'Location planning approval for merge winner', 0;
INSERT INTO approvers ("approvalStepUuid", "positionUuid") VALUES
((SELECT uuid from "approvalSteps" where name = 'Location planning approval for merge winner'), (SELECT uuid from positions where name = 'EF 1.1 Advisor A'));

INSERT INTO "approvalSteps" (uuid, "relatedObjectUuid", name, type)
SELECT uuid_generate_v4(), '64795e03-ba83-4bc3-b647-d37fcb1c0694', 'Location publication approval for merge winner', 1;
INSERT INTO approvers ("approvalStepUuid", "positionUuid") VALUES
((SELECT uuid from "approvalSteps" where name = 'Location publication approval for merge winner'), (SELECT uuid from positions where name = 'EF 1.1 Advisor B'));

INSERT INTO "approvalSteps" (uuid, "relatedObjectUuid", name, type)
SELECT uuid_generate_v4(), '4694bb3c-275a-4e74-9197-033e8e9c53ed', 'Location planning approval for merge loser', 0;
INSERT INTO approvers ("approvalStepUuid", "positionUuid") VALUES
((SELECT uuid from "approvalSteps" where name = 'Location planning approval for merge loser'), (SELECT uuid from positions where name = 'EF 2.2 Advisor C'));

INSERT INTO "approvalSteps" (uuid, "relatedObjectUuid", name, type)
SELECT uuid_generate_v4(), '4694bb3c-275a-4e74-9197-033e8e9c53ed', 'Location publication approval for merge loser', 1;
INSERT INTO approvers ("approvalStepUuid", "positionUuid") VALUES
((SELECT uuid from "approvalSteps" where name = 'Location publication approval for merge loser'), (SELECT uuid from positions where name = 'EF 2.2 Advisor D'));

-- Top-level organizations
INSERT INTO organizations (uuid, "shortName", "longName", "identificationCode", "locationUuid", app6context, "app6standardIdentity", "app6symbolSet", "createdAt", "updatedAt") VALUES
(uuid_generate_v4(), 'MoD', 'Ministry of Defense', 'Z12345', (SELECT uuid FROM locations WHERE type = 'PAC' AND name = 'Afghanistan'), '0', '4', '11', CURRENT_TIMESTAMP, CURRENT_TIMESTAMP),
Expand Down

0 comments on commit e3c9169

Please sign in to comment.