aboutsummaryrefslogtreecommitdiff
path: root/tests/test-gloss--add-finish-internal.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-04-30 07:27:44 -0500
committerCraig Jennings <c@cjennings.net>2026-04-30 07:27:44 -0500
commit9e90517a98785c450cd13cd940bd1787a4771529 (patch)
tree5c20f077bd3dcc28661711c3fdcad5ab90a5a3fa /tests/test-gloss--add-finish-internal.el
parent5c7bb207081278e41122e62d8f6c282a18574665 (diff)
downloadgloss-9e90517a98785c450cd13cd940bd1787a4771529.tar.gz
gloss-9e90517a98785c450cd13cd940bd1787a4771529.zip
refactor: rework gloss-add UX to single side-window buffer
The previous shape opened a regular (non-side) buffer for body input and showed the saved entry in the side window after C-c C-c. That left an extra window split during the typing phase and a side popup the user didn't ask for. New shape, modeled on `org-capture': - `gloss-add' renders the term and underline as a read-only header in *gloss-add: TERM*, leaves the body region beneath it editable, and pops the buffer in the side-window slot. Point lands at the body start so the user can type immediately. - `gloss-add-finish' reads the body via the `gloss-add--body-start' marker, saves with source `manual', kills the buffer, closes the side window, and echoes `gloss-add: saved TERM' for confirmation. - `gloss-add-abort' kills the buffer and closes the side window. - The shared `gloss--add-cleanup' helper handles kill + window-close for both finish and abort. Read-only header uses text properties (`read-only', `front-sticky', `rear-nonsticky') rather than narrowing, so the user can't escape the restriction with `C-x n w'. `gloss--add-finish-internal' no longer calls show-entry — the save is its only responsibility. The display decision (show or not) is the caller's, which lets `gloss-add-finish' choose "save and close" while `gloss-lookup' still chooses "save and show." The previous saved-window-config approach is dropped — the side-slot takeover means there's nothing to restore. Layout returns to its pre-add state on either C-c C-c or C-c C-k. Adds `tests/test-gloss--add-flow-smoke.el' covering the four interactive moments (open, finish, abort, empty-term guard) plus the read-only-header invariant. Updates the `gloss--add-finish-internal' tests to drop the show-entry assertion. 129 tests pass in 0.27s.
Diffstat (limited to 'tests/test-gloss--add-finish-internal.el')
-rw-r--r--tests/test-gloss--add-finish-internal.el47
1 files changed, 19 insertions, 28 deletions
diff --git a/tests/test-gloss--add-finish-internal.el b/tests/test-gloss--add-finish-internal.el
index 688d6f2..bb7e4ee 100644
--- a/tests/test-gloss--add-finish-internal.el
+++ b/tests/test-gloss--add-finish-internal.el
@@ -15,47 +15,38 @@
(require 'gloss)
(require 'testutil-gloss)
-(ert-deftest test-gloss-add-finish-internal-saves-and-shows ()
- "Normal: a fresh term + body is saved with source `manual' and shown."
+(ert-deftest test-gloss-add-finish-internal-saves-with-manual-source ()
+ "Normal: a fresh term + body is saved with source `manual'.
+Display is the caller's responsibility, not this function's."
(gloss-test--with-missing-glossary
- (let (shown)
- (cl-letf (((symbol-function 'gloss-display-show-entry)
- (lambda (term body) (setq shown (list term body)))))
- (gloss--add-finish-internal "newterm" "A new definition.")
- (let ((saved (gloss-core-lookup "newterm")))
- (should saved)
- (should (equal (plist-get saved :body) "A new definition."))
- (should (eq (plist-get saved :source) 'manual)))
- (should (equal shown '("newterm" "A new definition.")))))))
+ (let ((saved (gloss--add-finish-internal "newterm" "A new definition.")))
+ (should saved)
+ (should (equal (plist-get saved :body) "A new definition."))
+ (should (eq (plist-get saved :source) 'manual))
+ (should (equal (gloss-core-lookup "newterm") saved)))))
(ert-deftest test-gloss-add-finish-internal-empty-term-raises ()
"Error: empty TERM raises `user-error'."
(gloss-test--with-missing-glossary
- (cl-letf (((symbol-function 'gloss-display-show-entry)
- (lambda (_ _) nil)))
- (should-error (gloss--add-finish-internal "" "Body.")
- :type 'user-error)
- (should-error (gloss--add-finish-internal " " "Body.")
- :type 'user-error))))
+ (should-error (gloss--add-finish-internal "" "Body.")
+ :type 'user-error)
+ (should-error (gloss--add-finish-internal " " "Body.")
+ :type 'user-error)))
(ert-deftest test-gloss-add-finish-internal-empty-body-raises ()
"Error: empty BODY raises `user-error'."
(gloss-test--with-missing-glossary
- (cl-letf (((symbol-function 'gloss-display-show-entry)
- (lambda (_ _) nil)))
- (should-error (gloss--add-finish-internal "term" "")
- :type 'user-error)
- (should-error (gloss--add-finish-internal "term" " \n ")
- :type 'user-error))))
+ (should-error (gloss--add-finish-internal "term" "")
+ :type 'user-error)
+ (should-error (gloss--add-finish-internal "term" " \n ")
+ :type 'user-error)))
(ert-deftest test-gloss-add-finish-internal-trims-body-whitespace ()
"Boundary: leading/trailing whitespace in BODY is trimmed before save."
(gloss-test--with-missing-glossary
- (cl-letf (((symbol-function 'gloss-display-show-entry)
- (lambda (_ _) nil)))
- (gloss--add-finish-internal "term" " Body content.\n\n")
- (let ((saved (gloss-core-lookup "term")))
- (should (equal (plist-get saved :body) "Body content."))))))
+ (gloss--add-finish-internal "term" " Body content.\n\n")
+ (let ((saved (gloss-core-lookup "term")))
+ (should (equal (plist-get saved :body) "Body content.")))))
(provide 'test-gloss--add-finish-internal)
;;; test-gloss--add-finish-internal.el ends here