Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
6 changes: 6 additions & 0 deletions tests/fixtures/non-task-with-tasks-1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- [ ] task A
- [ ] task B
- [ ] subtask B A
- Point Item
- [ ] task C
- [ ] task D
6 changes: 6 additions & 0 deletions tests/fixtures/non-task-with-tasks-2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- [ ] task A
- [ ] task B
- [ ] subtask B A
- [ ] Point Item
- [ ] task C
- [ ] task D
7 changes: 7 additions & 0 deletions tests/fixtures/non-task-with-tasks-3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- [ ] task A
- [ ] task B
- [ ] subtask B A
- Point Item
- Sub Point
- [ ] task C
- [ ] task D
51 changes: 51 additions & 0 deletions tests/task-tree-builder.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)');
});
});

});
Loading