branch: externals/org-gnosis
commit c214c41cde9e907c78a1ffb8530515ebe21eb7ac
Author: Thanos Apollo <[email protected]>
Commit: Thanos Apollo <[email protected]>

    tests: Update for new title parsing.
    
    * New title parsing stacks parent headings for node title.
---
 tests/org-gnosis-test-parsing.el | 121 ++++++++++++++++++++-------------------
 1 file changed, 61 insertions(+), 60 deletions(-)

diff --git a/tests/org-gnosis-test-parsing.el b/tests/org-gnosis-test-parsing.el
index 580e9d3c2b..97f129d82f 100644
--- a/tests/org-gnosis-test-parsing.el
+++ b/tests/org-gnosis-test-parsing.el
@@ -20,7 +20,7 @@
 (require 'org-element)
 
 ;; Load the main org-gnosis.el file
-(let ((gnosis-file (expand-file-name "../org-gnosis.el" 
+(let ((gnosis-file (expand-file-name "../org-gnosis.el"
                                      (file-name-directory (or load-file-name 
buffer-file-name)))))
   (if (file-exists-p gnosis-file)
       (load gnosis-file)
@@ -39,7 +39,7 @@
   (let ((test-content ":PROPERTIES:
 :ID: file-id-123
 :END:
-#+title: Test File
+#+title: Test
 #+filetags: :project:important:
 
 * First Heading :heading:
@@ -60,31 +60,31 @@ More content with another [[id:another-link][Link]]."))
       (let ((data (org-gnosis-buffer-data)))
         ;; Should have topic + 2 headlines = 3 items
         (should (= (length data) 3))
-        
+
         ;; Find topic by ID
         (let ((topic (cl-find-if (lambda (item) (equal (plist-get item :id) 
"file-id-123")) data)))
           (should topic)
-          (should (equal (plist-get topic :title) "Test File"))
+          (should (equal (plist-get topic :title) "Test"))
           (should (equal (plist-get topic :level) 0))
           (should (member "project" (plist-get topic :tags)))
           (should (member "important" (plist-get topic :tags))))
-        
+
         ;; Find first heading by ID
         (let ((heading (cl-find-if (lambda (item) (equal (plist-get item :id) 
"heading-id-456")) data)))
           (should heading)
-          (should (equal (plist-get heading :title) "First Heading"))
+          (should (equal (plist-get heading :title) "Test:First Heading"))
           (should (equal (plist-get heading :level) 1))
           (should (equal (plist-get heading :master) "file-id-123"))
           (should (member "heading" (plist-get heading :tags))))
-        
+
         ;; Find sub heading by ID
         (let ((sub-heading (cl-find-if (lambda (item) (equal (plist-get item 
:id) "sub-id-789")) data)))
           (should sub-heading)
-          (should (equal (plist-get sub-heading :title) "Sub Heading"))
+          (should (equal (plist-get sub-heading :title) "Test:First 
Heading:Sub Heading"))
           (should (equal (plist-get sub-heading :level) 2))
           (should (equal (plist-get sub-heading :master) "heading-id-456"))
           (should (member "sub" (plist-get sub-heading :tags))))
-        
+
         ;; Test link extraction
         (let ((links (org-gnosis-collect-id-links)))
           (should (>= (length links) 2)))))))
@@ -111,22 +111,22 @@ More content with another [[id:another-link][Link]]."))
 :PROPERTIES:
 :ID: level3-id
 :END:"))
-    
+
     (org-gnosis-test-with-temp-buffer test-content
       (let ((data (org-gnosis-buffer-data)))
         ;; Should have topic + 3 headlines = 4 items
         (should (= (length data) 4))
-        
+
         ;; Check topic has global tag
         (let ((topic (cl-find-if (lambda (item) (equal (plist-get item :id) 
"file-id")) data)))
           (should topic)
           (should (equal (plist-get topic :title) "Tag Test"))
           (should (member "global" (plist-get topic :tags))))
-        
+
         ;; Check level 1 hierarchy
         (let ((level1 (cl-find-if (lambda (item) (equal (plist-get item :id) 
"level1-id")) data)))
           (should level1)
-          (should (equal (plist-get level1 :title) "Level 1"))
+          (should (equal (plist-get level1 :title) "Tag Test:Level 1"))
           (should (equal (plist-get level1 :level) 1))
           (should (equal (plist-get level1 :master) "file-id"))
           (should (member "level1" (plist-get level1 :tags)))
@@ -154,17 +154,17 @@ Regular [[id:target1][Link One]] and [[id:target2][Link 
Two]].
 :END:
 
 Links in [[id:target3][different]] formats and [[id:target4][contexts]]."))
-    
+
     (org-gnosis-test-with-temp-buffer test-content
       (let ((data (org-gnosis-buffer-data)))
         ;; Should have topic + 2 headlines = 3 items
         (should (= (length data) 3))
-        
+
         ;; Check topic
         (let ((topic (cl-find-if (lambda (item) (equal (plist-get item :id) 
"main-id")) data)))
           (should topic)
           (should (equal (plist-get topic :title) "Link Test")))
-        
+
         ;; Test link collection
         (let ((links (org-gnosis-collect-id-links)))
           (should (>= (length links) 4))
@@ -205,39 +205,40 @@ Links in [[id:target3][different]] formats and 
[[id:target4][contexts]]."))
 :PROPERTIES:
 :ID: another-level2-id
 :END:"))
-    
+
     (org-gnosis-test-with-temp-buffer test-content
       (let ((data (org-gnosis-buffer-data)))
         ;; Should have topic + 5 headlines = 6 items
         (should (= (length data) 6))
-        
+
         ;; Check topic
         (let ((topic (cl-find-if (lambda (item) (equal (plist-get item :id) 
"topic-id-123")) data)))
           (should topic)
           (should (equal (plist-get topic :title) "Parent Topic"))
           (should (equal (plist-get topic :master) 0))
           (should (equal (plist-get topic :level) 0)))
-        
+
         ;; Check level 1 master relationship
         (let ((level1 (cl-find-if (lambda (item) (equal (plist-get item :id) 
"level1-id-456")) data)))
           (should level1)
-          (should (equal (plist-get level1 :title) "Level 1 Heading"))
+          (should (equal (plist-get level1 :title) "Parent Topic:Level 1 
Heading"))
           (should (equal (plist-get level1 :master) "topic-id-123"))
           (should (equal (plist-get level1 :level) 1)))
-        
+
         ;; Check level 2 master relationship
         (let ((level2 (cl-find-if (lambda (item) (equal (plist-get item :id) 
"level2-id-789")) data)))
           (should level2)
-          (should (equal (plist-get level2 :title) "Level 2 Heading"))
+          (should (equal (plist-get level2 :title) "Parent Topic:Level 1 
Heading:Level 2 Heading"))
           (should (equal (plist-get level2 :master) "level1-id-456"))
           (should (equal (plist-get level2 :level) 2)))
-        
+
         ;; Check level 3 master relationship
         ;; Note: Current implementation links level 3 to level 1 
(grandparent), not level 2 (parent)
         ;; This appears to be intended behavior based on the 
org-gnosis--find-master-id logic
         (let ((level3 (cl-find-if (lambda (item) (equal (plist-get item :id) 
"level3-id-abc")) data)))
           (should level3)
-          (should (equal (plist-get level3 :title) "Level 3 Heading"))
+          (should (equal (plist-get level3 :title)
+                        "Parent Topic:Level 1 Heading:Level 2 Heading:Level 3 
Heading"))
           (should (equal (plist-get level3 :master) "level1-id-456")) ; Links 
to grandparent, not direct parent
           (should (equal (plist-get level3 :level) 3)))))))
 
@@ -277,31 +278,31 @@ Content here.
 :ID: deep-id-abc
 :END:
 This should link to section-id-789, skipping the parent without ID."))
-    
+
     (org-gnosis-test-with-temp-buffer test-content
       (let ((data (org-gnosis-buffer-data)))
         ;; Should have topic + 4 headlines with IDs = 5 total
         (should (= (length data) 5))
-        
+
         ;; Check subsection links to topic (skipping parent without ID)
-        (let ((subsection (cl-find-if 
-                          (lambda (item) 
+        (let ((subsection (cl-find-if
+                          (lambda (item)
                             (equal (plist-get item :id) "subsection-id-123"))
                           data)))
           (should subsection)
           (should (equal (plist-get subsection :master) "topic-id-xyz")))
-        
+
         ;; Check sub-subsection links to subsection
-        (let ((subsubsection (cl-find-if 
-                             (lambda (item) 
+        (let ((subsubsection (cl-find-if
+                             (lambda (item)
                                (equal (plist-get item :id) 
"subsubsection-id-456"))
                              data)))
           (should subsubsection)
           (should (equal (plist-get subsubsection :master) 
"subsection-id-123")))
-        
+
         ;; Check deep item links to section (skipping parent without ID)
-        (let ((deep-item (cl-find-if 
-                         (lambda (item) 
+        (let ((deep-item (cl-find-if
+                         (lambda (item)
                            (equal (plist-get item :id) "deep-id-abc"))
                          data)))
           (should deep-item)
@@ -309,13 +310,13 @@ This should link to section-id-789, skipping the parent 
without ID."))
 
 (ert-deftest org-gnosis-test-edge-cases ()
   "Test various edge cases that could break parsing."
-  
+
   ;; Test empty title error
-  (should-error 
-   (org-gnosis-test-with-temp-buffer 
+  (should-error
+   (org-gnosis-test-with-temp-buffer
     ":PROPERTIES:\n:ID: test-id\n:END:\n#+title: \n\n* 
Test\n:PROPERTIES:\n:ID: test-headline\n:END:\n"
     (org-gnosis-buffer-data)))
-  
+
   ;; Test missing topic ID (should not error, but create fake topic)
   (let ((result (org-gnosis-test-with-temp-buffer
                  "#+title: Test Without ID\n\n* Test\n:PROPERTIES:\n:ID: 
test-headline\n:END:\n"
@@ -325,30 +326,30 @@ This should link to section-id-789, skipping the parent 
without ID."))
     (let ((topic (cl-find-if (lambda (item) (= (plist-get item :level) 0)) 
result)))
       (should topic)
       (should (equal (plist-get topic :title) "Test Without ID"))))
-  
+
   ;; Test headline without ID (should be skipped)
   (let ((test-content ":PROPERTIES:\n:ID: topic-id\n:END:\n#+title: Valid 
Topic\n\n* Headline Without ID\nContent here.\n\n* Headline With 
ID\n:PROPERTIES:\n:ID: valid-headline-id\n:END:\nMore content."))
     (org-gnosis-test-with-temp-buffer test-content
       (let ((data (org-gnosis-buffer-data)))
         ;; Should only have topic + 1 headline = 2 items
         (should (= (length data) 2)))))
-  
+
   ;; Test deeply nested hierarchy (performance test)
   (let ((deep-content ":PROPERTIES:\n:ID: deep-topic\n:END:\n#+title: Deep 
Hierarchy\n"))
     (dotimes (i 10)  ; Create 10 levels deep
-      (setq deep-content 
-            (concat deep-content 
+      (setq deep-content
+            (concat deep-content
                     (make-string (1+ i) ?*) " Level " (number-to-string (1+ 
i)) "\n"
                     ":PROPERTIES:\n:ID: level-" (number-to-string (1+ i)) 
"-id\n:END:\n\n")))
-    
+
     (org-gnosis-test-with-temp-buffer deep-content
       (let ((data (org-gnosis-buffer-data)))
         ;; Should have topic + 10 headlines = 11 items
         (should (= (length data) 11))
-        
+
         ;; Check that deepest level exists and has correct hierarchy behavior
         ;; Note: Based on org-gnosis hierarchy logic, level 10 links to level 
1, not level 9
-        (let ((deepest (cl-find-if (lambda (item) 
+        (let ((deepest (cl-find-if (lambda (item)
                                     (equal (plist-get item :id) "level-10-id"))
                                   data)))
           (should deepest)
@@ -361,7 +362,7 @@ This should link to section-id-789, skipping the parent 
without ID."))
 :ID: topic-mixed-123
 :END:
 #+title: Mixed Headlines
-#+filetags: 
+#+filetags:
 
 * Section Without ID
 Some content here.
@@ -379,28 +380,28 @@ This has an ID and should be parsed.
 *** DONE Another Task Without ID
 More content without ID.
 
-*** Sub-subsection With ID  
+*** Sub-subsection With ID
 :PROPERTIES:
 :ID: deep-with-id-789
 :END:
 This should link to subsection-with-id-456."))
-    
+
     (org-gnosis-test-with-temp-buffer test-content
       (let ((data (org-gnosis-buffer-data)))
         ;; Should have: topic + 2 headlines with IDs = 3 total
         (should (= (length data) 3))
-        
+
         ;; Check subsection links to topic (skipping parent without ID)
-        (let ((subsection (cl-find-if 
-                          (lambda (item) 
+        (let ((subsection (cl-find-if
+                          (lambda (item)
                             (equal (plist-get item :id) 
"subsection-with-id-456"))
                           data)))
           (should subsection)
           (should (equal (plist-get subsection :master) "topic-mixed-123")))
-        
+
         ;; Check deep item links to subsection (skipping intermediate parent 
without ID)
-        (let ((deep-item (cl-find-if 
-                         (lambda (item) 
+        (let ((deep-item (cl-find-if
+                         (lambda (item)
                            (equal (plist-get item :id) "deep-with-id-789"))
                          data)))
           (should deep-item)
@@ -412,9 +413,9 @@ This should link to subsection-with-id-456."))
 :ID:       9a2f2518-66a4-436f-b824-5bf0ac959055
 :END:
 #+title: 2025-03-02
-#+filetags: 
+#+filetags:
 
-Ἡμέραι ἓως ἔτους 2050: *9071* 
+Ἡμέραι ἓως ἔτους 2050: *9071*
 
 * Καταγραφή
 * Ὑπομνήματα Ἡμέρας
@@ -427,12 +428,12 @@ This should link to subsection-with-id-456."))
 + [X] Ἐνδυνάμωση· Πλάτη & Δικέφαλα
 ** DONE Γνῶσις
 + [X] Ὁλοκλήρωση τῶν ἐπαναλήψεων γνῶσις"))
-    
+
     (org-gnosis-test-with-temp-buffer test-content
       (let ((data (org-gnosis-buffer-data)))
         ;; Should have: topic only (no headlines have IDs) = 1 item
         (should (= (length data) 1))
-        
+
         ;; Check topic was parsed correctly
         (let ((topic (car data)))
           (should (equal (plist-get topic :title) "2025-03-02"))
@@ -446,9 +447,9 @@ This should link to subsection-with-id-456."))
   (ert-run-tests-batch "org-gnosis-test-"))
 
 ;; Run tests if called directly
-(when (and (boundp 'argv) 
+(when (and (boundp 'argv)
            (member "--run-tests" argv))
   (ert-run-tests-batch "org-gnosis-test-"))
 
 (provide 'org-gnosis-test-parsing)
-;;; org-gnosis-test-parsing.el ends here
\ No newline at end of file
+;;; org-gnosis-test-parsing.el ends here

Reply via email to