diff --git a/manifest.json b/manifest.json index 538258d..b7bb180 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "progress-tracker-label", "name": "Progress Tracker", - "version": "1.6.6", + "version": "1.7.0", "minAppVersion": "0.15.0", "description": "Obsidian plugin that displays progress statistics inline by calculating the ratio of completed to incomplete tasks within task trees. It includes tasks from both the current note and any linked notes, offering insights like Complete 10% (10/100). Designed to integrate seamlessly via markdown post-processing, it avoids automatic parent task completion for full user control.", "author": "BalaSoft", diff --git a/package.json b/package.json index 1b9068b..dd1fb1b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "progress-tracker-label", - "version": "1.6.6", + "version": "1.7.0", "description": "Progress Tracker plugin for Obsidian (https://obsidian.md)", "main": "main.js", "scripts": { diff --git a/tests/fixtures/non-task-with-tasks-1.md b/tests/fixtures/non-task-with-tasks-1.md new file mode 100644 index 0000000..7d730ac --- /dev/null +++ b/tests/fixtures/non-task-with-tasks-1.md @@ -0,0 +1,6 @@ +- [ ] task A +- [ ] task B + - [ ] subtask B A +- Point Item + - [ ] task C + - [ ] task D diff --git a/tests/fixtures/non-task-with-tasks-2.md b/tests/fixtures/non-task-with-tasks-2.md new file mode 100644 index 0000000..e9316f9 --- /dev/null +++ b/tests/fixtures/non-task-with-tasks-2.md @@ -0,0 +1,6 @@ +- [ ] task A +- [ ] task B + - [ ] subtask B A +- [ ] Point Item + - [ ] task C + - [ ] task D diff --git a/tests/fixtures/non-task-with-tasks-3.md b/tests/fixtures/non-task-with-tasks-3.md new file mode 100644 index 0000000..2c08920 --- /dev/null +++ b/tests/fixtures/non-task-with-tasks-3.md @@ -0,0 +1,7 @@ +- [ ] task A +- [ ] task B + - [ ] subtask B A +- Point Item + - Sub Point + - [ ] task C + - [ ] task D diff --git a/tests/task-tree-builder.test.ts b/tests/task-tree-builder.test.ts index 9b3f5ab..adbfe51 100644 --- a/tests/task-tree-builder.test.ts +++ b/tests/task-tree-builder.test.ts @@ -179,4 +179,55 @@ describe('TaskTreeBuilder', () => { expect(task1.completed).toBe(false); }); + describe('non-task items in task tree', () => { + test('non-task list item with tasks beneath it counts all tasks as root tasks', () => { + // Test case 1: Non-task "Point Item" should not be counted as a task + // - [ ] task A + // - [ ] task B + // - [ ] subtask B A + // - Point Item + // - [ ] task C + // - [ ] task D + // Expected: Only leaf tasks are counted: task A (leaf=1), subtask B A (leaf=1), task C (leaf=1), task D (leaf=1) = 0/4 + const file = __dirname + '/fixtures/non-task-with-tasks-1.md'; + const tree = builder.buildFromFile(file); + expect(tree.getCounts()).toEqual({ total: 4, completed: 0 }); + expect(tree.getCompletionString()).toBe('Complete 0% (0/4)'); + }); + + test('checkbox on "Point Item" makes it a task with children', () => { + // Test case 2: "- [ ] Point Item" is a task with task C and D as children + // - [ ] task A + // - [ ] task B + // - [ ] subtask B A + // - [ ] Point Item + // - [ ] task C + // - [ ] task D + // The current implementation counts only leaf tasks: task A (1), subtask B A (1), task C (1), task D (1). + // Point Item as a parent task doesn't count itself, only its leaf children are counted. + // Total = 0/4 (Note: The issue description suggested 0/3, but the current implementation + // consistently counts only leaf tasks regardless of parent type.) + const file = __dirname + '/fixtures/non-task-with-tasks-2.md'; + const tree = builder.buildFromFile(file); + expect(tree.getCounts()).toEqual({ total: 4, completed: 0 }); + expect(tree.getCompletionString()).toBe('Complete 0% (0/4)'); + }); + + test('nested non-task items with tasks beneath count all leaf tasks', () => { + // Test case 3: Non-task "Point Item" with nested non-task "Sub Point" + // - [ ] task A + // - [ ] task B + // - [ ] subtask B A + // - Point Item + // - Sub Point + // - [ ] task C + // - [ ] task D + // Expected: Only leaf tasks are counted: task A (leaf=1), subtask B A (leaf=1), task C (leaf=1), task D (leaf=1) = 0/4 + const file = __dirname + '/fixtures/non-task-with-tasks-3.md'; + const tree = builder.buildFromFile(file); + expect(tree.getCounts()).toEqual({ total: 4, completed: 0 }); + expect(tree.getCompletionString()).toBe('Complete 0% (0/4)'); + }); + }); + });