forked from ministryofjustice/bichard7-next-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DRY out insert court cases helper functions (ministryofjustice#157)
* Add generic insertCourtCasesWithFields method to setup test data * Remove redundant insertDummyCourtCaseWithLock function * Remove redundant insertMultipleDummyCourtCasesWithLock function * Fix failing lock test We need to seed error count and trigger count when testing locks, if case don't have error/trigger locking will fail * Rename visibleForces in resolve trigger test * Remove redundant insertCourtCasesWithCourtDates * Remove redundant insertCourtCasesWithOrgCodes * Remove redundant insertCourtCasesWithCourtNames * Fix insertCourtCasesWithFields seeds court dates * Remove redundant insertMultipleDummyCourtCasesWithResolutionTimestamp * Remove redundant insertCourtCasesWithUrgencies function * Simplify list court cases test setup * Simplify add notes integration test * Delete unused task from cypress config * Dry out insertMultipleDummyCourtCases function * DRY out the remaining insert court cases helper functions * Seed multiple cases with uniq defendant name
- Loading branch information
Showing
10 changed files
with
384 additions
and
491 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,7 +34,7 @@ describe("Case details", () => { | |
}) | ||
|
||
it("should be accessible", () => { | ||
cy.task("insertCourtCasesWithOrgCodes", ["01"]) | ||
cy.task("insertCourtCasesWithFields", [{ orgForPoliceFilter: "01" }]) | ||
const triggers: TestTrigger[] = [ | ||
{ | ||
triggerId: 0, | ||
|
@@ -54,7 +54,7 @@ describe("Case details", () => { | |
}) | ||
|
||
it("should load case details for the case that this user can see", () => { | ||
cy.task("insertCourtCasesWithOrgCodes", ["01"]) | ||
cy.task("insertCourtCasesWithFields", [{ orgForPoliceFilter: "01" }]) | ||
const triggers: TestTrigger[] = [ | ||
{ | ||
triggerId: 0, | ||
|
@@ -124,7 +124,7 @@ describe("Case details", () => { | |
}) | ||
|
||
it("should return 404 for a case that this user can not see", () => { | ||
cy.task("insertCourtCasesWithOrgCodes", ["02"]) | ||
cy.task("insertCourtCasesWithFields", [{ orgForPoliceFilter: "02" }]) | ||
cy.login("[email protected]", "password") | ||
|
||
cy.request({ | ||
|
@@ -155,13 +155,15 @@ describe("Case details", () => { | |
}) | ||
|
||
it("should lock a case when a user views a case details page", () => { | ||
cy.task("insertDummyCourtCaseWithLock", { | ||
errorLockedByUsername: null, | ||
triggerLockedByUsername: null, | ||
orgCodes: ["02"], | ||
errorCount: 1, | ||
triggerCount: 1 | ||
}) | ||
cy.task("insertCourtCasesWithFields", [ | ||
{ | ||
errorLockedByUsername: null, | ||
triggerLockedByUsername: null, | ||
orgForPoliceFilter: "02", | ||
errorCount: 1, | ||
triggerCount: 1 | ||
} | ||
]) | ||
|
||
cy.login("[email protected]", "password") | ||
cy.visit("/bichard/court-cases/0") | ||
|
@@ -174,13 +176,15 @@ describe("Case details", () => { | |
|
||
it("should not lock a court case when its already locked", () => { | ||
const existingUserLock = "Another name" | ||
cy.task("insertDummyCourtCaseWithLock", { | ||
errorLockedByUsername: existingUserLock, | ||
triggerLockedByUsername: existingUserLock, | ||
orgCodes: ["01"], | ||
errorCount: 1, | ||
triggerCount: 1 | ||
}) | ||
cy.task("insertCourtCasesWithFields", [ | ||
{ | ||
errorLockedByUsername: existingUserLock, | ||
triggerLockedByUsername: existingUserLock, | ||
orgForPoliceFilter: "01", | ||
errorCount: 1, | ||
triggerCount: 1 | ||
} | ||
]) | ||
|
||
cy.login("[email protected]", "password") | ||
cy.visit("/bichard/court-cases/0") | ||
|
@@ -191,11 +195,15 @@ describe("Case details", () => { | |
|
||
it("should unlock and lock a court case when its already locked", () => { | ||
const existingUserLock = "Another name" | ||
cy.task("insertDummyCourtCaseWithLock", { | ||
errorLockedByUsername: existingUserLock, | ||
triggerLockedByUsername: existingUserLock, | ||
orgCodes: ["02"] | ||
}) | ||
cy.task("insertCourtCasesWithFields", [ | ||
{ | ||
errorLockedByUsername: existingUserLock, | ||
triggerLockedByUsername: existingUserLock, | ||
orgForPoliceFilter: "02", | ||
errorCount: 1, | ||
triggerCount: 1 | ||
} | ||
]) | ||
|
||
cy.login("[email protected]", "password") | ||
cy.visit("/bichard/court-cases/0") | ||
|
@@ -216,11 +224,14 @@ describe("Case details", () => { | |
|
||
it("should resolve a trigger after clicking the button", () => { | ||
const userWithGeneralHandlerPermission = "Bichard02" | ||
cy.task("insertDummyCourtCaseWithLock", { | ||
errorLockedByUsername: userWithGeneralHandlerPermission, | ||
triggerLockedByUsername: userWithGeneralHandlerPermission, | ||
orgCodes: ["02"] | ||
}) | ||
cy.task("insertCourtCasesWithFields", [ | ||
{ | ||
errorLockedByUsername: userWithGeneralHandlerPermission, | ||
triggerLockedByUsername: userWithGeneralHandlerPermission, | ||
orgForPoliceFilter: "02" | ||
} | ||
]) | ||
|
||
const triggers: TestTrigger[] = [ | ||
{ | ||
triggerId: 0, | ||
|
@@ -249,11 +260,13 @@ describe("Case details", () => { | |
}) | ||
|
||
it("should resubmit a case when the resubmit button is clicked", () => { | ||
cy.task("insertDummyCourtCaseWithLock", { | ||
errorLockedByUsername: null, | ||
triggerLockedByUsername: null, | ||
orgCodes: ["02"] | ||
}) | ||
cy.task("insertCourtCasesWithFields", [ | ||
{ | ||
errorLockedByUsername: null, | ||
triggerLockedByUsername: null, | ||
orgForPoliceFilter: "02" | ||
} | ||
]) | ||
|
||
cy.login("[email protected]", "password") | ||
|
||
|
@@ -277,8 +290,7 @@ describe("Case details", () => { | |
}) | ||
|
||
it("should resubmit a case when updates are made and the resubmit button is clicked", () => { | ||
cy.task("insertCourtCasesWithOrgCodes", ["02"]) | ||
|
||
cy.task("insertCourtCasesWithFields", [{ orgForPoliceFilter: "02" }]) | ||
cy.login("[email protected]", "password") | ||
|
||
cy.visit("/bichard/court-cases/0") | ||
|
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 |
---|---|---|
|
@@ -29,7 +29,7 @@ describe("Case details", () => { | |
}) | ||
|
||
it("should be accessible", () => { | ||
cy.task("insertCourtCasesWithOrgCodes", ["01"]) | ||
cy.task("insertCourtCasesWithFields", [{ orgForPoliceFilter: "01" }]) | ||
const triggers: TestTrigger[] = [ | ||
{ | ||
triggerId: 0, | ||
|
@@ -50,7 +50,7 @@ describe("Case details", () => { | |
}) | ||
|
||
it("should be able to add a note when case is visible to the user and not locked by another user", () => { | ||
cy.task("insertCourtCasesWithOrgCodes", ["01"]) | ||
cy.task("insertCourtCasesWithFields", [{ orgForPoliceFilter: "01" }]) | ||
const triggers: TestTrigger[] = [ | ||
{ | ||
triggerId: 0, | ||
|
@@ -78,7 +78,7 @@ describe("Case details", () => { | |
}) | ||
|
||
it("should be able to add a long note", () => { | ||
cy.task("insertCourtCasesWithOrgCodes", ["01"]) | ||
cy.task("insertCourtCasesWithFields", [{ orgForPoliceFilter: "01" }]) | ||
const triggers: TestTrigger[] = [ | ||
{ | ||
triggerId: 0, | ||
|
@@ -109,7 +109,7 @@ describe("Case details", () => { | |
}) | ||
|
||
it("should show error message when note text is empty", () => { | ||
cy.task("insertCourtCasesWithOrgCodes", ["01"]) | ||
cy.task("insertCourtCasesWithFields", [{ orgForPoliceFilter: "01" }]) | ||
const triggers: TestTrigger[] = [ | ||
{ | ||
triggerId: 0, | ||
|
@@ -134,7 +134,7 @@ describe("Case details", () => { | |
}) | ||
|
||
it("Adding an empty note doesn't add a note, when the case is visible to the user and not locked by another user", () => { | ||
cy.task("insertCourtCasesWithOrgCodes", ["01"]) | ||
cy.task("insertCourtCasesWithFields", [{ orgForPoliceFilter: "01" }]) | ||
const triggers: TestTrigger[] = [ | ||
{ | ||
triggerId: 0, | ||
|
@@ -158,7 +158,7 @@ describe("Case details", () => { | |
}) | ||
|
||
it("should return 404 for a case that this user can not see", () => { | ||
cy.task("insertCourtCasesWithOrgCodes", ["02"]) | ||
cy.task("insertCourtCasesWithFields", [{ orgForPoliceFilter: "02" }]) | ||
cy.login("[email protected]", "password") | ||
|
||
cy.request({ | ||
|
Oops, something went wrong.