Skip to content

Commit 16877dc

Browse files
committed
fix(projects): require a pericope set before the Import tab can submit (#420)
The tab enabled Create Project without one while the modal refused the submit silently, so the button lit up and did nothing. A project cannot exist without a pericope set, so the rule now matches the field's required marker. Claude-Session: https://claude.ai/code/session_014fMrwRFHtdtJCL3QrvRFSJ
1 parent 79e8579 commit 16877dc

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

src/features/projects/components/UsfmImportTab.test.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const COMPLETE_FORM: ProjectFormData = {
2525
sourceLanguage: 1,
2626
sourceBible: 10,
2727
targetLanguage: 2,
28+
pericopeSetId: 1,
2829
};
2930

3031
/** jsdom's File has no usable `text()`, so the component's read path needs one supplied. */
@@ -206,7 +207,14 @@ describe('UsfmImportTab fields after validation (#420)', () => {
206207
expect(screen.getByRole('button', { name: 'createProject' })).toBeDisabled();
207208
});
208209

209-
it('enables Create Project once title, source bible and target language are set', async () => {
210+
it('keeps Create Project disabled without a pericope set, since the modal would refuse it', async () => {
211+
renderTab({ formData: { ...COMPLETE_FORM, pericopeSetId: null } });
212+
drop([usfmFile('gen.usfm', GEN)]);
213+
await waitFor(() => expect(screen.getByText('createProject')).toBeInTheDocument());
214+
expect(screen.getByRole('button', { name: 'createProject' })).toBeDisabled();
215+
});
216+
217+
it('enables Create Project once title, source bible, target language and pericope set are set', async () => {
210218
renderTab({ formData: COMPLETE_FORM });
211219
drop([usfmFile('gen.usfm', GEN)]);
212220
await waitFor(() => expect(screen.getByText('createProject')).toBeInTheDocument());

src/features/projects/components/UsfmImportTab.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,15 @@ export function UsfmImportTab({
9696
};
9797

9898
/**
99-
* #420's rule, which is not the New tab's: Book(s) comes from the files rather than a picker,
100-
* and Pericope Set is not part of it.
99+
* #420's rule plus the pericope set: Book(s) comes from the files rather than a picker, and a
100+
* project cannot exist without a pericope set, so the button must not light up before one is
101+
* chosen — the modal would only refuse the submit silently.
101102
*/
102103
const canSubmit =
103104
Boolean(formData.title.trim()) &&
104105
Boolean(formData.sourceBible) &&
105106
Boolean(formData.targetLanguage) &&
107+
Boolean(formData.pericopeSetId) &&
106108
accepted.length > 0;
107109

108110
// Before any file is accepted the tab is only the upload area; afterwards it is replaced by the

0 commit comments

Comments
 (0)