diff --git a/cypress/e2e/content/content.spec.js b/cypress/e2e/content/content.spec.js index e3459fcc11..774d0cc93f 100644 --- a/cypress/e2e/content/content.spec.js +++ b/cypress/e2e/content/content.spec.js @@ -142,7 +142,43 @@ describe("Content Specs", () => { // TODO: Need to confirm toggling of value it("Yes/No Field", () => { + // Click the "Yes" button to select it + cy.get("#12-575f7c-trw1w3 button").contains("Yes").click({ force: true }); + + // Check if the "Yes" button has the ".Mui-selected" class + cy.get("#12-575f7c-trw1w3 button") + .contains("Yes") + .should("have.class", "Mui-selected"); + + // Click the "Yes" button again to deselect it cy.get("#12-575f7c-trw1w3 button").contains("Yes").click(); + + // Check if neither "Yes" nor "No" buttons have the ".Mui-selected" class + cy.get("#12-575f7c-trw1w3 button") + .contains("Yes") + .should("not.have.class", "Mui-selected"); + cy.get("#12-575f7c-trw1w3 button") + .contains("No") + .should("not.have.class", "Mui-selected"); + + // Click the "No" button to select it + cy.get("#12-575f7c-trw1w3 button").contains("No").click(); + + // Check if the "No" button has the ".Mui-selected" class + cy.get("#12-575f7c-trw1w3 button") + .contains("No") + .should("have.class", "Mui-selected"); + + // Click the "No" button again to deselect it + cy.get("#12-575f7c-trw1w3 button").contains("No").click(); + + // Check again if neither "Yes" nor "No" buttons have the ".Mui-selected" class + cy.get("#12-575f7c-trw1w3 button") + .contains("Yes") + .should("not.have.class", "Mui-selected"); + cy.get("#12-575f7c-trw1w3 button") + .contains("No") + .should("not.have.class", "Mui-selected"); }); // TODO: Need to confirm toggling of value diff --git a/src/apps/content-editor/src/app/components/Editor/Editor.js b/src/apps/content-editor/src/app/components/Editor/Editor.js index fb1d93a2b6..1416531ad5 100644 --- a/src/apps/content-editor/src/app/components/Editor/Editor.js +++ b/src/apps/content-editor/src/app/components/Editor/Editor.js @@ -120,7 +120,7 @@ export default memo(function Editor({ itemZUID: itemZUID, key: name, // convert empty strings to null - value: value || null, + value: value === "" ? null : value, }); // If we are working with a new item