-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Verify creation of pages and movement to pages #635
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,19 @@ | |
* test/hypb-tests.el (hypb--verify-info-index-is-correct): Ensure info | ||
index is correct. | ||
|
||
2024-12-29 Mats Lidell <[email protected]> | ||
|
||
* test/hywiki-tests.el | ||
(hywiki-tests--action-key-on-hy-wikiword-displays-page): Rename so | ||
hy:WikiWord is mentioned. Fix removal of temp files. | ||
(hywiki-tests--assist-key-on-hy-wikiword-displays-help): Rename so | ||
hy:WikiWord is mentioned and refactor to verify help buffer is shown. | ||
(hywiki-tests--action-key-on-wikiword-displays-page) | ||
(hywiki-tests--action-key-on-wikiword-and-section-displays-page): New | ||
tests for verifying display of pages with and without sections. | ||
(hywiki-tests--wikiword-identified-with-delimiters): Add test for | ||
WikiWord with a single hash mark. | ||
|
||
2024-12-28 Bob Weiner <[email protected]> | ||
|
||
* hywiki.el (hywiki-convert-words-to-org-links): Error if called within a | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
;; Author: Mats Lidell | ||
;; | ||
;; Orig-Date: 18-May-24 at 23:59:48 | ||
;; Last-Mod: 28-Dec-24 at 16:58:48 by Mats Lidell | ||
;; Last-Mod: 28-Dec-24 at 22:14:33 by Mats Lidell | ||
;; | ||
;; SPDX-License-Identifier: GPL-3.0-or-later | ||
;; | ||
|
@@ -53,7 +53,7 @@ | |
(should-not (cdr (hywiki-add-page "notawikiword"))) | ||
(hy-delete-dir-and-buffer hywiki-directory)))) | ||
|
||
(ert-deftest hywiki-tests--action-key-on-wikiword-displays-page () | ||
(ert-deftest hywiki-tests--action-key-on-hy-wikiword-displays-page () | ||
"Verify `action-key' on a prefixed WikiWord, outside of hywiki-directory, creates a new page." | ||
(let ((hsys-org-enable-smart-keys t) | ||
(hywiki-directory (make-temp-file "hywiki" t)) | ||
|
@@ -65,21 +65,72 @@ | |
(goto-char 4) | ||
(action-key) | ||
(should (equal (cons 'page wikifile) (hywiki-get-referent "WikiWord")))) | ||
(hy-delete-file-and-buffer wikifile)))) | ||
(hy-delete-file-and-buffer (expand-file-name wikifile hywiki-directory)) | ||
(hy-delete-dir-and-buffer hywiki-directory)))) | ||
|
||
(ert-deftest hywiki-tests--assist-key-on-wikiword-displays-help () | ||
(ert-deftest hywiki-tests--assist-key-on-hy-wikiword-displays-help () | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as prior comment. |
||
"Verify `assist-key' on a prefixed WikiWord, outside of hywiki-directory, displays help for the WikiWord link." | ||
(let ((hsys-org-enable-smart-keys t) | ||
(hywiki-directory (make-temp-file "hywiki" t)) | ||
(wikifile (make-temp-file "wikifile" nil ".org"))) | ||
(hywiki-directory (make-temp-file "hywiki" t))) | ||
(unwind-protect | ||
(with-temp-buffer | ||
(hywiki-mode 1) | ||
(insert "[[hy:WikiWord]]") | ||
(goto-char 4) | ||
(goto-char 6) | ||
(should (string= "WikiWord" (hywiki-word-at))) | ||
(assist-key)) | ||
(hy-delete-file-and-buffer wikifile)))) | ||
(delete-other-windows) | ||
(assist-key) | ||
(other-window 1) | ||
(should (string-prefix-p "*Help: Hyperbole " (buffer-name)))) | ||
(hy-delete-dir-and-buffer hywiki-directory)))) | ||
|
||
(ert-deftest hywiki-tests--action-key-on-wikiword-displays-page () | ||
"Verify `action-key' on a WikiWord, outside of hywiki-directory, creates a new page." | ||
(let* ((hsys-org-enable-smart-keys t) | ||
(hywiki-directory (make-temp-file "hywiki" t)) | ||
(hywiki-page-file (expand-file-name "WikiWord.org" hywiki-directory))) | ||
(unwind-protect | ||
(dolist (v '(nil t)) ;; Verify the file exists the second time | ||
(if v | ||
(should (file-exists-p hywiki-page-file)) | ||
(should-not (file-exists-p hywiki-page-file))) | ||
(with-temp-buffer | ||
(hywiki-mode 1) | ||
(insert "WikiWord\n") | ||
(goto-char 4) | ||
(action-key) | ||
(should (string= hywiki-page-file (buffer-file-name))) | ||
(should (equal (cons 'page (file-name-nondirectory hywiki-page-file)) | ||
(hywiki-get-referent "WikiWord"))) | ||
(if v | ||
(should (looking-at-p "WikiWord page")) | ||
(insert "WikiWord page") | ||
(goto-char (point-min))))) | ||
(hy-delete-file-and-buffer hywiki-page-file) | ||
(hy-delete-dir-and-buffer hywiki-directory)))) | ||
|
||
(ert-deftest hywiki-tests--action-key-on-wikiword-and-section-displays-page () | ||
"Verify `action-key' on a WikiWord with section moves to the section." | ||
(let* ((hsys-org-enable-smart-keys t) | ||
(hywiki-directory (make-temp-file "hywiki" t)) | ||
(hywiki-page-file (expand-file-name "WikiWord.org" hywiki-directory)) | ||
(sections '("* Header" "** SubHeader" "*** SubSubHeader"))) | ||
matsl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
(unwind-protect | ||
(progn | ||
(find-file hywiki-page-file) | ||
(dolist (v sections) | ||
(insert (format "%s\nbody\n" v))) | ||
(save-buffer) | ||
(hywiki-mode 1) | ||
(dolist (v sections) | ||
(with-temp-buffer | ||
(insert "WikiWord#" (cadr (split-string v " "))) | ||
(goto-char 4) | ||
(action-key) | ||
(should (string= hywiki-page-file (buffer-file-name))) | ||
(should (looking-at-p (regexp-quote v)))))) | ||
(hy-delete-file-and-buffer hywiki-page-file) | ||
(hy-delete-dir-and-buffer hywiki-directory)))) | ||
|
||
(ert-deftest hywiki-tests--not-a-wikiword-unless-in-hywiki-mode () | ||
"Verify WikiWord is not a WikiWord unless in `hywiki-mode'." | ||
|
@@ -132,6 +183,15 @@ | |
(goto-char 6) | ||
(should (string= "WikiWord" (hywiki-word-at))))) | ||
|
||
;; Does not match as a WikiWord | ||
(dolist (v '("WikiWord#")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. An Action Key press on a WikiWord with just a trailing # should probably either go to the first Org doc section or trigger an error. What do you prefer? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think it currently raises an error. (Hyperbole Action Key): No action defined for this context; try another location That is OK. Maybe just handle it as WikiWord would cause less questions from a user but will think about it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thinking more on this I think Currently we just move to the WikiWord-page if the section does not exists, There is an error message that the section can't be found. With an empty section we should do something similar. We could even strip of the hash mark and treat it as a normal WikiWord. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think a wikiword that links to a page will display an existing buffer page with point wherever it was before the button was activated. We need a way to say, display the beginning or first section of the page, so this is as good a way as any. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I changed my thought on this. With my next update, you'll be able to add :L1 at the end of a HyWikiWord referent to go to the first line of a wiki page, so if a # is given without a section name, it the HyWikiWord reference will just be ignored for now. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK. I will updated these tests when that change goes in. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That update has been made, so you can finish this PR. |
||
(with-temp-buffer | ||
(org-mode) | ||
(insert v) | ||
(newline nil t) | ||
(goto-char 6) | ||
(should-not (string= "WikiWord" (hywiki-word-at))))) | ||
|
||
;; Identifies as org link (Note: Not checked if target | ||
;; exists.) AND matches WikiWord | ||
(dolist (v '("[[hy:WikiWord]]" "[[hy:WikiWord\\]]]")) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for a dash, just use 'hywikiword' instead of 'hy-wikiword'.