@@ -28,6 +28,7 @@ import inheritance_task_listitem_task from './__test_data__/inheritance_task_lis
2828import inheritance_task_mixed_children from './__test_data__/inheritance_task_mixed_children.json' ;
2929import numbered_list_items_with_paren from './__test_data__/numbered_list_items_with_paren.json' ;
3030import numbered_list_items_standard from './__test_data__/numbered_list_items_standard.json' ;
31+ import numbered_tasks_issue_3481 from './__test_data__/numbered_tasks_issue_3481.json' ;
3132import one_task from './__test_data__/one_task.json' ;
3233import callouts_nested_issue_2890_labelled from './__test_data__/callouts_nested_issue_2890_labelled.json' ;
3334import callout from './__test_data__/callout.json' ;
@@ -177,6 +178,48 @@ describe('cache', () => {
177178 expect ( tasks . length ) . toEqual ( 2 ) ;
178179 } ) ;
179180
181+ it ( 'visualise how Tasks handles sample tasks in issue #3481' , ( ) => {
182+ // This test name does not yet begin 'should', because it is only documenting/visualsing
183+ // the current behaviour - and not stating that the current behaviour is correct.
184+
185+ // See https://github.com/obsidian-tasks-group/obsidian-tasks/issues/3481
186+ // "Tasks query turns single-line tasks into multi-line tasks"
187+ const data = numbered_tasks_issue_3481 ;
188+ const tasks = readTasksFromSimulatedFile ( data ) ;
189+ expect ( data . fileContents ) . toMatchInlineSnapshot ( `
190+ "# numbered_tasks_issue_3481
191+
192+ See https://github.com/obsidian-tasks-group/obsidian-tasks/issues/3481.
193+
194+ - [ ] 1. #task Task 1 in 'numbered_tasks_issue_3481'
195+ - [ ] 2 #task Task 2 in 'numbered_tasks_issue_3481'
196+ - [ ] 3) #task Task 3 in 'numbered_tasks_issue_3481'
197+ - [ ] 4 - #task Task 4 in 'numbered_tasks_issue_3481'
198+ - [ ] 5: #task Task 5 in 'numbered_tasks_issue_3481'
199+ - [ ] (6) #task Task 6 in 'numbered_tasks_issue_3481'
200+
201+ The file [[numbered_tasks_issue_3481_searches]] shows how Obsidian and some plugins parse the above data.
202+ "
203+ ` ) ;
204+
205+ // This shows the current behaviour of the Tasks code for processing Obsidian listItems.
206+ // The two nested ListItem lines are not expected.
207+ // But reviewing the listItems values in numbered_tasks_issue_3481.json, it is plausible
208+ // to see why Tasks might have created them.
209+ expect ( printRoots ( tasks ) ) . toMatchInlineSnapshot ( `
210+ "- [ ] 1. #task Task 1 in 'numbered_tasks_issue_3481' : Task
211+ - [ ] 1. #task Task 1 in 'numbered_tasks_issue_3481' : ListItem
212+ - [ ] 2 #task Task 2 in 'numbered_tasks_issue_3481' : Task
213+ - [ ] 3) #task Task 3 in 'numbered_tasks_issue_3481' : Task
214+ - [ ] 3) #task Task 3 in 'numbered_tasks_issue_3481' : ListItem
215+ - [ ] 4 - #task Task 4 in 'numbered_tasks_issue_3481' : Task
216+ - [ ] 5: #task Task 5 in 'numbered_tasks_issue_3481' : Task
217+ - [ ] (6) #task Task 6 in 'numbered_tasks_issue_3481' : Task
218+ "
219+ ` ) ;
220+ expect ( tasks . length ) . toEqual ( 6 ) ;
221+ } ) ;
222+
180223 it ( 'should read one parent and one child task' , ( ) => {
181224 const tasks = readTasksFromSimulatedFile ( inheritance_1parent1child ) ;
182225 expect ( inheritance_1parent1child . fileContents ) . toMatchInlineSnapshot ( `
@@ -852,6 +895,7 @@ describe('all mock files', () => {
852895 const files_without_tasks = [
853896 'Test Data/docs_sample_for_explain_query_file_defaults.md' ,
854897 'Test Data/non_tasks.md' ,
898+ 'Test Data/numbered_tasks_issue_3481_searches.md' ,
855899 ] ;
856900 if ( files_without_tasks . includes ( path ) ) {
857901 expect ( tasks . length ) . toEqual ( 0 ) ;
0 commit comments