Skip to content

Commit 264c10c

Browse files
authored
Merge pull request #3516 from obsidian-tasks-group/tests-for-issue-3481
vault, tests: Visualise Obsidian, dataview & Tasks behaviour with #3481
2 parents 654ea45 + de918f6 commit 264c10c

File tree

6 files changed

+735
-0
lines changed

6 files changed

+735
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# numbered_tasks_issue_3481
2+
3+
See https://github.com/obsidian-tasks-group/obsidian-tasks/issues/3481.
4+
5+
- [ ] 1. #task Task 1 in 'numbered_tasks_issue_3481'
6+
- [ ] 2 #task Task 2 in 'numbered_tasks_issue_3481'
7+
- [ ] 3) #task Task 3 in 'numbered_tasks_issue_3481'
8+
- [ ] 4 - #task Task 4 in 'numbered_tasks_issue_3481'
9+
- [ ] 5: #task Task 5 in 'numbered_tasks_issue_3481'
10+
- [ ] (6) #task Task 6 in 'numbered_tasks_issue_3481'
11+
12+
The file [[numbered_tasks_issue_3481_searches]] shows how Obsidian and some plugins parse the above data.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# numbered_tasks_issue_3481_searches
2+
3+
## Tasks
4+
5+
The Tasks plugin finds ==6 tasks==, but with 2 nested list items.
6+
7+
### show tree
8+
9+
```tasks
10+
path includes numbered_tasks_issue_3481
11+
show tree
12+
full mode
13+
```
14+
15+
### hide tree
16+
17+
```tasks
18+
path includes numbered_tasks_issue_3481
19+
hide tree
20+
full mode
21+
```
22+
23+
## Dataview
24+
25+
Dataview finds ==4 tasks==:
26+
27+
```dataview
28+
TASK
29+
FROM "Test Data/numbered_tasks_issue_3481"
30+
```
31+
32+
## Obsidian search
33+
34+
Obsidian finds ==6 tasks==:
35+
36+
```query
37+
task:3481
38+
```

tests/Obsidian/AllCacheSampleData.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ import no_yaml from './__test_data__/no_yaml.json';
5757
import non_tasks from './__test_data__/non_tasks.json';
5858
import numbered_list_items_standard from './__test_data__/numbered_list_items_standard.json';
5959
import numbered_list_items_with_paren from './__test_data__/numbered_list_items_with_paren.json';
60+
import numbered_tasks_issue_3481 from './__test_data__/numbered_tasks_issue_3481.json';
61+
import numbered_tasks_issue_3481_searches from './__test_data__/numbered_tasks_issue_3481_searches.json';
6062
import one_task from './__test_data__/one_task.json';
6163
import query_file_defaults_all_options_false from './__test_data__/query_file_defaults_all_options_false.json';
6264
import query_file_defaults_all_options_null from './__test_data__/query_file_defaults_all_options_null.json';
@@ -150,6 +152,8 @@ export function allCacheSampleData(): SimulatedFile[] {
150152
non_tasks,
151153
numbered_list_items_standard,
152154
numbered_list_items_with_paren,
155+
numbered_tasks_issue_3481,
156+
numbered_tasks_issue_3481_searches,
153157
one_task,
154158
query_file_defaults_all_options_false,
155159
query_file_defaults_all_options_null,

tests/Obsidian/Cache.test.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import inheritance_task_listitem_task from './__test_data__/inheritance_task_lis
2828
import inheritance_task_mixed_children from './__test_data__/inheritance_task_mixed_children.json';
2929
import numbered_list_items_with_paren from './__test_data__/numbered_list_items_with_paren.json';
3030
import 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';
3132
import one_task from './__test_data__/one_task.json';
3233
import callouts_nested_issue_2890_labelled from './__test_data__/callouts_nested_issue_2890_labelled.json';
3334
import 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

Comments
 (0)