<commit_before>(ns metabase.email.messages-test
  (:require [expectations :refer :all]
            [metabase.email-test :refer [with-fake-inbox inbox]]
            [metabase.email.messages :refer :all]))

;; new user email
;; NOTE: we are not validating the content of the email body namely because it's got randomized elements and thus
;;       it would be extremely hard to have a predictable test that we can rely on
(expect
    [{:from "<EMAIL>",
      :to ["<EMAIL>"],
      :subject "You're invited to join Metabase Test's Metabase",
      :body [{:type "text/html; charset=utf-8"}]}]
  (with-fake-inbox
    (send-new-user-email {:first_name "test" :email "<EMAIL>"}
                         {:first_name "invitor" :email "<EMAIL>"}
                         "http://localhost/some/url")
    (-> (@inbox "<EMAIL>")
        (update-in [0 :body 0] dissoc :content))))

;; password reset email
(expect
    [{:from "<EMAIL>",
      :to ["<EMAIL>"],
      :subject "[Metabase] Password Reset Request",
      :body [{:type "text/html; charset=utf-8",
              :content (str "<html><body><p>You're receiving this e-mail because you or someone else has requested a password for your user account at <EMAIL>.domain.<EMAIL>. "
                            "It can be safely ignored if you did not request a password reset. Click the link below to reset your password.</p>"
                            "<p><a href=\"http://localhost/some/url\">http://localhost/some/url</a></p></body></html>")}]}]
  (with-fake-inbox
    (send-password-reset-email "<EMAIL>" "test.domain.com" "http://localhost/some/url")
    (@inbox "<EMAIL>")))<commit_msg>Fix password reset unit test<commit_after>(ns metabase.email.messages-test
  (:require [expectations :refer :all]
            [metabase.email-test :refer [with-fake-inbox inbox]]
            [metabase.email.messages :refer :all]))

;; new user email
;; NOTE: we are not validating the content of the email body namely because it's got randomized elements and thus
;;       it would be extremely hard to have a predictable test that we can rely on
(expect
    [{:from "<EMAIL>",
      :to ["<EMAIL>"],
      :subject "You're invited to join Metabase Test's Metabase",
      :body [{:type "text/html; charset=utf-8"}]}]
  (with-fake-inbox
    (send-new-user-email {:first_name "test" :email "<EMAIL>"}
                         {:first_name "invitor" :email "<EMAIL>"}
                         "http://localhost/some/url")
    (-> (@inbox "<EMAIL>")
        (update-in [0 :body 0] dissoc :content))))

;; password reset email
(expect
    [{:from "<EMAIL>",
      :to ["<EMAIL>"],
      :subject "[Metabase] Password Reset Request",
      :body [{:type "text/html; charset=utf-8"}]}]
  (with-fake-inbox
    (send-password-reset-email "<EMAIL>" "test.domain.com" "http://localhost/some/url")
    (-> (@inbox "<EMAIL>")
        (update-in [0 :body 0] dissoc :content))))
{'fraction_non_alphanumeric': 0.16327936617292457, 'fraction_numerical': 0.003444712366517396, 'mean_word_length': 2.78125, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 36, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3383568', 'n_tokens_mistral': 899, 'n_tokens_neox': 876, 'n_words': 273}