mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-29 11:26:25 -05:00
Download forms: allow a frequency of "Once" (#804)
* app: a download frequency of "Once" no longer blocks submission useForm treated any falsy value as a missing required field. "Once" is frequency 0, so the Channel/Playlist, RSS, and Zim download forms never became ready and the Download button stayed disabled. Only null, undefined, '', false, and NaN count as missing now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * downloads: editing to "Once" stores a once-download, not frequency 0 Once-downloads have a NULL frequency. A 0 frequency counted as recurring (frequency != None) but could never be scheduled (not frequency), so an edited download stayed on the recurring list and could break renewal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
c8d5765ea3
commit
d75be8e1a4
5 changed files with 65 additions and 1 deletions
|
|
@ -727,6 +727,29 @@ describe('useForm', () => {
|
|||
});
|
||||
});
|
||||
|
||||
it('zero satisfies a required field', async () => {
|
||||
// A download frequency of 0 means "Once".
|
||||
const {result} = renderHook(() => useForm({
|
||||
defaultFormData: {frequency: null},
|
||||
submitter: jest.fn(),
|
||||
}));
|
||||
|
||||
act(() => {
|
||||
result.current.getCustomProps({name: 'frequency', required: true});
|
||||
});
|
||||
await waitFor(() => {
|
||||
expect(result.current.ready).toBe(false);
|
||||
});
|
||||
|
||||
act(() => {
|
||||
result.current.setValue('frequency', 0);
|
||||
});
|
||||
await waitFor(() => {
|
||||
expect(result.current.formData.frequency).toBe(0);
|
||||
expect(result.current.ready).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
it('addRequires marks field as required', async () => {
|
||||
const {result} = renderHook(() => useForm({
|
||||
defaultFormData: {field: ''},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue