@@ -16,35 +16,62 @@ export const multiselectQuestionFactory = (
1616 optOut ?: boolean ;
1717 multiselectQuestion ?: Partial < Prisma . MultiselectQuestionsCreateInput > ;
1818 } ,
19+ version2 = false ,
1920) : Prisma . MultiselectQuestionsCreateInput => {
2021 const previousMultiselectQuestion = optionalParams ?. multiselectQuestion || { } ;
22+ const name = optionalParams ?. multiselectQuestion ?. name || randomName ( ) ;
2123 const text = optionalParams ?. multiselectQuestion ?. text || randomName ( ) ;
22- return {
23- text : text ,
24- subText : `sub text for ${ text } ` ,
25- description : `description of ${ text } ` ,
26- links : [ ] ,
27- options : multiselectOptionFactory ( randomInt ( 1 , 3 ) ) ,
28- optOutText : optionalParams ?. optOut ? "I don't want this preference" : null ,
29- hideFromListing : false ,
24+ const baseFields = {
3025 applicationSection :
3126 optionalParams ?. multiselectQuestion ?. applicationSection ||
3227 multiselectAppSectionAsArray [
3328 randomInt ( multiselectAppSectionAsArray . length )
3429 ] ,
35-
36- // TODO: Temporary until after MSQ refactor
37- isExclusive : optionalParams ?. multiselectQuestion ?. isExclusive ?? false ,
38- multiselectOptions : undefined ,
39- name : text ,
40- status : MultiselectQuestionsStatusEnum . draft ,
41-
42- ...previousMultiselectQuestion ,
30+ hideFromListing : false ,
4331 jurisdiction : {
4432 connect : {
4533 id : jurisdictionId ,
4634 } ,
4735 } ,
36+ links : [ ] ,
37+ } ;
38+
39+ const v1Fields = {
40+ description : `description of ${ text } ` ,
41+ isExclusive : false ,
42+ name : text ,
43+ options : multiselectOptionFactory ( randomInt ( 1 , 3 ) ) ,
44+ optOutText : optionalParams ?. optOut ? "I don't want this preference" : null ,
45+ status : MultiselectQuestionsStatusEnum . draft ,
46+ subText : `sub text for ${ text } ` ,
47+ text : text ,
48+ } ;
49+ const v2Fields = {
50+ description : `description of ${ name } ` ,
51+ isExclusive : optionalParams ?. multiselectQuestion ?. isExclusive ?? false ,
52+ multiselectOptions : {
53+ createMany : {
54+ data : multiselectOptionFactoryV2 ( randomInt ( 1 , 3 ) ) ,
55+ } ,
56+ } ,
57+ name : name ,
58+ subText : `sub text for ${ name } ` ,
59+ status : MultiselectQuestionsStatusEnum . draft ,
60+ // TODO: Can be removed after MSQ refactor
61+ text : name ,
62+ } ;
63+
64+ if ( version2 ) {
65+ return {
66+ ...v2Fields ,
67+ ...previousMultiselectQuestion ,
68+ ...baseFields ,
69+ } ;
70+ }
71+ return {
72+ ...v1Fields ,
73+ ...previousMultiselectQuestion ,
74+ ...baseFields ,
4875 } ;
4976} ;
5077
@@ -58,3 +85,11 @@ const multiselectOptionFactory = (
5885 collectAddress : index % 2 === 0 ,
5986 } ) ) ;
6087} ;
88+
89+ const multiselectOptionFactoryV2 = ( numberToMake : number ) => {
90+ if ( ! numberToMake ) return [ ] ;
91+ return [ ...new Array ( numberToMake ) ] . map ( ( _ , index ) => ( {
92+ name : randomNoun ( ) ,
93+ ordinal : index ,
94+ } ) ) ;
95+ } ;
0 commit comments