-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make add patient e2e test rerunnable
- Loading branch information
Showing
10 changed files
with
286 additions
and
24 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
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
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
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
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
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
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export const graphqlURL = `${ | ||
Cypress.env("BACKEND_URL") || "http://localhost:8080" | ||
}/graphql`; | ||
const backendURL = Cypress.env("BACKEND_URL") || "http://localhost:8080"; | ||
export const graphqlURL = `${backendURL}/graphql`; | ||
export const addOrgToQueueURL = `${backendURL}/account-request/organization-add-to-queue`; |
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,58 @@ | ||
import { | ||
accessOrganization, | ||
addMockFacility, | ||
createOrganization, | ||
getOrganizationsByName, getPatientsByFacilityId, | ||
markOrganizationAsDeleted, markPatientAsDeleted, | ||
verifyPendingOrganization | ||
} from "./testing-data-utils"; | ||
import { generateUser } from "../support/e2e"; | ||
|
||
const createOrgName = (specName) => { | ||
return `${specName}-org`; | ||
} | ||
|
||
const createFacilityName = (specName) => { | ||
return `${specName}-facility`; | ||
} | ||
|
||
const createAndVerifyOrganization = (orgName) => { | ||
const adminUser = generateUser(); | ||
return createOrganization(orgName, adminUser.email) | ||
.then((res) => verifyPendingOrganization(res.body.orgExternalId)) | ||
} | ||
const archivePatientsForFacility = (facilityId) => { | ||
return getPatientsByFacilityId(facilityId) | ||
.then((res) => { | ||
let patients = res.body.data.patients; | ||
if (patients.length > 0) { | ||
patients.map( | ||
(patient) => markPatientAsDeleted(patient.internalId, true)) | ||
} | ||
}) | ||
} | ||
|
||
export const cleanUpPreviousOrg = (specName) => { | ||
let orgName = createOrgName(specName); | ||
getOrganizationsByName(orgName) | ||
.then((res) => { | ||
let orgs = res.body.data.organizationsByName; | ||
let org = orgs.length > 0 ? orgs[0] : null; | ||
if (org) { | ||
let facilities = org.facilities | ||
if (facilities.length > 0) { | ||
facilities.map((facility) => archivePatientsForFacility(facility.id)) | ||
} | ||
markOrganizationAsDeleted(org.id, true); | ||
} | ||
}) | ||
} | ||
|
||
export const setupOrgAndFacility = (specName) => { | ||
let orgName = createOrgName(specName); | ||
let facilityName = createFacilityName(specName); | ||
createAndVerifyOrganization(orgName) | ||
.then(() => getOrganizationsByName(orgName)) | ||
.then((res) => accessOrganization(res.body.data.organizationsByName[0].externalId)) | ||
.then(() => addMockFacility(facilityName)) | ||
}; |
Oops, something went wrong.