Update telemetry task for handle user subscriptions

This commit is contained in:
Andrey Antukh
2022-04-04 17:09:58 +02:00
parent 88292f2f3b
commit 0afb47ade0
3 changed files with 52 additions and 24 deletions

View File

@@ -21,13 +21,16 @@
(with-mocks [mock {:target 'app.tasks.telemetry/send!
:return nil}]
(let [task-fn (-> th/*system* :app.worker/registry :telemetry)
prof (th/create-profile* 1 {:is-active true})]
prof (th/create-profile* 1 {:is-active true
:props {:newsletter-subscribed true}})]
;; run the task
(task-fn nil)
(task-fn {:send? true :enabled? true})
(t/is (:called? @mock))
(let [[_ data] (-> @mock :call-args)]
(t/is (contains? data :subscriptions))
(t/is (= [(:email prof)] (get data :subscriptions)))
(t/is (contains? data :total-fonts))
(t/is (contains? data :total-users))
(t/is (contains? data :total-projects))