2022-02-01 17:48:50 +01:00
|
|
|
;; This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
;; License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
;; file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
;;
|
2022-09-20 23:23:22 +02:00
|
|
|
;; Copyright (c) KALEIDOS INC
|
2022-02-01 17:48:50 +01:00
|
|
|
|
2022-11-08 10:40:19 +01:00
|
|
|
(ns backend-tests.tasks-telemetry-test
|
2022-02-01 17:48:50 +01:00
|
|
|
(:require
|
|
|
|
[app.db :as db]
|
|
|
|
[app.util.time :as dt]
|
2023-11-29 12:53:34 +01:00
|
|
|
[backend-tests.helpers :as th]
|
2022-02-01 17:48:50 +01:00
|
|
|
[clojure.pprint :refer [pprint]]
|
|
|
|
[clojure.test :as t]
|
|
|
|
[mockery.core :refer [with-mocks]]))
|
|
|
|
|
|
|
|
(t/use-fixtures :once th/state-init)
|
|
|
|
(t/use-fixtures :each th/database-reset)
|
|
|
|
|
|
|
|
(t/deftest test-base-report-data-structure
|
|
|
|
(with-mocks [mock {:target 'app.tasks.telemetry/send!
|
|
|
|
:return nil}]
|
2022-11-22 18:06:24 +01:00
|
|
|
(let [prof (th/create-profile* 1 {:is-active true
|
|
|
|
:props {:newsletter-news true}})]
|
2022-02-01 17:48:50 +01:00
|
|
|
|
2022-11-22 18:06:24 +01:00
|
|
|
(th/run-task! :telemetry {:send? true :enabled? true})
|
2022-02-01 17:48:50 +01:00
|
|
|
|
|
|
|
(t/is (:called? @mock))
|
2022-02-28 17:15:58 +01:00
|
|
|
(let [[_ data] (-> @mock :call-args)]
|
2022-04-04 17:09:58 +02:00
|
|
|
(t/is (contains? data :subscriptions))
|
2022-09-22 13:34:42 +02:00
|
|
|
(t/is (= [(:email prof)] (get-in data [:subscriptions :newsletter-news])))
|
2022-02-01 17:48:50 +01:00
|
|
|
(t/is (contains? data :total-fonts))
|
|
|
|
(t/is (contains? data :total-users))
|
|
|
|
(t/is (contains? data :total-projects))
|
|
|
|
(t/is (contains? data :total-files))
|
|
|
|
(t/is (contains? data :total-teams))
|
|
|
|
(t/is (contains? data :total-comments))
|
|
|
|
(t/is (contains? data :instance-id))
|
|
|
|
(t/is (contains? data :jvm-cpus))
|
|
|
|
(t/is (contains? data :jvm-heap-max))
|
|
|
|
(t/is (contains? data :max-users-on-team))
|
|
|
|
(t/is (contains? data :avg-users-on-team))
|
|
|
|
(t/is (contains? data :max-files-on-project))
|
|
|
|
(t/is (contains? data :avg-files-on-project))
|
|
|
|
(t/is (contains? data :max-projects-on-team))
|
|
|
|
(t/is (contains? data :avg-files-on-project))
|
|
|
|
(t/is (contains? data :version))))))
|