-
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
* tests:OH2-326 | Tests | Add cypress e2e tests to cover admin/diseases * tests:OH2-328 | Tests | Add cypress e2e tests to cover admin/operations * chore:improve cypress indexing
- Loading branch information
Showing
5 changed files
with
136 additions
and
2 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
cypress/integrations/admin_activities/operations_activities/add_operation_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 OPERATION_STARTS_PATH = "/admin/operations"; | ||
|
||
describe("Add Operation Activity specs", () => { | ||
it("should render the ui", () => { | ||
cy.authenticate(OPERATION_STARTS_PATH); | ||
cy.dataCy("activity-title").contains("Operations"); | ||
}); | ||
|
||
it("should show operation creation form", () => { | ||
cy.dataCy("add-new-operation").click(); | ||
cy.dataCy("activity-title").contains("Add Operation"); | ||
}); | ||
|
||
it("should fail to create a new operation", () => { | ||
cy.byId("code").type("FAIL"); | ||
cy.byId("type").click(); | ||
cy.get('.MuiAutocomplete-popper li[data-option-index="0"]').click(); | ||
cy.byId("description").type("Laparotomy"); | ||
cy.get('input[name="major"]').check(); | ||
cy.dataCy("submit-form").click(); | ||
cy.dataCy("info-box").contains("Fail"); | ||
}); | ||
|
||
it("should successfully create a new operation", () => { | ||
cy.byId("code").clear().type("202"); | ||
cy.dataCy("submit-form").click(); | ||
cy.dataCy("dialog-info").contains( | ||
"Operation has been created successfully!" | ||
); | ||
cy.dataCy("approve-dialog").click(); | ||
}); | ||
|
||
it("should redirect after operation creation", () => { | ||
cy.dataCy("activity-title").contains("Operations"); | ||
}); | ||
|
||
it("should cancel the cancellation of the operation creation", () => { | ||
cy.dataCy("add-new-operation").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.exist"); | ||
}); | ||
|
||
it("should cancel the operation creation", () => { | ||
cy.dataCy("cancel-form").click(); | ||
cy.dataCy("approve-dialog").click(); | ||
cy.dataCy("dialog-info").should("not.exist"); | ||
cy.dataCy("activity-title").contains("Operations"); | ||
}); | ||
}); |
53 changes: 53 additions & 0 deletions
53
cypress/integrations/admin_activities/operations_activities/edit_operation_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,53 @@ | ||
/// <reference types="cypress" /> | ||
|
||
const OPERATION_START_PATH = "/admin/operations"; | ||
|
||
describe("Operations Edit Activity specs", () => { | ||
it("should render the ui", () => { | ||
cy.authenticate(OPERATION_START_PATH); | ||
cy.dataCy("activity-title").contains("Operations"); | ||
}); | ||
|
||
it("should show operation edit form", () => { | ||
cy.dataCy("table-edit-action").first().click(); | ||
cy.dataCy("activity-title").contains("Edit Operation"); | ||
}); | ||
|
||
it("should fail to edit the operation", () => { | ||
cy.byId("code").should("be.disabled"); | ||
cy.get('input[name="major"]').uncheck(); | ||
cy.get('input[name="major"]').check(); | ||
cy.byId("type").clear().blur(); | ||
cy.dataCy("submit-form").click(); | ||
cy.dataCy("dialog-info").should("not.exist"); | ||
}); | ||
|
||
it("should successfully save operation changes", () => { | ||
cy.byId("type").click(); | ||
cy.get('.MuiAutocomplete-popper li[data-option-index="0"]').click(); | ||
cy.dataCy("submit-form").click(); | ||
cy.dataCy("dialog-info").contains("has been updated successfully!"); | ||
cy.dataCy("approve-dialog").click(); | ||
}); | ||
|
||
it("should redirect after operation update", () => { | ||
cy.dataCy("activity-title").contains("Operations"); | ||
}); | ||
|
||
it("should cancel the cancellation of the operation creation", () => { | ||
cy.dataCy("table-edit-action").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 operation update", () => { | ||
cy.dataCy("cancel-form").click(); | ||
cy.dataCy("approve-dialog").click(); | ||
cy.dataCy("dialog-info").should("not.exist"); | ||
cy.dataCy("activity-title").contains("Operations"); | ||
}); | ||
}); |
19 changes: 19 additions & 0 deletions
19
cypress/integrations/admin_activities/operations_activities/manage_operations_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,19 @@ | ||
/// <reference types="cypress" /> | ||
|
||
const OPERATIONS_START_PATH = "/admin/operations"; | ||
|
||
describe("Operations Activity specs", () => { | ||
it("should render the ui", () => { | ||
cy.authenticate(OPERATIONS_START_PATH); | ||
cy.dataCy("activity-title").contains("Operations"); | ||
}); | ||
|
||
it("should present the table with four rows", () => { | ||
cy.dataCy("operations-table") | ||
.find("table") | ||
.then(($table) => { | ||
const rows = $table.find("tbody tr"); | ||
expect(rows.length).equal(4); | ||
}); | ||
}); | ||
}); |
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