forked from informatici/openhospital-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.
chore:OH2-329 | Tests / Add cypress e2e tests to cover admin/vaccines (…
- Loading branch information
Showing
5 changed files
with
148 additions
and
17 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
cypress/integrations/admin_activities/vaccines_activities/add_vaccine_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 VACCINE_STARTS_PATH = "/admin/vaccines"; | ||
|
||
describe("Add Vaccine Activity specs", () => { | ||
it("should render the ui", () => { | ||
cy.authenticate(VACCINE_STARTS_PATH); | ||
cy.dataCy("activity-title").contains("Vaccines"); | ||
}); | ||
|
||
it("should show vaccine creation form", () => { | ||
cy.dataCy("add-new-vaccine").click(); | ||
cy.dataCy("activity-title").contains("Add Vaccine"); | ||
}); | ||
|
||
it("should fail to create a new vaccine", () => { | ||
cy.byId("code").type("FAIL"); | ||
cy.byId("vaccineType").click(); | ||
cy.get('.MuiAutocomplete-popper li[data-option-index="0"]').click(); | ||
cy.byId("description").type("Children vaccine"); | ||
cy.dataCy("submit-form").click(); | ||
cy.dataCy("info-box").contains("Fail"); | ||
}); | ||
|
||
it("should successfully create a new vaccine", () => { | ||
cy.byId("code").clear().type("22"); | ||
cy.dataCy("submit-form").click(); | ||
cy.dataCy("dialog-info").contains("Vaccine has been created successfully!"); | ||
cy.dataCy("approve-dialog").click(); | ||
}); | ||
|
||
it("should redirect after vaccine creation", () => { | ||
cy.dataCy("activity-title").contains("Vaccines"); | ||
}); | ||
|
||
it("should cancel the cancellation of the vaccine creation", () => { | ||
cy.dataCy("add-new-vaccine").click(); | ||
cy.dataCy("cancel-form").click(); | ||
cy.dataCy("dialog-info").contains( | ||
"Are you sure to cancel the vaccine creation" | ||
); | ||
cy.dataCy("close-dialog").click(); | ||
cy.dataCy("dialog-info").should("not.exist"); | ||
}); | ||
|
||
it("should cancel the vaccine creation", () => { | ||
cy.dataCy("cancel-form").click(); | ||
cy.dataCy("approve-dialog").click(); | ||
cy.dataCy("dialog-info").should("not.exist"); | ||
cy.dataCy("activity-title").contains("Vaccines"); | ||
}); | ||
}); |
51 changes: 51 additions & 0 deletions
51
cypress/integrations/admin_activities/vaccines_activities/edit_vaccine_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,51 @@ | ||
/// <reference types="cypress" /> | ||
|
||
const VACCINE_START_PATH = "/admin/vaccines"; | ||
|
||
describe("Vaccines Edit Activity specs", () => { | ||
it("should render the ui", () => { | ||
cy.authenticate(VACCINE_START_PATH); | ||
cy.dataCy("activity-title").contains("Vaccines"); | ||
}); | ||
|
||
it("should show vaccine edit form", () => { | ||
cy.dataCy("table-edit-action").first().click(); | ||
cy.dataCy("activity-title").contains("Edit Vaccine"); | ||
}); | ||
|
||
it("should fail to edit the vaccine", () => { | ||
cy.byId("code").should("be.disabled"); | ||
cy.byId("vaccineType").clear().blur(); | ||
cy.dataCy("submit-form").click(); | ||
cy.dataCy("dialog-info").should("not.exist"); | ||
}); | ||
|
||
it("should successfully save vaccine changes", () => { | ||
cy.byId("vaccineType").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 vaccine update", () => { | ||
cy.dataCy("activity-title").contains("Vaccines"); | ||
}); | ||
|
||
it("should cancel the cancellation of the vaccine creation", () => { | ||
cy.dataCy("table-edit-action").first().click(); | ||
cy.dataCy("cancel-form").click(); | ||
cy.dataCy("dialog-info").contains( | ||
"Are you sure to cancel the vaccine update" | ||
); | ||
cy.dataCy("close-dialog").click(); | ||
cy.dataCy("dialog-info").should("not.exist"); | ||
}); | ||
|
||
it("should cancel the vaccine update", () => { | ||
cy.dataCy("cancel-form").click(); | ||
cy.dataCy("approve-dialog").click(); | ||
cy.dataCy("dialog-info").should("not.exist"); | ||
cy.dataCy("activity-title").contains("Vaccines"); | ||
}); | ||
}); |
19 changes: 19 additions & 0 deletions
19
cypress/integrations/admin_activities/vaccines_activities/manage_vaccines_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 VACCINES_START_PATH = "/admin/vaccines"; | ||
|
||
describe("Vaccines Activity specs", () => { | ||
it("should render the ui", () => { | ||
cy.authenticate(VACCINES_START_PATH); | ||
cy.dataCy("activity-title").contains("Vaccines"); | ||
}); | ||
|
||
it("should present the table with eight rows", () => { | ||
cy.dataCy("vaccines-table") | ||
.find("table") | ||
.then(($table) => { | ||
const rows = $table.find("tbody tr"); | ||
expect(rows.length).equal(8); | ||
}); | ||
}); | ||
}); |
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