Skip to content

Commit c7335eb

Browse files
authored
Merge pull request #1735 from PhilanthropyDataCommons/1670-add-instructions-to-applicationformfield
Add Instructions field to ApplicationFormField
2 parents e7793d4 + b7ec6a1 commit c7335eb

15 files changed

+194
-6
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## 0.20.2 2025-07-10
9+
10+
### Added
11+
12+
- `ApplicationFormField` now have an `instructions` attribute.
13+
814
## 0.20.1 2025-07-10
915

1016
### Added

src/__tests__/applicationForms.int.test.ts

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,24 +202,28 @@ describe('/applicationForms', () => {
202202
baseFieldShortCode: 'yearsOfWork',
203203
position: 1,
204204
label: 'Anni Worki',
205+
instructions: 'Please enter the number of years of work.',
205206
});
206207
await createApplicationFormField(db, null, {
207208
applicationFormId: 3,
208209
baseFieldShortCode: 'organizationName',
209210
position: 2,
210211
label: 'Org Nomen',
212+
instructions: 'Please enter the name of the organization.',
211213
});
212214
await createApplicationFormField(db, null, {
213215
applicationFormId: 2,
214216
baseFieldShortCode: 'organizationName',
215217
position: 2,
216218
label: 'Name of Organization',
219+
instructions: 'Please enter the name of the organization.',
217220
});
218221
await createApplicationFormField(db, null, {
219222
applicationFormId: 2,
220223
baseFieldShortCode: 'yearsOfWork',
221224
position: 1,
222225
label: 'Duration of work in years',
226+
instructions: 'Please enter the number of years of work.',
223227
});
224228
const result = await request(app)
225229
.get('/applicationForms/2')
@@ -290,12 +294,14 @@ describe('/applicationForms', () => {
290294
baseFieldShortCode: 'organizationName',
291295
position: 2,
292296
label: 'Name of Organization',
297+
instructions: 'Please enter the name of the organization.',
293298
});
294299
await createApplicationFormField(db, null, {
295300
applicationFormId: 1,
296301
baseFieldShortCode: 'yearsOfWork',
297302
position: 1,
298303
label: 'Duration of work in years',
304+
instructions: 'Please enter the number of years of work.',
299305
});
300306
const result = await request(app)
301307
.get('/applicationForms/1')
@@ -320,6 +326,7 @@ describe('/applicationForms', () => {
320326
},
321327
position: 1,
322328
label: 'Duration of work in years',
329+
instructions: 'Please enter the number of years of work.',
323330
createdAt: expectTimestamp(),
324331
},
325332
{
@@ -334,6 +341,84 @@ describe('/applicationForms', () => {
334341
},
335342
position: 2,
336343
label: 'Name of Organization',
344+
instructions: 'Please enter the name of the organization.',
345+
createdAt: expectTimestamp(),
346+
},
347+
],
348+
createdAt: expectTimestamp(),
349+
});
350+
});
351+
it('returns an application form with its fields when the user has read access to the relevant funder, and the instructions are null', async () => {
352+
const systemFunder = await loadSystemFunder(db, null);
353+
const systemUser = await loadSystemUser(db, null);
354+
const systemUserAuthContext = getAuthContext(systemUser);
355+
const testUser = await loadTestUser();
356+
await createOrUpdateUserFunderPermission(db, systemUserAuthContext, {
357+
userKeycloakUserId: testUser.keycloakUserId,
358+
funderShortCode: systemFunder.shortCode,
359+
permission: Permission.VIEW,
360+
});
361+
await createOpportunity(db, null, {
362+
title: 'Holiday opportunity 🎄',
363+
funderShortCode: systemFunder.shortCode,
364+
});
365+
await createApplicationForm(db, null, {
366+
opportunityId: 1,
367+
});
368+
await createTestBaseFields();
369+
await createApplicationFormField(db, null, {
370+
applicationFormId: 1,
371+
baseFieldShortCode: 'organizationName',
372+
position: 2,
373+
label: 'Name of Organization',
374+
instructions: null,
375+
});
376+
await createApplicationFormField(db, null, {
377+
applicationFormId: 1,
378+
baseFieldShortCode: 'yearsOfWork',
379+
position: 1,
380+
label: 'Duration of work in years',
381+
instructions: null,
382+
});
383+
const result = await request(app)
384+
.get('/applicationForms/1')
385+
.set(authHeader)
386+
.expect(200);
387+
388+
expect(result.body).toMatchObject({
389+
id: 1,
390+
opportunityId: 1,
391+
version: 1,
392+
fields: [
393+
{
394+
applicationFormId: 1,
395+
baseFieldShortCode: 'yearsOfWork',
396+
baseField: {
397+
label: 'Years of work',
398+
description:
399+
'The number of years the project will take to complete',
400+
shortCode: 'yearsOfWork',
401+
dataType: BaseFieldDataType.STRING,
402+
createdAt: expectTimestamp(),
403+
},
404+
position: 1,
405+
label: 'Duration of work in years',
406+
instructions: null,
407+
createdAt: expectTimestamp(),
408+
},
409+
{
410+
applicationFormId: 1,
411+
baseFieldShortCode: 'organizationName',
412+
baseField: {
413+
label: 'Organization Name',
414+
description: 'The organizational name of the applicant',
415+
shortCode: 'organizationName',
416+
dataType: BaseFieldDataType.STRING,
417+
createdAt: expectTimestamp(),
418+
},
419+
position: 2,
420+
label: 'Name of Organization',
421+
instructions: null,
337422
createdAt: expectTimestamp(),
338423
},
339424
],
@@ -365,6 +450,7 @@ describe('/applicationForms', () => {
365450
baseFieldShortCode: forbiddenBaseField.shortCode,
366451
position: 1,
367452
label: 'Anni Worki',
453+
instructions: 'Please enter the number of years of work.',
368454
});
369455
await createOrUpdateBaseField(db, null, {
370456
...forbiddenBaseField,
@@ -412,12 +498,14 @@ describe('/applicationForms', () => {
412498
baseFieldShortCode: 'organizationName',
413499
position: 2,
414500
label: 'Name of Organization',
501+
instructions: 'Please enter the name of the organization.',
415502
});
416503
await createApplicationFormField(db, null, {
417504
applicationFormId: 1,
418505
baseFieldShortCode: 'yearsOfWork',
419506
position: 1,
420507
label: 'Duration of work in years',
508+
instructions: 'Please enter the number of years of work.',
421509
});
422510
await request(app).get('/applicationForms/1').set(authHeader).expect(404);
423511
});
@@ -560,6 +648,7 @@ describe('/applicationForms', () => {
560648
baseFieldShortCode: 'organizationName',
561649
position: 1,
562650
label: 'Organization Name',
651+
instructions: 'Please enter the name of the organization.',
563652
},
564653
],
565654
})
@@ -578,6 +667,7 @@ describe('/applicationForms', () => {
578667
createdAt: expectTimestamp(),
579668
id: 1,
580669
label: 'Organization Name',
670+
instructions: 'Please enter the name of the organization.',
581671
position: 1,
582672
},
583673
],

src/__tests__/changemakers.int.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,8 @@ describe('/changemakers', () => {
463463
applicationFormId: applicationFormIdEarliest,
464464
baseFieldShortCode,
465465
position: 5279,
466+
instructions:
467+
'Please enter the email address of the organization.',
466468
})
467469
).id,
468470
position: 5297,
@@ -488,6 +490,8 @@ describe('/changemakers', () => {
488490
applicationFormId: applicationFormIdLatestValid,
489491
baseFieldShortCode,
490492
position: 5347,
493+
instructions:
494+
'Please enter the email address of the organization.',
491495
})
492496
).id,
493497
position: 5381,
@@ -517,6 +521,8 @@ describe('/changemakers', () => {
517521
applicationFormId: applicationFormIdLatest,
518522
baseFieldShortCode,
519523
position: 5209,
524+
instructions:
525+
'Please enter the email address of the organization.',
520526
})
521527
).id,
522528
position: 5231,
@@ -586,6 +592,8 @@ describe('/changemakers', () => {
586592
applicationFormId: applicationFormIdChangemakerEarliest,
587593
baseFieldShortCode,
588594
position: 5407,
595+
instructions:
596+
'Please enter the phone number of the organization.',
589597
})
590598
).id,
591599
position: 5413,
@@ -613,6 +621,8 @@ describe('/changemakers', () => {
613621
applicationFormId: applicationFormIdFunderLatest,
614622
baseFieldShortCode,
615623
position: 5417,
624+
instructions:
625+
'Please enter the phone number of the organization.',
616626
})
617627
).id,
618628
position: 5419,
@@ -675,6 +685,8 @@ describe('/changemakers', () => {
675685
applicationFormId: applicationFormIdFunderEarliest,
676686
baseFieldShortCode,
677687
position: 5437,
688+
instructions:
689+
'Please enter the phone number of the organization.',
678690
})
679691
).id,
680692
position: 5441,
@@ -701,6 +713,8 @@ describe('/changemakers', () => {
701713
applicationFormId: applicationFormIdDataProviderLatest,
702714
baseFieldShortCode,
703715
position: 5443,
716+
instructions:
717+
'Please enter the phone number of the organization.',
704718
})
705719
).id,
706720
position: 5449,
@@ -764,6 +778,7 @@ describe('/changemakers', () => {
764778
applicationFormId: applicationFormIdDataProviderEarliest,
765779
baseFieldShortCode: baseFieldWebsite.shortCode,
766780
position: 5479,
781+
instructions: 'Please enter the website of the organization.',
767782
})
768783
).id,
769784
position: 5483,
@@ -793,6 +808,7 @@ describe('/changemakers', () => {
793808
applicationFormId: applicationFormIdDataProviderLatest,
794809
baseFieldShortCode: baseFieldWebsite.shortCode,
795810
position: 5501,
811+
instructions: 'Please enter the website of the organization.',
796812
})
797813
).id,
798814
position: 5503,
@@ -852,6 +868,7 @@ describe('/changemakers', () => {
852868
applicationFormId: applicationForm.id,
853869
baseFieldShortCode: forbiddenBaseField.shortCode,
854870
position: 1,
871+
instructions: 'Please enter the forbidden field.',
855872
},
856873
);
857874
const proposalVersion = await createProposalVersion(

src/__tests__/proposalVersions.int.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,12 +363,14 @@ describe('/proposalVersions', () => {
363363
baseFieldShortCode: 'firstName',
364364
position: 1,
365365
label: 'First Name',
366+
instructions: 'Please enter the first name of the applicant.',
366367
});
367368
await createApplicationFormField(db, null, {
368369
applicationFormId: 1,
369370
baseFieldShortCode: 'lastName',
370371
position: 2,
371372
label: 'Last Name',
373+
instructions: 'Please enter the last name of the applicant.',
372374
});
373375
const before = await loadTableMetrics('proposal_field_values');
374376
const result = await request(app)
@@ -461,6 +463,7 @@ describe('/proposalVersions', () => {
461463
baseFieldShortCode: forbiddenBaseField.shortCode,
462464
position: 1,
463465
label: 'Forbidden Field',
466+
instructions: 'This field should not be used in proposal versions',
464467
},
465468
);
466469
const proposalVersion = await createProposalVersion(
@@ -801,12 +804,14 @@ describe('/proposalVersions', () => {
801804
baseFieldShortCode: 'firstName',
802805
position: 1,
803806
label: 'First Name',
807+
instructions: 'Please enter the first name of the applicant.',
804808
});
805809
await createApplicationFormField(db, null, {
806810
applicationFormId: 1,
807811
baseFieldShortCode: 'lastName',
808812
position: 2,
809813
label: 'Last Name',
814+
instructions: 'Please enter the last name of the applicant.',
810815
});
811816
const before = await loadTableMetrics('proposal_field_values');
812817
logger.debug('before: %o', before);

0 commit comments

Comments
 (0)