-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OH2-355 | Tests / Add cypress e2e tests to cover diseases types (admi…
…n/types/diseases) (#628) * tests:OH2-355 | Tests / Add cypress e2e tests to cover diseases types (admin/types/diseases) * chore: code quality improvement
- Loading branch information
Showing
7 changed files
with
164 additions
and
8 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
...grations/admin_activities/types_activities/diseases_activities/add_disease_activity.cy.ts
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,52 @@ | ||
/// <reference types="cypress" /> | ||
|
||
const DISEASE_TYPE_STARTS_PATH = "/admin/types/diseases"; | ||
|
||
describe("Add disease type Activity specs", () => { | ||
it("should render the ui", () => { | ||
cy.authenticate(DISEASE_TYPE_STARTS_PATH); | ||
cy.dataCy("sub-activity-title").contains("Manage disease types"); | ||
}); | ||
|
||
it("should show disease type creation form", () => { | ||
cy.dataCy("add-disease-type").click(); | ||
cy.dataCy("sub-activity-title").contains("New disease type"); | ||
}); | ||
|
||
it("should fail to create a new disease type", () => { | ||
cy.byId("code").type("FAIL"); | ||
cy.byId("description").type("Disease type"); | ||
cy.dataCy("submit-form").click(); | ||
cy.dataCy("info-box").contains("Fail"); | ||
}); | ||
|
||
it("should successfully create a new disease type", () => { | ||
cy.byId("code").clear().type("22"); | ||
cy.dataCy("submit-form").click(); | ||
cy.dataCy("dialog-info").contains( | ||
"The disease type has been created successfully!" | ||
); | ||
cy.dataCy("approve-dialog").click(); | ||
}); | ||
|
||
it("should redirect after disease type creation", () => { | ||
cy.dataCy("sub-activity-title").contains("Manage disease types"); | ||
}); | ||
|
||
it("should cancel the cancellation of the disease type creation", () => { | ||
cy.dataCy("add-disease-type").click(); | ||
cy.dataCy("cancel-form").click(); | ||
cy.dataCy("dialog-info").contains( | ||
"Are you sure to cancel the disease type creation?" | ||
); | ||
cy.dataCy("close-dialog").click(); | ||
cy.dataCy("dialog-info").should("not.exist"); | ||
}); | ||
|
||
it("should cancel the disease type creation", () => { | ||
cy.dataCy("cancel-form").click(); | ||
cy.dataCy("approve-dialog").click(); | ||
cy.dataCy("dialog-info").should("not.exist"); | ||
cy.dataCy("sub-activity-title").contains("Manage disease types"); | ||
}); | ||
}); |
50 changes: 50 additions & 0 deletions
50
...rations/admin_activities/types_activities/diseases_activities/edit_disease_activity.cy.ts
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,50 @@ | ||
/// <reference types="cypress" /> | ||
|
||
const DISEASE_TYPE_START_PATH = "/admin/types/diseases"; | ||
|
||
describe("Disease types Edit Activity specs", () => { | ||
it("should render the ui", () => { | ||
cy.authenticate(DISEASE_TYPE_START_PATH); | ||
cy.dataCy("sub-activity-title").contains("Manage disease types"); | ||
}); | ||
|
||
it("should show disease type edit form", () => { | ||
cy.dataCy("table-edit-action").first().click(); | ||
cy.dataCy("sub-activity-title").contains("Edit disease type"); | ||
}); | ||
|
||
it("should fail to edit the disease type", () => { | ||
cy.byId("code").should("be.disabled"); | ||
cy.byId("description").clear(); | ||
cy.dataCy("submit-form").click(); | ||
cy.dataCy("dialog-info").should("not.exist"); | ||
}); | ||
|
||
it("should successfully save disease type changes", () => { | ||
cy.byId("description").clear().type("Disease type"); | ||
cy.dataCy("submit-form").click(); | ||
cy.dataCy("dialog-info").contains("has been updated successfully!"); | ||
cy.dataCy("approve-dialog").click(); | ||
}); | ||
|
||
it("should redirect after disease type update", () => { | ||
cy.dataCy("sub-activity-title").contains("Manage disease types"); | ||
}); | ||
|
||
it("should cancel the cancellation of the disease type update", () => { | ||
cy.dataCy("table-edit-action").first().click(); | ||
cy.dataCy("cancel-form").click(); | ||
cy.dataCy("dialog-info").contains( | ||
"Are you sure to cancel the disease type update?" | ||
); | ||
cy.dataCy("close-dialog").click(); | ||
cy.dataCy("dialog-info").should("not.exist"); | ||
}); | ||
|
||
it("should cancel the disease type update", () => { | ||
cy.dataCy("cancel-form").click(); | ||
cy.dataCy("approve-dialog").click(); | ||
cy.dataCy("dialog-info").should("not.exist"); | ||
cy.dataCy("sub-activity-title").contains("Manage disease types"); | ||
}); | ||
}); |
38 changes: 38 additions & 0 deletions
38
...ions/admin_activities/types_activities/diseases_activities/manage_diseases_activity.cy.ts
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,38 @@ | ||
/// <reference types="cypress" /> | ||
|
||
const DISEASE_TYPES_START_PATH = "/admin/types/diseases"; | ||
|
||
describe("Disease types Activity specs", () => { | ||
it("should render the ui", () => { | ||
cy.authenticate(DISEASE_TYPES_START_PATH); | ||
cy.dataCy("sub-activity-title").contains("Manage disease types"); | ||
}); | ||
|
||
it("should present the table with two rows", () => { | ||
cy.dataCy("disease-types-table") | ||
.find("table") | ||
.then((table) => { | ||
expect(table.find("tbody tr").length).equal(2); | ||
}); | ||
}); | ||
|
||
it("should cancel the deletion of the disease type", () => { | ||
cy.dataCy("table-delete-action").first().click(); | ||
cy.dataCy("dialog-info").contains("Are you sure to delete item with code"); | ||
cy.dataCy("close-dialog").click(); | ||
cy.dataCy("dialog-info").should("not.exist"); | ||
}); | ||
|
||
it("should delete the first disease type", () => { | ||
cy.dataCy("table-delete-action").first().click(); | ||
cy.dataCy("approve-dialog").click(); | ||
cy.dataCy("dialog-info").contains("has been deleted successfully!"); | ||
cy.dataCy("approve-dialog").last().click(); | ||
cy.dataCy("dialog-info").should("not.exist"); | ||
cy.dataCy("disease-types-table") | ||
.find("table") | ||
.then((table) => { | ||
expect(table.find("tbody tr").length).equal(1); | ||
}); | ||
}); | ||
}); |
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