diff --git a/manifest.json b/manifest.json index 396bd8a..538258d 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "progress-tracker-label", "name": "Progress Tracker", - "version": "1.6.5", + "version": "1.6.6", "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-lock.json b/package-lock.json index 8d6420e..0f70921 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "progress-tracker-label", - "version": "1.6.3", + "version": "1.6.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "progress-tracker-label", - "version": "1.6.3", + "version": "1.6.6", "license": "MIT", "dependencies": { "@codemirror/state": "^6.5.2", diff --git a/package.json b/package.json index 4dd5870..1b9068b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "progress-tracker-label", - "version": "1.6.5", + "version": "1.6.6", "description": "Progress Tracker plugin for Obsidian (https://obsidian.md)", "main": "main.js", "scripts": { diff --git a/tests/bug-linked-parent-with-children.test.ts b/tests/bug-linked-parent-with-children.test.ts new file mode 100644 index 0000000..6bb4656 --- /dev/null +++ b/tests/bug-linked-parent-with-children.test.ts @@ -0,0 +1,58 @@ +import * as fs from 'fs'; +import * as path from 'path'; +import { updateParentStatuses } from '../src/auto-parent'; + +describe('Parent task with link and child tasks', () => { + const root = path.join(__dirname, 'fixtures'); + + test('parent with link to incomplete page and all children complete should remain unchecked', () => { + // Scenario: parent task links to pageB (which has incomplete tasks) + // and has two child tasks that are both complete. + // Expected: parent should remain unchecked because linked page has incomplete tasks + const filePath = path.join(root, 'pageA.md'); + + const content = `- [ ] [[pageB]] + - [x] child A + - [x] child B`; + + const result = updateParentStatuses(content, undefined, filePath, root, 'ignoretasktree', true); + + // Parent should remain unchecked despite all children being complete + // because pageB has incomplete tasks + expect(result.content.split(/\r?\n/)[0]).toBe('- [ ] [[pageB]]'); + expect(result.content).toBe(content); // No changes should be made + }); + + test('parent with link to complete page and all children complete should be checked', () => { + // Scenario: parent task links to a page with all tasks complete + // and has two child tasks that are both complete. + // Expected: parent should be checked + const filePath = path.join(root, 'pageA-complete.md'); + + const content = `- [ ] [[subpage-complete]] + - [x] child A + - [x] child B`; + + const result = updateParentStatuses(content, undefined, filePath, root, 'ignoretasktree', true); + + // Parent should be checked because both children and linked page are complete + expect(result.content.split(/\r?\n/)[0]).toBe('- [x] [[subpage-complete]]'); + }); + + test('parent with link and incomplete children should remain unchecked', () => { + // Scenario: parent task has a link (doesn't matter if page is complete) + // but has at least one incomplete child + // Expected: parent should remain unchecked + const filePath = path.join(root, 'pageA.md'); + + const content = `- [ ] [[subpage-complete]] + - [x] child A + - [ ] child B`; + + const result = updateParentStatuses(content, undefined, filePath, root, 'ignoretasktree', true); + + // Parent should remain unchecked because child B is incomplete + expect(result.content.split(/\r?\n/)[0]).toBe('- [ ] [[subpage-complete]]'); + expect(result.content).toBe(content); // No changes should be made + }); +}); diff --git a/tests/fixtures/pageA-complete.md b/tests/fixtures/pageA-complete.md new file mode 100644 index 0000000..124594e --- /dev/null +++ b/tests/fixtures/pageA-complete.md @@ -0,0 +1,3 @@ +- [ ] [[subpage-complete]] + - [x] child A + - [x] child B diff --git a/tests/fixtures/pageA.md b/tests/fixtures/pageA.md new file mode 100644 index 0000000..8ff5902 --- /dev/null +++ b/tests/fixtures/pageA.md @@ -0,0 +1,3 @@ +- [ ] [[pageB]] + - [x] child A + - [ ] child B diff --git a/tests/fixtures/pageB.md b/tests/fixtures/pageB.md new file mode 100644 index 0000000..370d525 --- /dev/null +++ b/tests/fixtures/pageB.md @@ -0,0 +1 @@ +- [ ] task diff --git a/versions.json b/versions.json index 26382a1..1dc2bdc 100644 --- a/versions.json +++ b/versions.json @@ -1,3 +1,4 @@ { - "1.0.0": "0.15.0" + "1.0.0": "0.15.0", + "1.6.6": "0.15.0" }