-
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.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
8 changed files
with
169 additions
and
5 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
cypress/integrations/admin_activities/wards_activities/add_ward_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,55 @@ | ||
/// <reference types="cypress" /> | ||
|
||
const WARD_START_PATH = "/admin/wards"; | ||
|
||
describe("Wards Activity specs", () => { | ||
it("should render the ui", () => { | ||
cy.authenticate(WARD_START_PATH); | ||
cy.dataCy("activity-title").contains("Wards"); | ||
}); | ||
|
||
it("should show ward creation form", () => { | ||
cy.dataCy("add-new-ward").click(); | ||
cy.dataCy("activity-title").contains("Add Ward"); | ||
}); | ||
|
||
it("should fail to create a new ward", () => { | ||
cy.byId("code").type("FAIL"); | ||
cy.byId("description").type("Children ward"); | ||
cy.byId("email").type("[email protected]"); | ||
cy.byId("telephone").type("698123234"); | ||
cy.get('input[name="opd"]').check(); | ||
cy.get('input[name="pharmacy"]').check(); | ||
cy.get('input[name="pharmacy"]').uncheck(); | ||
cy.dataCy("submit-form").click(); | ||
cy.dataCy("info-box").contains("Fail"); | ||
}); | ||
|
||
it("should successfully create a new ward", () => { | ||
cy.byId("code").clear().type("C"); | ||
cy.dataCy("submit-form").click(); | ||
cy.dataCy("dialog-info").contains("Ward has been created successfully!"); | ||
cy.dataCy("approve-dialog").click(); | ||
}); | ||
|
||
it("should redirect after ward creation", () => { | ||
cy.dataCy("activity-title").contains("Wards"); | ||
}); | ||
|
||
it("should cancel the cancellation of the ward creation", () => { | ||
cy.dataCy("add-new-ward").click(); | ||
cy.dataCy("cancel-form").click(); | ||
cy.dataCy("dialog-info").contains( | ||
"Are you sure to Reset the Form? All the unsaved data will be lost." | ||
); | ||
cy.dataCy("close-dialog").click(); | ||
cy.dataCy("dialog-info").should("not.be.visible"); | ||
}); | ||
|
||
it("should cancel the ward creation", () => { | ||
cy.dataCy("cancel-form").click(); | ||
cy.dataCy("approve-dialog").click(); | ||
cy.dataCy("dialog-info").should("not.exist"); | ||
cy.dataCy("activity-title").contains("Wards"); | ||
}); | ||
}); |
52 changes: 52 additions & 0 deletions
52
cypress/integrations/admin_activities/wards_activities/edit_ward_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 WARD_STARTS_PATH = "/admin/wards"; | ||
|
||
describe("Wards Activity specs", () => { | ||
it("should render the ui", () => { | ||
cy.authenticate(WARD_STARTS_PATH); | ||
cy.dataCy("activity-title").contains("Wards"); | ||
}); | ||
|
||
it("should show ward creation form", () => { | ||
cy.get('button[title="Edit"]').first().click(); | ||
cy.dataCy("activity-title").contains("Edit Ward"); | ||
}); | ||
|
||
it("should fail to edit the ward", () => { | ||
cy.byId("code").should("be.disabled"); | ||
cy.get('input[name="opd"]').uncheck(); | ||
cy.get('input[name="pharmacy"]').check(); | ||
cy.byId("telephone").type("+237698123234"); | ||
cy.dataCy("submit-form").click(); | ||
cy.dataCy("dialog-info").should("not.exist"); | ||
}); | ||
|
||
it("should successfully save ward changes", () => { | ||
cy.byId("telephone").clear().type("623123234"); | ||
cy.dataCy("submit-form").click(); | ||
cy.dataCy("dialog-info").contains("has been updated successfully!"); | ||
cy.dataCy("approve-dialog").click(); | ||
}); | ||
|
||
it("should redirect after ward update", () => { | ||
cy.dataCy("activity-title").contains("Wards"); | ||
}); | ||
|
||
it("should cancel the cancellation of the ward creation", () => { | ||
cy.get('button[title="Edit"]').first().click(); | ||
cy.dataCy("cancel-form").click(); | ||
cy.dataCy("dialog-info").contains( | ||
"Are you sure to Reset the Form? All the unsaved data will be lost." | ||
); | ||
cy.dataCy("close-dialog").click(); | ||
cy.dataCy("dialog-info").should("not.be.visible"); | ||
}); | ||
|
||
it("should cancel the ward update", () => { | ||
cy.dataCy("cancel-form").click(); | ||
cy.dataCy("approve-dialog").click(); | ||
cy.dataCy("dialog-info").should("not.exist"); | ||
cy.dataCy("activity-title").contains("Wards"); | ||
}); | ||
}); |
45 changes: 45 additions & 0 deletions
45
cypress/integrations/admin_activities/wards_activities/manage_wards_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,45 @@ | ||
/// <reference types="cypress" /> | ||
|
||
const WARDS_START_PATH = "/admin/wards"; | ||
|
||
describe("Wards Activity specs", () => { | ||
it("should render the ui", () => { | ||
cy.authenticate(WARDS_START_PATH); | ||
cy.dataCy("activity-title").contains("Wards"); | ||
}); | ||
|
||
it("should present the table with four rows", () => { | ||
cy.dataCy("wards-table") | ||
.find("table") | ||
.then(($table) => { | ||
const rows = $table.find("tbody tr"); | ||
expect(rows.length).equal(8); | ||
}); | ||
}); | ||
|
||
it("should display the deletion dialog", () => { | ||
cy.get('button[title="Delete"]').first().click(); | ||
cy.dataCy("dialog-info").should( | ||
"contain", | ||
"Are you sure to delete item with code" | ||
); | ||
}); | ||
|
||
it("should cancel the ward deletion", () => { | ||
cy.dataCy("close-dialog").click(); | ||
cy.dataCy("dialog-info").should("not.be.visible"); | ||
cy.dataCy("wards-table") | ||
.find("table") | ||
.then(($table) => { | ||
const rows = $table.find("tbody tr"); | ||
expect(rows.length).equal(8); | ||
}); | ||
}); | ||
|
||
it("should delete the ward", () => { | ||
cy.get('button[title="Delete"]').first().click(); | ||
cy.dataCy("approve-dialog").click(); | ||
cy.dataCy("dialog-info").should("not.be.visible"); | ||
cy.dataCy("approve-dialog").last().click(); | ||
}); | ||
}); |
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