diff --git a/cypress/integrations/admin_activities/types_activities/diseases_activities/add_disease_activity.cy.ts b/cypress/integrations/admin_activities/types_activities/diseases_activities/add_disease_activity.cy.ts
new file mode 100644
index 000000000..42200c5bc
--- /dev/null
+++ b/cypress/integrations/admin_activities/types_activities/diseases_activities/add_disease_activity.cy.ts
@@ -0,0 +1,52 @@
+///
+
+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");
+ });
+});
diff --git a/cypress/integrations/admin_activities/types_activities/diseases_activities/edit_disease_activity.cy.ts b/cypress/integrations/admin_activities/types_activities/diseases_activities/edit_disease_activity.cy.ts
new file mode 100644
index 000000000..21bee467e
--- /dev/null
+++ b/cypress/integrations/admin_activities/types_activities/diseases_activities/edit_disease_activity.cy.ts
@@ -0,0 +1,50 @@
+///
+
+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");
+ });
+});
diff --git a/cypress/integrations/admin_activities/types_activities/diseases_activities/manage_diseases_activity.cy.ts b/cypress/integrations/admin_activities/types_activities/diseases_activities/manage_diseases_activity.cy.ts
new file mode 100644
index 000000000..62bbbc4b3
--- /dev/null
+++ b/cypress/integrations/admin_activities/types_activities/diseases_activities/manage_diseases_activity.cy.ts
@@ -0,0 +1,38 @@
+///
+
+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);
+ });
+ });
+});
diff --git a/src/components/accessories/admin/types/components/diseases/DiseaseTypes.tsx b/src/components/accessories/admin/types/components/diseases/DiseaseTypes.tsx
index 641ebb940..3dfda736d 100644
--- a/src/components/accessories/admin/types/components/diseases/DiseaseTypes.tsx
+++ b/src/components/accessories/admin/types/components/diseases/DiseaseTypes.tsx
@@ -40,9 +40,9 @@ const DiseaseTypes = () => {
const { t } = useTranslation();
return (
<>
-
{t("diseaseTypes.title")}
+ {t("diseaseTypes.title")}
-
+
{
type="button"
variant="contained"
color="primary"
+ dataCy="add-disease-type"
>
{t("diseaseTypes.addDiseaseType")}
diff --git a/src/components/accessories/admin/types/components/diseases/diseaseTypesForm/DiseaseTypeForm.tsx b/src/components/accessories/admin/types/components/diseases/diseaseTypesForm/DiseaseTypeForm.tsx
index df2777ba7..090e6a8c0 100644
--- a/src/components/accessories/admin/types/components/diseases/diseaseTypesForm/DiseaseTypeForm.tsx
+++ b/src/components/accessories/admin/types/components/diseases/diseaseTypesForm/DiseaseTypeForm.tsx
@@ -140,7 +140,12 @@ const DiseaseTypeForm: FC = ({
-
@@ -148,6 +153,7 @@ const DiseaseTypeForm: FC
= ({
setOpenResetConfirmation(true)}
>
diff --git a/src/components/accessories/admin/types/components/diseases/editDiseaseType/EditDiseaseType.tsx b/src/components/accessories/admin/types/components/diseases/editDiseaseType/EditDiseaseType.tsx
index 0777aa8b4..344aac144 100644
--- a/src/components/accessories/admin/types/components/diseases/editDiseaseType/EditDiseaseType.tsx
+++ b/src/components/accessories/admin/types/components/diseases/editDiseaseType/EditDiseaseType.tsx
@@ -9,7 +9,7 @@ import { updateDiseaseType } from "../../../../../../../state/types/diseases/act
import { PATHS } from "../../../../../../../consts";
import { getInitialFields } from "../diseaseTypesForm/consts";
import DiseaseTypeForm from "../diseaseTypesForm/DiseaseTypeForm";
-import { setTypeMode } from "../../../../../../../state/types/config";
+import { setTypeMode, TypeMode } from "../../../../../../../state/types/config";
import "./styles.scss";
export const EditDiseaseType = () => {
@@ -20,14 +20,19 @@ export const EditDiseaseType = () => {
const update = useSelector>(
(state) => state.types.diseases.update
);
+ const mode = useSelector(
+ (state) => state.types.config.mode
+ );
const handleSubmit = (value: DiseaseTypeDTO) => {
dispatch(updateDiseaseType(value));
};
useEffect(() => {
- dispatch(setTypeMode("edit"));
- });
+ if (mode !== "edit") {
+ dispatch(setTypeMode("edit"));
+ }
+ }, [mode, dispatch]);
if (state?.code !== code) {
return ;
@@ -35,7 +40,9 @@ export const EditDiseaseType = () => {
return (
-
{t("diseaseTypes.editDiseaseType")}
+
+ {t("diseaseTypes.editDiseaseType")}
+
{
return (
-
{t("diseaseTypes.addDiseaseType")}
+
+ {t("diseaseTypes.addDiseaseType")}
+