diff --git a/ui/cap-react/cypress.config.js b/ui/cap-react/cypress.config.js
index 5b7469f8ed..be7c6322c9 100644
--- a/ui/cap-react/cypress.config.js
+++ b/ui/cap-react/cypress.config.js
@@ -1,6 +1,6 @@
-const { defineConfig } = require("cypress");
+import { defineConfig } from "cypress";
-module.exports = defineConfig({
+export default defineConfig({
projectId: "4mpnou",
video: false,
downloadsFolder: "cypress/downloads",
diff --git a/ui/cap-react/cypress/e2e/drafts/create_draft_spec.js b/ui/cap-react/cypress/e2e/drafts/create_draft_spec.js
index f8f2aa98bf..cb2d1bb452 100644
--- a/ui/cap-react/cypress/e2e/drafts/create_draft_spec.js
+++ b/ui/cap-react/cypress/e2e/drafts/create_draft_spec.js
@@ -69,4 +69,23 @@ describe("Create Draft", function () {
cy.url().should("not.include", DRAFTS);
});
+
+ it("Save a draft with an empty required field", () => {
+ cy.loginUrl("info@inveniosoftware.org", "infoinfo");
+
+ // navigate to the draft
+ cy.get("[data-cy=DraftDocuments-list] a").first().click();
+
+ // navigate to edit tab
+ cy.get("[data-cy=itemNavEdit]").click();
+
+ // type in a normal field but leave the required field empty
+ cy.get("textarea#root\\!basic_info\\!abstract").type("whatever");
+
+ // save the draft
+ cy.get("[data-cy=draft-save-btn]").click();
+
+ // validate save
+ cy.get("div.ant-notification-notice-message").contains("Draft saved");
+ });
});
diff --git a/ui/cap-react/cypress/e2e/published/published_spec.js b/ui/cap-react/cypress/e2e/published/published_spec.js
index 973259f037..8b8de14cb4 100644
--- a/ui/cap-react/cypress/e2e/published/published_spec.js
+++ b/ui/cap-react/cypress/e2e/published/published_spec.js
@@ -9,6 +9,15 @@ describe("Published Tests", function () {
cy.get("[data-cy=DraftDocuments-list] a").first().click();
+ // navigate to edit tab
+ cy.get("[data-cy=itemNavEdit]").click();
+
+ // fill in the required field
+ cy.get("input#root\\!basic_info\\!cadi_id").type("JME-10-107");
+
+ //save the draft
+ cy.get("[data-cy=draft-save-btn]").click();
+
// navigate to settings tab
cy.get("[data-cy=itemNavSettings]").click();
@@ -45,6 +54,55 @@ describe("Published Tests", function () {
cy.get("[data-cy=changeToDraftButton]").click();
- cy.get("[ data-cy=sidebarStatus]").contains("draft");
+ cy.get("[data-cy=sidebarStatus]").contains("draft");
+ });
+
+ it("Does not allow publishing a draft with an empty required field", () => {
+ cy.createDraft("CMS Analysis", "empty-required", "cms");
+
+ cy.visit("/");
+
+ cy.get("[data-cy=DraftDocuments-list] a").first().click();
+
+ // 1. Check that the validation works without modifying the form data
+
+ // navigate to settings tab
+ cy.get("[data-cy=itemNavSettings]").click();
+
+ // click publish button
+ cy.get("[data-cy=draftSettingsRecidButton]").click();
+
+ // confirm publish action
+ cy.get("[data-cy=draftSettingsPublish]").click();
+
+ // verify that it throws an error
+ cy.get("div.ant-notification-notice-message").contains(
+ "Validation Error while publishing"
+ );
+
+ // 2. Check the that the validation works after modifying the form data
+
+ // navigate to edit tab
+ cy.get("[data-cy=itemNavEdit]").click();
+
+ // type in a normal field but leave the required field empty
+ cy.get("textarea#root\\!basic_info\\!abstract").type("asd");
+
+ // save the draft
+ cy.get("[data-cy=draft-save-btn]").click();
+
+ // navigate to settings tab
+ cy.get("[data-cy=itemNavSettings]").click();
+
+ // click publish button
+ cy.get("[data-cy=draftSettingsRecidButton]").click();
+
+ // confirm publish action
+ cy.get("[data-cy=draftSettingsPublish]").click();
+
+ // verify that it throws an error
+ cy.get("div.ant-notification-notice-message").contains(
+ "Validation Error while publishing"
+ );
});
});
diff --git a/ui/cap-react/src/antd/drafts/components/DraftItemNav/NavMenu.js b/ui/cap-react/src/antd/drafts/components/DraftItemNav/NavMenu.js
index 6ff5d84a65..79c91ac4a2 100644
--- a/ui/cap-react/src/antd/drafts/components/DraftItemNav/NavMenu.js
+++ b/ui/cap-react/src/antd/drafts/components/DraftItemNav/NavMenu.js
@@ -24,7 +24,14 @@ const NavMenu = ({ match, history, formErrors }) => {
},
{
key: "edit",
- label: Edit,
+ label: (
+
+ Edit
+
+ ),
icon: ,
danger: formErrors && formErrors.size > 0,
},
diff --git a/ui/cap-react/src/antd/drafts/components/Editor/Header.js b/ui/cap-react/src/antd/drafts/components/Editor/Header.js
index 81a467866e..d4c463d81a 100644
--- a/ui/cap-react/src/antd/drafts/components/Editor/Header.js
+++ b/ui/cap-react/src/antd/drafts/components/Editor/Header.js
@@ -174,6 +174,7 @@ const Header = ({
disabled={mode != "edit" || !canEdit(canAdmin, canUpdate)}
loading={loading}
onClick={_saveData}
+ data-cy="draft-save-btn"
>
Save