<commit_before>(defpackage :nyxt.tests
  (:use :common-lisp
        :nyxt
        :prove))

(in-package :nyxt.tests)

(plan nil)

(subtest "Global history"
  (let* ((*browser* (make-instance 'user-browser))
         (buffer (nyxt::make-internal-buffer)))
    ;; We need to make sure nothing will be restored.
    (nyxt:with-current-buffer buffer
      (let ((path (setf (history-path buffer)
                        (make-instance 'history-data-path
                                       :basename "history"
                                       :dirname "/tmp/nyxt-history-test"))))
        (nyxt::history-add (quri:uri "http://example.org"))
        (is (htree:size (nyxt:get-data path))
            1
            "history has 1 entry")
        (let ((entry (first (htree:all-nodes-data (nyxt:get-data path)))))
          (is (url entry)
              (quri:uri "http://example.org")
              :test #'quri:uri=
              "value has quri:uri")
          (is (title entry)
              ""
              "value has no title"))
        (nyxt::history-add (quri:uri "http://example.org") :title "foo")
        (is (htree:size (nyxt:get-data path))
            1
            "history has still 1 entry after adding same URI")
        (let ((entry (first (htree:all-nodes-data (nyxt:get-data path)))))
          (is (title entry)
              "foo"
              "value now has title"))
        (nyxt::history-add (quri:uri "http://example.org/sub"))
        (is (htree:size (nyxt:get-data path))
            2<commit_msg>tests/test-global-history: Use all-data instead of all-nodes-data.<commit_after>(defpackage :nyxt.tests
  (:use :common-lisp
        :nyxt
        :prove))

(in-package :nyxt.tests)

(plan nil)

(subtest "Global history"
  (let* ((*browser* (make-instance 'user-browser))
         (buffer (nyxt::make-internal-buffer)))
    ;; We need to make sure nothing will be restored.
    (nyxt:with-current-buffer buffer
      (let ((path (setf (history-path buffer)
                        (make-instance 'history-data-path
                                       :basename "history"
                                       :dirname "/tmp/nyxt-history-test"))))
        (nyxt::history-add (quri:uri "http://example.org"))
        (is (htree:size (nyxt:get-data path))
            1
            "history has 1 entry")
        (let ((entry (first (htree:all-data (nyxt:get-data path)))))
          (is (url entry)
              (quri:uri "http://example.org")
              :test #'quri:uri=
              "value has quri:uri")
          (is (title entry)
              ""
              "value has no title"))
        (nyxt::history-add (quri:uri "http://example.org") :title "foo")
        (is (htree:size (nyxt:get-data path))
            1
            "history has still 1 entry after adding same URI")
        (let ((entry (first (htree:all-data (nyxt:get-data path)))))
          (is (title entry)
              "foo"
              "value now has title"))
        (nyxt::history-add (quri:uri "http://example.org/sub"))
        (is (htree:size (nyxt:get-data path))
            2
{'fraction_non_alphanumeric': 0.1470493389229281, 'fraction_numerical': 0.0032247662044501773, 'mean_word_length': 1.7330396475770926, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4098342', 'n_tokens_mistral': 953, 'n_tokens_neox': 936, 'n_words': 238}