diff --git a/cypress/e2e/updateQuestion.cy.js b/cypress/e2e/updateQuestion.cy.js index 92f5d5e..369168a 100644 --- a/cypress/e2e/updateQuestion.cy.js +++ b/cypress/e2e/updateQuestion.cy.js @@ -139,3 +139,22 @@ describe("Updating a Question using the Question editor", () => { }); }); }); + +describe("Update question using mode random", () => { + beforeEach(() => { + cy.fixture("repeatio-module-cypress_1.json").then((value) => { + localStorage.setItem("repeatio-module-cypress_1", JSON.stringify(value)); + }); + cy.visit("/module/cypress_1"); + cy.get("article[data-cy='Practice'").contains("button", "Random").click(); + cy.get("button[aria-label='Edit Question']").click(); + cy.get("div.ReactModal__Overlay").scrollIntoView(); + }); + + it("should show warning if trying to update question", () => { + cy.contains("button", "Update").click(); + cy.contains( + "Can't edit this questions while using mode random! Navigate to this question using the question overview." + ).should("exist"); + }); +}); diff --git a/src/components/Home/CreateModule.jsx b/src/components/Home/CreateModule.jsx index 02599d8..71c673f 100644 --- a/src/components/Home/CreateModule.jsx +++ b/src/components/Home/CreateModule.jsx @@ -161,8 +161,8 @@ export const CreateModule = ({ handleModalClose }) => { > {/* language values are defined in ISO-639-1 */} - + {/* Compatibility Info (Version of repeatio) */} diff --git a/src/components/QuestionEditor/QuestionEditor.jsx b/src/components/QuestionEditor/QuestionEditor.jsx index 99e41d7..7a7a555 100644 --- a/src/components/QuestionEditor/QuestionEditor.jsx +++ b/src/components/QuestionEditor/QuestionEditor.jsx @@ -112,16 +112,28 @@ export const Form = ({ prevQuestionID, handleModalClose }) => { //Return if there are any errors if (Object.keys(errors).length > 0) return; - //Setup variables - hasSubmitted.current = true; - let onSubmitErrors = {}; - if (isElectron()) { toast.warn("Can't edit question in electron for this time. Use your browser instead!"); handleModalClose(); return; } + //Don't allow question editing when using mode random + if (new URLSearchParams(search).get("mode") === "random") { + //TODO fix this + toast.warn( + "Can't edit this questions while using mode random! Navigate to this question using the question overview.", + { + autoClose: 12000, + } + ); + return; + } + + //Setup variables + hasSubmitted.current = true; + let onSubmitErrors = {}; + //Prevent adding to types module as it is originally saved in the public folder //Adding a question would create a module in the localStorage with the same id. if (moduleData?.id === "types_1") { diff --git a/src/components/toast/toast.css b/src/components/toast/toast.css index db029e2..69d19b0 100644 --- a/src/components/toast/toast.css +++ b/src/components/toast/toast.css @@ -14,6 +14,7 @@ /* Set font size */ .Toastify__toast p, +.Toastify__toast .Toastify__toast-body span, .Toastify__toast a span, .Toastify__toast a { font-size: 16px;