diff --git a/cypress/integrations/admin_activities/diseases_activities/add_disease_activity.cy.ts b/cypress/integrations/admin_activities/diseases_activities/add_disease_activity.cy.ts new file mode 100644 index 000000000..613c8e037 --- /dev/null +++ b/cypress/integrations/admin_activities/diseases_activities/add_disease_activity.cy.ts @@ -0,0 +1,55 @@ +/// + +const DISEASE_STARTS_PATH = "/admin/diseases"; + +describe("Add Disease Activity specs", () => { + it("should render the ui", () => { + cy.authenticate(DISEASE_STARTS_PATH); + cy.dataCy("activity-title").contains("Diseases"); + }); + + it("should show disease creation form", () => { + cy.dataCy("add-new-disease").click(); + cy.dataCy("activity-title").contains("Add Disease"); + }); + + it("should fail to create a new disease", () => { + cy.byId("code").type("FAIL"); + cy.byId("diseaseType").click(); + cy.get('.MuiAutocomplete-popper li[data-option-index="0"]').click(); + cy.byId("description").type("Children disease"); + cy.get('input[name="opdInclude"]').check(); + cy.get('input[name="ipdInInclude"]').check(); + cy.get('input[name="ipdInInclude"]').uncheck(); + cy.dataCy("submit-form").click(); + cy.dataCy("info-box").contains("Fail"); + }); + + it("should successfully create a new disease", () => { + cy.byId("code").clear().type("22"); + cy.dataCy("submit-form").click(); + cy.dataCy("dialog-info").contains("Disease has been created successfully!"); + cy.dataCy("approve-dialog").click(); + }); + + it("should redirect after disease creation", () => { + cy.dataCy("activity-title").contains("Diseases"); + }); + + it("should cancel the cancellation of the disease creation", () => { + cy.dataCy("add-new-disease").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 disease creation", () => { + cy.dataCy("cancel-form").click(); + cy.dataCy("approve-dialog").click(); + cy.dataCy("dialog-info").should("not.exist"); + cy.dataCy("activity-title").contains("Diseases"); + }); +}); diff --git a/cypress/integrations/admin_activities/diseases_activities/edit_disease_activity.cy.ts b/cypress/integrations/admin_activities/diseases_activities/edit_disease_activity.cy.ts new file mode 100644 index 000000000..ba877fda8 --- /dev/null +++ b/cypress/integrations/admin_activities/diseases_activities/edit_disease_activity.cy.ts @@ -0,0 +1,53 @@ +/// + +const DISEASE_START_PATH = "/admin/diseases"; + +describe("Diseases Edit Activity specs", () => { + it("should render the ui", () => { + cy.authenticate(DISEASE_START_PATH); + cy.dataCy("activity-title").contains("Diseases"); + }); + + it("should show disease edit form", () => { + cy.dataCy("table-edit-action").first().click(); + cy.dataCy("activity-title").contains("Edit Disease"); + }); + + it("should fail to edit the disease", () => { + cy.byId("code").should("be.disabled"); + cy.get('input[name="opdInclude"]').uncheck(); + cy.get('input[name="ipdInInclude"]').check(); + cy.byId("diseaseType").clear(); + cy.dataCy("submit-form").click(); + cy.dataCy("dialog-info").should("not.exist"); + }); + + it("should successfully save disease changes", () => { + cy.byId("diseaseType").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 disease update", () => { + cy.dataCy("activity-title").contains("Diseases"); + }); + + it("should cancel the cancellation of the disease 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.exist"); + }); + + it("should cancel the disease update", () => { + cy.dataCy("cancel-form").click(); + cy.dataCy("approve-dialog").click(); + cy.dataCy("dialog-info").should("not.exist"); + cy.dataCy("activity-title").contains("Diseases"); + }); +}); diff --git a/cypress/integrations/admin_activities/diseases_activities/manage_diseases_activity.cy.ts b/cypress/integrations/admin_activities/diseases_activities/manage_diseases_activity.cy.ts new file mode 100644 index 000000000..920ee99c4 --- /dev/null +++ b/cypress/integrations/admin_activities/diseases_activities/manage_diseases_activity.cy.ts @@ -0,0 +1,19 @@ +/// + +const DISEASES_START_PATH = "/admin/diseases"; + +describe("Diseases Activity specs", () => { + it("should render the ui", () => { + cy.authenticate(DISEASES_START_PATH); + cy.dataCy("activity-title").contains("Diseases"); + }); + + it("should present the table with three rows", () => { + cy.dataCy("diseases-table") + .find("table") + .then(($table) => { + const rows = $table.find("tbody tr"); + expect(rows.length).equal(3); + }); + }); +}); diff --git a/cypress/integrations/admin_activities/wards_activities/add_ward_activity.cy.ts b/cypress/integrations/admin_activities/wards_activities/add_ward_activity.cy.ts index 8d6ac8401..e2f4a3ab5 100644 --- a/cypress/integrations/admin_activities/wards_activities/add_ward_activity.cy.ts +++ b/cypress/integrations/admin_activities/wards_activities/add_ward_activity.cy.ts @@ -2,7 +2,7 @@ const WARD_START_PATH = "/admin/wards"; -describe("Wards Activity specs", () => { +describe("Add Ward Activity specs", () => { it("should render the ui", () => { cy.authenticate(WARD_START_PATH); cy.dataCy("activity-title").contains("Wards"); diff --git a/cypress/integrations/admin_activities/wards_activities/edit_ward_activity.cy.ts b/cypress/integrations/admin_activities/wards_activities/edit_ward_activity.cy.ts index 57acada34..7338f58a3 100644 --- a/cypress/integrations/admin_activities/wards_activities/edit_ward_activity.cy.ts +++ b/cypress/integrations/admin_activities/wards_activities/edit_ward_activity.cy.ts @@ -2,7 +2,7 @@ const WARD_STARTS_PATH = "/admin/wards"; -describe("Wards Activity specs", () => { +describe("Edit Ward Activity specs", () => { it("should render the ui", () => { cy.authenticate(WARD_STARTS_PATH); cy.dataCy("activity-title").contains("Wards"); diff --git a/src/components/accessories/admin/diseases/Diseases.tsx b/src/components/accessories/admin/diseases/Diseases.tsx index cb4fd7313..3a112b82e 100644 --- a/src/components/accessories/admin/diseases/Diseases.tsx +++ b/src/components/accessories/admin/diseases/Diseases.tsx @@ -27,7 +27,7 @@ export const Diseases = () => { }; return ( -
+
{ onClick={() => { navigate(PATHS.admin_diseases_new); }} + dataCy="add-new-disease" type="button" variant="contained" color="primary" diff --git a/src/components/accessories/admin/diseases/diseaseForm/DiseaseForm.tsx b/src/components/accessories/admin/diseases/diseaseForm/DiseaseForm.tsx index bfd9590a6..36a2b034a 100644 --- a/src/components/accessories/admin/diseases/diseaseForm/DiseaseForm.tsx +++ b/src/components/accessories/admin/diseases/diseaseForm/DiseaseForm.tsx @@ -221,13 +221,19 @@ const DiseaseForm: FC = ({
-