-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into update-ci-scripts
- Loading branch information
Showing
9 changed files
with
753 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
/// <reference types="cypress" /> | ||
|
||
describe("Org chart", () => { | ||
const baseUrl = Cypress.env("baseUrl"); | ||
const timeout = Cypress.env("timeoutInMs"); | ||
|
||
const hierarchy = { | ||
10001: { | ||
10001: [10002, 10101], | ||
}, | ||
20004: { | ||
20006: [20002, 20003, { 20004: [20104] }, 20005, 20106], | ||
}, | ||
20104: { | ||
20004: [20104], | ||
}, | ||
}; | ||
|
||
// check whether worker is valid, and optionally check for skills to search transition | ||
const checkValidWorker = (workerId) => { | ||
if (!hierarchy[workerId]) { | ||
cy.contains( | ||
"Sorry, there is no employee or contractor with matching id." | ||
).should("exist"); | ||
} else { | ||
// check for current | ||
cy.get(`#${workerId}`).find(".current").should("exist"); | ||
|
||
const currentHierarchy = hierarchy[workerId]; | ||
const firstLevelId = Object.keys(currentHierarchy)[0]; | ||
const firstLevelDiv = () => cy.get(`#${firstLevelId}`); | ||
firstLevelDiv().should("exist"); | ||
|
||
const secondLevel = currentHierarchy[firstLevelId]; | ||
for (const peer of secondLevel) { | ||
if (typeof peer === "number") { | ||
// no subordinate | ||
firstLevelDiv().next().find(`#${peer}`).should("exist"); | ||
} else { | ||
// have subordinates | ||
const centerId = Object.keys(peer)[0]; | ||
const centerDiv = () => | ||
firstLevelDiv().next().find(`#${centerId}`); | ||
|
||
centerDiv().should("exist"); | ||
|
||
const thirdLevelIds = peer[centerId]; | ||
for (const subordinateId of thirdLevelIds) { | ||
centerDiv() | ||
.next() | ||
.find(`#${subordinateId}`) | ||
.should("exist"); | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
|
||
it("valid worker from url", () => { | ||
// no supervisor | ||
cy.visit(`${baseUrl}/orgchart/10001`); | ||
|
||
cy.get('[data-cy="loading-orgchart"]').should("exist"); | ||
cy.get('[data-cy="loading-orgchart"]', { timeout }).should("not.exist"); | ||
|
||
checkValidWorker(10001); | ||
|
||
// normal worker | ||
cy.visit(`${baseUrl}/orgchart/20004`); | ||
|
||
cy.get('[data-cy="loading-orgchart"]').should("exist"); | ||
cy.get('[data-cy="loading-orgchart"]', { timeout }).should("not.exist"); | ||
|
||
checkValidWorker(20004); | ||
|
||
// no subordinates | ||
cy.visit(`${baseUrl}/orgchart/20104`); | ||
|
||
cy.get('[data-cy="loading-orgchart"]').should("exist"); | ||
cy.get('[data-cy="loading-orgchart"]', { timeout }).should("not.exist"); | ||
|
||
checkValidWorker(20104); | ||
}); | ||
|
||
it("valid worker from other tabs", () => { | ||
// from search results (using COO as the tag) | ||
|
||
cy.visit(baseUrl); | ||
|
||
cy.get('[data-cy="loading-filters"]').should("exist"); | ||
cy.get('[data-cy="loading-filters"]', { timeout }).should("not.exist"); | ||
|
||
cy.get(".MuiChip-deleteIcon", { timeout }).click(); | ||
|
||
cy.get(".filter-form") | ||
.contains("Filter by title") | ||
.get(`[data-cy="expand-title-filters"]`, { timeout }) | ||
.click(); | ||
cy.get(".filter-list-button").contains("President and CEO").click(); | ||
|
||
cy.get('[data-cy="employee-card"]', { timeout }) | ||
.find('[data-cy="orgchart-icon-10001"]') | ||
.click(); | ||
|
||
cy.get('[data-cy="loading-orgchart"]').should("exist"); | ||
cy.get('[data-cy="loading-orgchart"]', { timeout }).should("not.exist"); | ||
|
||
checkValidWorker(10001); | ||
|
||
// from profile | ||
|
||
cy.visit(`${baseUrl}/profile/20104`); | ||
|
||
cy.get('[data-cy="loading-profile"]').should("exist"); | ||
cy.get('[data-cy="loading-profile"]').should("not.exist"); | ||
|
||
cy.contains("Organization Chart").click(); | ||
|
||
cy.get('[data-cy="loading-orgchart"]').should("not.exist"); | ||
|
||
checkValidWorker(20104); | ||
}); | ||
|
||
it("org chart navigation", () => { | ||
cy.visit(`${baseUrl}/orgchart/20004`); | ||
|
||
cy.get('[data-cy="loading-orgchart"]', { timeout }).should("not.exist"); | ||
|
||
cy.get("#20104").click(); | ||
|
||
cy.get('[data-cy="loading-orgchart"]', { timeout }).should("not.exist"); | ||
|
||
checkValidWorker(20104); | ||
}); | ||
|
||
it("invalid worker", () => { | ||
cy.visit(`${baseUrl}/orgchart/100030`); | ||
|
||
cy.get('[data-cy="loading-orgchart"]').should("exist"); | ||
cy.get('[data-cy="loading-orgchart"]', { timeout }).should("not.exist"); | ||
|
||
checkValidWorker(100030); | ||
}); | ||
}); |
Oops, something went wrong.