@@ -191,6 +191,75 @@ describe('JobService', () => {
191191 expect ( expression ?. optionIds . toArray ( ) ) . toEqual ( [ 'newOpt1' ] ) ;
192192 } ) ;
193193
194+ it ( 'should preserve the otherSelected flag when remapping conditions' , ( ) => {
195+ const sourceTask = new Task (
196+ 'src' ,
197+ TaskType . MULTIPLE_CHOICE ,
198+ 'Source' ,
199+ false ,
200+ 0 ,
201+ new MultipleChoice ( Cardinality . SELECT_ONE , List ( [ ] ) , true )
202+ ) ;
203+ const dependentTask = new Task (
204+ 'dep' ,
205+ TaskType . TEXT ,
206+ 'Dependent' ,
207+ false ,
208+ 1 ,
209+ undefined ,
210+ new TaskCondition (
211+ TaskConditionMatchType . MATCH_ALL ,
212+ List ( [
213+ new TaskConditionExpression (
214+ TaskConditionExpressionType . ONE_OF_SELECTED ,
215+ 'src' ,
216+ List ( [ ] ) ,
217+ /* otherSelected= */ true
218+ ) ,
219+ ] )
220+ )
221+ ) ;
222+ const job = new Job (
223+ 'job1' ,
224+ 0 ,
225+ '#000' ,
226+ 'Job 1' ,
227+ Map ( { src : sourceTask , dep : dependentTask } ) ,
228+ DataCollectionStrategy . MIXED
229+ ) ;
230+
231+ const newSourceTask = new Task (
232+ 'newSrc' ,
233+ TaskType . MULTIPLE_CHOICE ,
234+ 'Source' ,
235+ false ,
236+ 0 ,
237+ new MultipleChoice ( Cardinality . SELECT_ONE , List ( [ ] ) , true )
238+ ) ;
239+ const newDependentTask = new Task (
240+ 'newDep' ,
241+ TaskType . TEXT ,
242+ 'Dependent' ,
243+ false ,
244+ 1 ,
245+ undefined ,
246+ dependentTask . condition
247+ ) ;
248+ dataStoreServiceSpy . generateId . and . returnValue ( 'job2' ) ;
249+ taskServiceSpy . duplicateTask . and . returnValues (
250+ newSourceTask ,
251+ newDependentTask
252+ ) ;
253+
254+ const newJob = service . duplicateJob ( job , '#FFF' ) ;
255+
256+ const expression = newJob . tasks
257+ ?. get ( 'newDep' )
258+ ?. condition ?. expressions . first ( ) ;
259+ expect ( expression ?. taskId ) . toBe ( 'newSrc' ) ;
260+ expect ( expression ?. otherSelected ) . toBe ( true ) ;
261+ } ) ;
262+
194263 it ( 'should drop condition expressions whose source task is missing' , ( ) => {
195264 const dependentTask = new Task (
196265 'dep' ,
0 commit comments