From 8dda6e4aac34b518e0e28706ef3099446f631d1d Mon Sep 17 00:00:00 2001 From: Justin Gasper Date: Thu, 2 Apr 2026 19:49:02 +1100 Subject: [PATCH] PM-4685: remove unlimited submissions option What was broken The design challenge editor still showed an Unlimited submissions option even though that control is no longer used and did not work as expected. Root cause The maximum submissions field still rendered the legacy Unlimited checkbox and the editor still carried an update path for that unused metadata toggle. What was changed Removed the editable Unlimited checkbox from the design challenge maximum submissions field. Removed the unused unlimited update branch from challenge metadata handling. Kept the existing read-only display for legacy unlimited metadata so older challenge data still renders consistently. Any added/updated tests Added a MaximumSubmissionsField component test that covers removing the editable Unlimited option, preserving the legacy read-only display, and sanitizing the count input. --- .../MaximumSubmissions-Field/index.js | 18 ---- .../MaximumSubmissions-Field/index.test.js | 82 +++++++++++++++++++ src/components/ChallengeEditor/index.js | 3 - 3 files changed, 82 insertions(+), 21 deletions(-) create mode 100644 src/components/ChallengeEditor/MaximumSubmissions-Field/index.test.js diff --git a/src/components/ChallengeEditor/MaximumSubmissions-Field/index.js b/src/components/ChallengeEditor/MaximumSubmissions-Field/index.js index 03d0fc88..d35f972e 100644 --- a/src/components/ChallengeEditor/MaximumSubmissions-Field/index.js +++ b/src/components/ChallengeEditor/MaximumSubmissions-Field/index.js @@ -34,24 +34,6 @@ class MaximumSubmissionsField extends Component { {!readOnly && (
-
-
-
- onUpdateMetadata('submissionLimit', e.target.checked, 'unlimited')} - /> - -
-
-
diff --git a/src/components/ChallengeEditor/MaximumSubmissions-Field/index.test.js b/src/components/ChallengeEditor/MaximumSubmissions-Field/index.test.js new file mode 100644 index 00000000..c484d044 --- /dev/null +++ b/src/components/ChallengeEditor/MaximumSubmissions-Field/index.test.js @@ -0,0 +1,82 @@ +/* global describe, it, expect, beforeEach, afterEach, jest */ + +import React from 'react' +import ReactDOM from 'react-dom' +import { act, Simulate } from 'react-dom/test-utils' +import MaximumSubmissionsField from './index' + +describe('MaximumSubmissionsField', () => { + let container + + const renderComponent = (props = {}) => { + act(() => { + ReactDOM.render( + {}} + {...props} + />, + container + ) + }) + } + + beforeEach(() => { + container = document.createElement('div') + document.body.appendChild(container) + }) + + afterEach(() => { + ReactDOM.unmountComponentAtNode(container) + container.remove() + container = null + jest.clearAllMocks() + }) + + it('does not render the unlimited option while editing', () => { + renderComponent({ + challenge: { + metadata: [ + { + name: 'submissionLimit', + value: '{"unlimited":"true","limit":"false","count":""}' + } + ] + } + }) + + expect(container.querySelector('#unlimited')).toBeNull() + expect(container.querySelector('#limit')).not.toBeNull() + expect(container.textContent).not.toContain('Unlimited') + }) + + it('shows unlimited in read-only mode for legacy metadata', () => { + renderComponent({ + readOnly: true, + challenge: { + metadata: [ + { + name: 'submissionLimit', + value: '{"unlimited":"true","limit":"false","count":""}' + } + ] + } + }) + + expect(container.textContent).toContain('Unlimited') + }) + + it('sanitizes the count input before updating metadata', () => { + const onUpdateMetadata = jest.fn() + + renderComponent({ onUpdateMetadata }) + + const countInput = container.querySelector('#count') + + act(() => { + Simulate.change(countInput, { target: { value: '12abc' } }) + }) + + expect(onUpdateMetadata).toHaveBeenCalledWith('submissionLimit', '12', 'count') + }) +}) diff --git a/src/components/ChallengeEditor/index.js b/src/components/ChallengeEditor/index.js index 3d21e062..73a97a4f 100644 --- a/src/components/ChallengeEditor/index.js +++ b/src/components/ChallengeEditor/index.js @@ -637,9 +637,6 @@ class ChallengeEditor extends Component { if (path === 'count') { submissionLimit.limit = 'true' submissionLimit.unlimited = 'false' - } else if (path === 'unlimited' && value) { - submissionLimit.limit = 'false' - submissionLimit.count = '' } existingMetadata.value = JSON.stringify(submissionLimit) } else if (existingMetadata.name === 'show_data_dashboard') {