diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/hooks.js b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/hooks.js
index 1fb8fa6a8..5f10f2289 100644
--- a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/hooks.js
+++ b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/hooks.js
@@ -164,7 +164,7 @@ export const scoringCardHooks = (scoring, updateSettings, defaultValue) => {
const handleWeightChange = (event) => {
let weight = parseFloat(event.target.value);
- if (_.isNaN(weight)) {
+ if (_.isNaN(weight) || weight < 0) {
weight = 0;
}
updateSettings({ scoring: { ...scoring, weight } });
@@ -198,7 +198,7 @@ export const useAnswerSettings = (showAnswer, updateSettings) => {
const handleAttemptsChange = (event) => {
let attempts = parseInt(event.target.value, 10);
- if (_.isNaN(attempts)) {
+ if (_.isNaN(attempts) || attempts < 0) {
attempts = 0;
}
updateSettings({ showAnswer: { ...showAnswer, afterAttempts: attempts } });
@@ -214,7 +214,7 @@ export const useAnswerSettings = (showAnswer, updateSettings) => {
export const timerCardHooks = (updateSettings) => ({
handleChange: (event) => {
let time = parseInt(event.target.value, 10);
- if (_.isNaN(time)) {
+ if (_.isNaN(time) || time < 0) {
time = 0;
}
updateSettings({ timeBetween: time });
diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/ScoringCard.jsx b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/ScoringCard.jsx
index d7710313c..3935c7cb7 100644
--- a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/ScoringCard.jsx
+++ b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/ScoringCard.jsx
@@ -49,6 +49,8 @@ const ScoringCard = ({
(event) => {
if (!isAnswerRangeSet({ answers })) {
- const newTolerance = { value: event.target.value, type: tolerance.type };
+ let value = parseFloat(event.target.value);
+ if (value < 0) {
+ value = 0;
+ }
+ const newTolerance = { value, type: tolerance.type };
updateSettings({ tolerance: newTolerance });
}
};
@@ -92,6 +96,8 @@ const ToleranceCard = ({
{
const { queryByTestId } = render();
expect(queryByTestId('input')).toBeFalsy();
});
- it('Renders with intial value of tolerance', async () => {
+ it('Renders with initial value of tolerance', async () => {
const { queryByTestId } = render();
expect(queryByTestId('input')).toBeTruthy();
expect(screen.getByDisplayValue('0')).toBeTruthy();
@@ -146,7 +146,12 @@ describe('ToleranceCard', () => {
it('Calls change function on change.', () => {
const { queryByTestId } = render();
fireEvent.change(queryByTestId('input'), { target: { value: 52 } });
- expect(props.updateSettings).toHaveBeenCalledWith({ tolerance: { type: ToleranceTypes.number.type, value: '52' } });
+ expect(props.updateSettings).toHaveBeenCalledWith({ tolerance: { type: ToleranceTypes.number.type, value: 52 } });
+ });
+ it('Resets negative value on change.', () => {
+ const { queryByTestId } = render();
+ fireEvent.change(queryByTestId('input'), { target: { value: -52 } });
+ expect(props.updateSettings).toHaveBeenCalledWith({ tolerance: { type: ToleranceTypes.number.type, value: 0 } });
});
});
});
diff --git a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/__snapshots__/ScoringCard.test.jsx.snap b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/__snapshots__/ScoringCard.test.jsx.snap
index e6e044d92..9f07b02d0 100644
--- a/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/__snapshots__/ScoringCard.test.jsx.snap
+++ b/src/editors/containers/ProblemEditor/components/EditProblemView/SettingsWidget/settingsComponents/__snapshots__/ScoringCard.test.jsx.snap
@@ -20,7 +20,9 @@ exports[`ScoringCard snapshot snapshot: scoring setting card 1`] = `
@@ -36,8 +38,10 @@ exports[`ScoringCard snapshot snapshot: scoring setting card 1`] = `
@@ -111,8 +117,10 @@ exports[`ScoringCard snapshot snapshot: scoring setting card max attempts 1`] =
@@ -186,8 +196,10 @@ exports[`ScoringCard snapshot snapshot: scoring setting card zero zero weight 1`
updateField({
licenseDetails: {
diff --git a/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/LicenseWidget/LicenseDisplay.jsx b/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/LicenseWidget/LicenseDisplay.jsx
index a7799eb74..a67d40607 100644
--- a/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/LicenseWidget/LicenseDisplay.jsx
+++ b/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/LicenseWidget/LicenseDisplay.jsx
@@ -28,13 +28,15 @@ const LicenseDisplay = ({
{licenseDescription}
-
-
-
+ {license === LicenseTypes.creativeCommons && (
+
+
+
+ )}
);
}
diff --git a/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/LicenseWidget/__snapshots__/LicenseDisplay.test.jsx.snap b/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/LicenseWidget/__snapshots__/LicenseDisplay.test.jsx.snap
index 488422c90..655802d54 100644
--- a/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/LicenseWidget/__snapshots__/LicenseDisplay.test.jsx.snap
+++ b/src/editors/containers/VideoEditor/components/VideoSettingsModal/components/LicenseWidget/__snapshots__/LicenseDisplay.test.jsx.snap
@@ -26,17 +26,6 @@ exports[`LicenseDisplay snapshots snapshots: renders as expected with default pr
FormattedMessage component with license description
-
-
-
`;
@@ -66,17 +55,6 @@ exports[`LicenseDisplay snapshots snapshots: renders as expected with level set
FormattedMessage component with license description
-
-
-
`;
@@ -148,16 +126,5 @@ exports[`LicenseDisplay snapshots snapshots: renders as expected with level set
FormattedMessage component with license description
-
-
-
`;