Add pairing docs link, disable pfs toggle in release
Signed-off-by: Andrea Maria Piana <andrea.maria.piana@gmail.com>
This commit is contained in:
parent
7985ee838e
commit
89725d693a
1
.env
1
.env
|
@ -12,6 +12,7 @@ LOG_LEVEL_STATUS_GO=info
|
||||||
LOG_LEVEL=debug
|
LOG_LEVEL=debug
|
||||||
MAILSERVER_CONFIRMATIONS_ENABLED=0
|
MAILSERVER_CONFIRMATIONS_ENABLED=0
|
||||||
PFS_ENCRYPTION_ENABLED=1
|
PFS_ENCRYPTION_ENABLED=1
|
||||||
|
PFS_TOGGLE_VISIBLE=1
|
||||||
POW_TARGET=0.002
|
POW_TARGET=0.002
|
||||||
POW_TIME=1
|
POW_TIME=1
|
||||||
RN_BRIDGE_THRESHOLD_WARNINGS=0
|
RN_BRIDGE_THRESHOLD_WARNINGS=0
|
||||||
|
|
1
.env.e2e
1
.env.e2e
|
@ -10,6 +10,7 @@ LOG_LEVEL=debug
|
||||||
MAILSERVER_CONFIRMATIONS_ENABLED=0
|
MAILSERVER_CONFIRMATIONS_ENABLED=0
|
||||||
PAIRING_POPUP_DISABLED=1
|
PAIRING_POPUP_DISABLED=1
|
||||||
PFS_ENCRYPTION_ENABLED=1
|
PFS_ENCRYPTION_ENABLED=1
|
||||||
|
PFS_TOGGLE_VISIBLE=1
|
||||||
POW_TARGET=0.002
|
POW_TARGET=0.002
|
||||||
POW_TIME=1
|
POW_TIME=1
|
||||||
RN_BRIDGE_THRESHOLD_WARNINGS=0
|
RN_BRIDGE_THRESHOLD_WARNINGS=0
|
||||||
|
|
|
@ -12,6 +12,7 @@ LOG_LEVEL=debug
|
||||||
MAILSERVER_CONFIRMATIONS_ENABLED=0
|
MAILSERVER_CONFIRMATIONS_ENABLED=0
|
||||||
MAINNET_WARNING_ENABLED=1
|
MAINNET_WARNING_ENABLED=1
|
||||||
PFS_ENCRYPTION_ENABLED=1
|
PFS_ENCRYPTION_ENABLED=1
|
||||||
|
PFS_TOGGLE_VISIBLE=1
|
||||||
POW_TARGET=0.002
|
POW_TARGET=0.002
|
||||||
POW_TIME=1
|
POW_TIME=1
|
||||||
RN_BRIDGE_THRESHOLD_WARNINGS=0
|
RN_BRIDGE_THRESHOLD_WARNINGS=0
|
||||||
|
|
|
@ -10,6 +10,7 @@ LOG_LEVEL=debug
|
||||||
MAILSERVER_CONFIRMATIONS_ENABLED=0
|
MAILSERVER_CONFIRMATIONS_ENABLED=0
|
||||||
MAINNET_WARNING_ENABLED=1
|
MAINNET_WARNING_ENABLED=1
|
||||||
PFS_ENCRYPTION_ENABLED=1
|
PFS_ENCRYPTION_ENABLED=1
|
||||||
|
PFS_TOGGLE_VISIBLE=1
|
||||||
POW_TARGET=0.002
|
POW_TARGET=0.002
|
||||||
POW_TIME=1
|
POW_TIME=1
|
||||||
RN_BRIDGE_THRESHOLD_WARNINGS=0
|
RN_BRIDGE_THRESHOLD_WARNINGS=0
|
||||||
|
|
|
@ -10,6 +10,7 @@ LOG_LEVEL=debug
|
||||||
MAILSERVER_CONFIRMATIONS_ENABLED=0
|
MAILSERVER_CONFIRMATIONS_ENABLED=0
|
||||||
MAINNET_WARNING_ENABLED=1
|
MAINNET_WARNING_ENABLED=1
|
||||||
PFS_ENCRYPTION_ENABLED=1
|
PFS_ENCRYPTION_ENABLED=1
|
||||||
|
PFS_TOGGLE_VISIBLE=1
|
||||||
POW_TARGET=0.002
|
POW_TARGET=0.002
|
||||||
POW_TIME=1
|
POW_TIME=1
|
||||||
RN_BRIDGE_THRESHOLD_WARNINGS=0
|
RN_BRIDGE_THRESHOLD_WARNINGS=0
|
||||||
|
|
|
@ -9,6 +9,7 @@ LOG_LEVEL_STATUS_GO=
|
||||||
LOG_LEVEL=info
|
LOG_LEVEL=info
|
||||||
MAINNET_WARNING_ENABLED=1
|
MAINNET_WARNING_ENABLED=1
|
||||||
PFS_ENCRYPTION_ENABLED=1
|
PFS_ENCRYPTION_ENABLED=1
|
||||||
|
PFS_TOGGLE_VISIBLE=0
|
||||||
POW_TARGET=0.002
|
POW_TARGET=0.002
|
||||||
POW_TIME=1
|
POW_TIME=1
|
||||||
RN_BRIDGE_THRESHOLD_WARNINGS=0
|
RN_BRIDGE_THRESHOLD_WARNINGS=0
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
[status-im.contact.core :as models.contact]))
|
[status-im.contact.core :as models.contact]))
|
||||||
|
|
||||||
;; How long do we wait until we process a contact-recovery again?
|
;; How long do we wait until we process a contact-recovery again?
|
||||||
(def contact-recovery-interval-ms (* 6 60 60 1000))
|
(def contact-recovery-interval-ms (* 60 60 1000))
|
||||||
|
|
||||||
(defn prompt-dismissed! [public-key]
|
(defn prompt-dismissed! [public-key]
|
||||||
(re-frame/dispatch [:contact-recovery.ui/prompt-dismissed public-key]))
|
(re-frame/dispatch [:contact-recovery.ui/prompt-dismissed public-key]))
|
||||||
|
@ -40,10 +40,11 @@
|
||||||
[now public-key]
|
[now public-key]
|
||||||
(let [{:keys [timestamp]} (data-store.contact-recovery/get-contact-recovery-by-id public-key)]
|
(let [{:keys [timestamp]} (data-store.contact-recovery/get-contact-recovery-by-id public-key)]
|
||||||
(and timestamp
|
(and timestamp
|
||||||
(< contact-recovery-interval-ms (- now timestamp)))))
|
(> contact-recovery-interval-ms (- now timestamp)))))
|
||||||
|
|
||||||
(defn handle-recovery-fx [now public-key]
|
(defn handle-recovery-fx [now public-key]
|
||||||
(when-not (notified-recently? now public-key)
|
(if (notified-recently? now public-key)
|
||||||
|
(prompt-dismissed! public-key)
|
||||||
(re-frame/dispatch [:contact-recovery.callback/handle-recovery public-key])))
|
(re-frame/dispatch [:contact-recovery.callback/handle-recovery public-key])))
|
||||||
|
|
||||||
(fx/defn notify-user
|
(fx/defn notify-user
|
||||||
|
|
|
@ -74,7 +74,7 @@
|
||||||
[{:keys [db] :as cofx} {:keys [payload chat-id success-event]}]
|
[{:keys [db] :as cofx} {:keys [payload chat-id success-event]}]
|
||||||
(let [{:keys [web3]} db]
|
(let [{:keys [web3]} db]
|
||||||
(let [pfs? (get-in db [:account/account :settings :pfs?])]
|
(let [pfs? (get-in db [:account/account :settings :pfs?])]
|
||||||
(if pfs?
|
(if (and config/pfs-toggle-visible? pfs?)
|
||||||
(send-direct-message cofx
|
(send-direct-message cofx
|
||||||
chat-id
|
chat-id
|
||||||
success-event
|
success-event
|
||||||
|
|
|
@ -87,6 +87,7 @@
|
||||||
[pairing.views/edit-installation-name]
|
[pairing.views/edit-installation-name]
|
||||||
[react/view
|
[react/view
|
||||||
[pairing.views/pair-this-device]
|
[pairing.views/pair-this-device]
|
||||||
|
[pairing.views/info-section]
|
||||||
[pairing.views/sync-devices]
|
[pairing.views/sync-devices]
|
||||||
[react/view {:style pairing.styles/installation-list}
|
[react/view {:style pairing.styles/installation-list}
|
||||||
[pairing.views/your-device your-installation-id your-installation-name]
|
[pairing.views/your-device your-installation-id your-installation-name]
|
||||||
|
@ -193,7 +194,7 @@
|
||||||
[react/view {:style styles/title-separator}]
|
[react/view {:style styles/title-separator}]
|
||||||
[react/text {:style styles/adv-settings-subtitle} (i18n/label :t/pfs)]
|
[react/text {:style styles/adv-settings-subtitle} (i18n/label :t/pfs)]
|
||||||
[react/view {:style (styles/profile-row false)}
|
[react/view {:style (styles/profile-row false)}
|
||||||
[react/text {:style (styles/profile-row-text colors/black)} (i18n/label :notifications)]
|
[react/text {:style (styles/profile-row-text colors/black)} (i18n/label :t/pfs)]
|
||||||
[react/switch {:on-tint-color colors/blue
|
[react/switch {:on-tint-color colors/blue
|
||||||
:value pfs?
|
:value pfs?
|
||||||
:on-value-change #(re-frame/dispatch [:accounts.ui/toggle-pfs (not pfs?)])}]]])))
|
:on-value-change #(re-frame/dispatch [:accounts.ui/toggle-pfs (not pfs?)])}]]])))
|
||||||
|
|
|
@ -44,6 +44,13 @@
|
||||||
:padding-top 12
|
:padding-top 12
|
||||||
:background-color :white})
|
:background-color :white})
|
||||||
|
|
||||||
|
(def info-section
|
||||||
|
{:padding-horizontal 16
|
||||||
|
:padding-top 12})
|
||||||
|
|
||||||
|
(def info-section-text
|
||||||
|
{:color colors/blue})
|
||||||
|
|
||||||
(def pair-this-device-actions
|
(def pair-this-device-actions
|
||||||
{:flex 1
|
{:flex 1
|
||||||
:flex-direction :row})
|
:flex-direction :row})
|
||||||
|
|
|
@ -177,6 +177,11 @@
|
||||||
(re-frame/dispatch [:pairing.ui/set-name-pressed @installation-name])
|
(re-frame/dispatch [:pairing.ui/set-name-pressed @installation-name])
|
||||||
(reset! installation-name ""))}]]])
|
(reset! installation-name ""))}]]])
|
||||||
|
|
||||||
|
(defn info-section []
|
||||||
|
[react/view {:style styles/info-section}
|
||||||
|
[react/touchable-highlight {:on-press #(.openURL react/linking "https://status.im/tutorials/pairing.html")}
|
||||||
|
[react/text {:style styles/info-section-text} (i18n/label :t/learn-more)]]])
|
||||||
|
|
||||||
(defn installations-list [installation-id installation-name installations]
|
(defn installations-list [installation-id installation-name installations]
|
||||||
[react/view {:style styles/installation-list}
|
[react/view {:style styles/installation-list}
|
||||||
[react/view {:style styles/paired-devices-title}
|
[react/view {:style styles/paired-devices-title}
|
||||||
|
@ -197,5 +202,6 @@
|
||||||
[edit-installation-name]
|
[edit-installation-name]
|
||||||
[react/view
|
[react/view
|
||||||
[pair-this-device]
|
[pair-this-device]
|
||||||
|
[info-section]
|
||||||
[installations-list installation-id installation-name installations]])]
|
[installations-list installation-id installation-name installations]])]
|
||||||
(when (seq installations) [footer syncing])]))
|
(when (seq installations) [footer syncing])]))
|
||||||
|
|
|
@ -200,9 +200,9 @@
|
||||||
{:label-kw :t/bootnodes
|
{:label-kw :t/bootnodes
|
||||||
:action-fn #(re-frame/dispatch [:navigate-to :bootnodes-settings])
|
:action-fn #(re-frame/dispatch [:navigate-to :bootnodes-settings])
|
||||||
:accessibility-label :bootnodes-settings-button}])
|
:accessibility-label :bootnodes-settings-button}])
|
||||||
(when dev-mode?
|
(when (and dev-mode? config/pfs-toggle-visible?)
|
||||||
[profile.components/settings-item-separator])
|
[profile.components/settings-item-separator])
|
||||||
(when dev-mode?
|
(when (and dev-mode? config/pfs-toggle-visible?)
|
||||||
[profile.components/settings-switch-item
|
[profile.components/settings-switch-item
|
||||||
{:label-kw :t/pfs
|
{:label-kw :t/pfs
|
||||||
:value (:pfs? settings)
|
:value (:pfs? settings)
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
(def mainnet-warning-enabled? (enabled? (get-config :MAINNET_WARNING_ENABLED 0)))
|
(def mainnet-warning-enabled? (enabled? (get-config :MAINNET_WARNING_ENABLED 0)))
|
||||||
(def pfs-encryption-enabled? (enabled? (get-config :PFS_ENCRYPTION_ENABLED "0")))
|
(def pfs-encryption-enabled? (enabled? (get-config :PFS_ENCRYPTION_ENABLED "0")))
|
||||||
(def pairing-popup-disabled? (enabled? (get-config :PAIRING_POPUP_DISABLED "0")))
|
(def pairing-popup-disabled? (enabled? (get-config :PAIRING_POPUP_DISABLED "0")))
|
||||||
|
(def pfs-toggle-visible? (enabled? (get-config :PFS_TOGGLE_VISIBLE "0")))
|
||||||
(def cached-webviews-enabled? (enabled? (get-config :CACHED_WEBVIEWS_ENABLED 0)))
|
(def cached-webviews-enabled? (enabled? (get-config :CACHED_WEBVIEWS_ENABLED 0)))
|
||||||
(def rn-bridge-threshold-warnings-enabled? (enabled? (get-config :RN_BRIDGE_THRESHOLD_WARNINGS 0)))
|
(def rn-bridge-threshold-warnings-enabled? (enabled? (get-config :RN_BRIDGE_THRESHOLD_WARNINGS 0)))
|
||||||
(def extensions-enabled? (enabled? (get-config :EXTENSIONS 0)))
|
(def extensions-enabled? (enabled? (get-config :EXTENSIONS 0)))
|
||||||
|
|
|
@ -29,176 +29,174 @@
|
||||||
(is (= 3 (group-chats/get-last-clock-value {:db {:chats {chat-id {:last-clock-value 3}}}} chat-id))))
|
(is (= 3 (group-chats/get-last-clock-value {:db {:chats {chat-id {:last-clock-value 3}}}} chat-id))))
|
||||||
|
|
||||||
(deftest handle-group-membership-update-test
|
(deftest handle-group-membership-update-test
|
||||||
(with-redefs [config/group-chats-enabled? true]
|
(testing "a brand new chat"
|
||||||
(testing "a brand new chat"
|
(let [actual (->
|
||||||
(let [actual (->
|
(group-chats/handle-membership-update {:now 0 :db {}} initial-message "payload" admin)
|
||||||
(group-chats/handle-membership-update {:now 0 :db {}} initial-message "payload" admin)
|
:db
|
||||||
:db
|
:chats
|
||||||
:chats
|
(get chat-id))]
|
||||||
(get chat-id))]
|
(testing "it creates a new chat"
|
||||||
(testing "it creates a new chat"
|
(is actual))
|
||||||
(is actual))
|
(testing "it sets the right chat-name"
|
||||||
(testing "it sets the right chat-name"
|
(is (= "chat-name"
|
||||||
(is (= "chat-name"
|
(:name actual))))
|
||||||
(:name actual))))
|
(testing "it sets the right chat-id"
|
||||||
(testing "it sets the right chat-id"
|
(is (= chat-id
|
||||||
(is (= chat-id
|
(:chat-id actual))))
|
||||||
(:chat-id actual))))
|
(testing "it sets the right participants"
|
||||||
(testing "it sets the right participants"
|
(is (= #{member-1 member-2 member-3}
|
||||||
(is (= #{member-1 member-2 member-3}
|
(:contacts actual))))
|
||||||
(:contacts actual))))
|
(testing "it sets the updates"
|
||||||
(testing "it sets the updates"
|
(is (= (:membership-updates initial-message)
|
||||||
(is (= (:membership-updates initial-message)
|
(:membership-updates actual))))
|
||||||
(:membership-updates actual))))
|
(testing "it sets the right admins"
|
||||||
(testing "it sets the right admins"
|
(is (= #{admin}
|
||||||
(is (= #{admin}
|
(:admins actual))))
|
||||||
(:admins actual))))
|
(testing "it adds a system message"
|
||||||
(testing "it adds a system message"
|
(is (= 3 (count (:messages actual)))))
|
||||||
(is (= 3 (count (:messages actual)))))
|
(testing "it adds the right text"
|
||||||
(testing "it adds the right text"
|
(is (= ["group-chat-created"
|
||||||
(is (= ["group-chat-created"
|
"group-chat-member-added"
|
||||||
"group-chat-member-added"
|
"group-chat-member-added"]
|
||||||
"group-chat-member-added"]
|
(map (comp :text :content) (sort-by :clock-value (vals (:messages actual)))))))))
|
||||||
(map (comp :text :content) (sort-by :clock-value (vals (:messages actual)))))))))
|
(testing "a chat with the wrong id"
|
||||||
(testing "a chat with the wrong id"
|
(let [bad-chat-id (str random-id member-2)
|
||||||
(let [bad-chat-id (str random-id member-2)
|
actual (->
|
||||||
actual (->
|
(group-chats/handle-membership-update
|
||||||
(group-chats/handle-membership-update
|
{:now 0 :db {}}
|
||||||
{:now 0 :db {}}
|
(assoc initial-message :chat-id bad-chat-id)
|
||||||
(assoc initial-message :chat-id bad-chat-id)
|
"payload"
|
||||||
"payload"
|
admin)
|
||||||
admin)
|
:db
|
||||||
:db
|
:chats
|
||||||
:chats
|
(get bad-chat-id))]
|
||||||
(get bad-chat-id))]
|
(testing "it does not create a chat"
|
||||||
(testing "it does not create a chat"
|
(is (not actual)))))
|
||||||
(is (not actual)))))
|
(testing "an already existing chat"
|
||||||
(testing "an already existing chat"
|
(let [cofx (assoc
|
||||||
(let [cofx (assoc
|
(group-chats/handle-membership-update {:now 0 :db {:account/account {:public-key member-3}}} initial-message "payload" admin)
|
||||||
(group-chats/handle-membership-update {:now 0 :db {:account/account {:public-key member-3}}} initial-message "payload" admin)
|
:now 0)]
|
||||||
:now 0)]
|
(testing "the message has already been received"
|
||||||
(testing "the message has already been received"
|
(let [actual (group-chats/handle-membership-update cofx initial-message "payload" admin)]
|
||||||
(let [actual (group-chats/handle-membership-update cofx initial-message "payload" admin)]
|
(testing "it noops"
|
||||||
(testing "it noops"
|
(is (=
|
||||||
(is (=
|
(get-in cofx [:db :chats chat-id])
|
||||||
(get-in cofx [:db :chats chat-id])
|
(get-in actual [:db :chats chat-id]))))))
|
||||||
(get-in actual [:db :chats chat-id]))))))
|
(testing "a chat we have deleted"
|
||||||
(testing "a chat we have deleted"
|
(let [after-leaving-cofx (-> (group-chats/handle-membership-update cofx
|
||||||
(let [after-leaving-cofx (-> (group-chats/handle-membership-update cofx
|
{:chat-id chat-id
|
||||||
{:chat-id chat-id
|
:membership-updates [{:from member-1
|
||||||
:membership-updates [{:from member-1
|
:events [{:type "chat-created"
|
||||||
:events [{:type "chat-created"
|
:clock-value 1
|
||||||
:clock-value 1
|
:name "group-name"}
|
||||||
:name "group-name"}
|
{:type "admins-added"
|
||||||
{:type "admins-added"
|
:clock-value 10
|
||||||
:clock-value 10
|
:members [member-2]}
|
||||||
:members [member-2]}
|
{:type "admin-removed"
|
||||||
{:type "admin-removed"
|
:clock-value 11
|
||||||
:clock-value 11
|
:member member-1}]}
|
||||||
:member member-1}]}
|
{:from member-3
|
||||||
{:from member-3
|
:events [{:type "member-removed"
|
||||||
:events [{:type "member-removed"
|
:clock-value 12
|
||||||
:clock-value 12
|
:member member-3}]}]}
|
||||||
:member member-3}]}]}
|
"payload"
|
||||||
"payload"
|
member-3)
|
||||||
member-3)
|
(assoc-in [:db :chats chat-id :is-active] false))
|
||||||
(assoc-in [:db :chats chat-id :is-active] false))
|
after-been-invited-again-cofx (group-chats/handle-membership-update (assoc after-leaving-cofx :now 0)
|
||||||
after-been-invited-again-cofx (group-chats/handle-membership-update (assoc after-leaving-cofx :now 0)
|
{:chat-id chat-id
|
||||||
{:chat-id chat-id
|
:membership-updates [{:from member-1
|
||||||
:membership-updates [{:from member-1
|
:events [{:type "chat-created"
|
||||||
:events [{:type "chat-created"
|
:clock-value 1
|
||||||
:clock-value 1
|
:name "group-name"}
|
||||||
:name "group-name"}
|
{:type "admins-added"
|
||||||
{:type "admins-added"
|
:clock-value 10
|
||||||
:clock-value 10
|
:members [member-2]}
|
||||||
:members [member-2]}
|
{:type "admin-removed"
|
||||||
{:type "admin-removed"
|
:clock-value 11
|
||||||
:clock-value 11
|
:member member-1}]}
|
||||||
:member member-1}]}
|
{:from member-2
|
||||||
{:from member-2
|
:events [{:type "members-added"
|
||||||
:events [{:type "members-added"
|
:clock-value 13
|
||||||
:clock-value 13
|
:members [member-3]}]}]}
|
||||||
:members [member-3]}]}]}
|
"payload"
|
||||||
"payload"
|
member-2)]
|
||||||
member-2)]
|
|
||||||
|
|
||||||
(testing "it sets the chat active after been invited again"
|
(testing "it sets the chat active after been invited again"
|
||||||
(is (get-in after-been-invited-again-cofx [:db :chats chat-id :is-active])))))
|
(is (get-in after-been-invited-again-cofx [:db :chats chat-id :is-active])))))
|
||||||
(testing "a new message comes in"
|
(testing "a new message comes in"
|
||||||
(let [actual (group-chats/handle-membership-update cofx
|
(let [actual (group-chats/handle-membership-update cofx
|
||||||
{:chat-id chat-id
|
{:chat-id chat-id
|
||||||
:membership-updates [{:from member-1
|
:membership-updates [{:from member-1
|
||||||
:events [{:type "chat-created"
|
:events [{:type "chat-created"
|
||||||
:clock-value 1
|
:clock-value 1
|
||||||
:name "group-name"}
|
:name "group-name"}
|
||||||
{:type "admins-added"
|
{:type "admins-added"
|
||||||
:clock-value 10
|
:clock-value 10
|
||||||
:members [member-2]}
|
:members [member-2]}
|
||||||
{:type "admin-removed"
|
{:type "admin-removed"
|
||||||
:clock-value 11
|
:clock-value 11
|
||||||
:member member-1}]}
|
:member member-1}]}
|
||||||
{:from member-2
|
{:from member-2
|
||||||
:events [{:type "member-removed"
|
:events [{:type "member-removed"
|
||||||
:clock-value 12
|
:clock-value 12
|
||||||
:member member-3}
|
:member member-3}
|
||||||
{:type "members-added"
|
{:type "members-added"
|
||||||
:clock-value 12
|
:clock-value 12
|
||||||
:members [member-4]}
|
:members [member-4]}
|
||||||
{:type "name-changed"
|
{:type "name-changed"
|
||||||
:clock-value 13
|
:clock-value 13
|
||||||
:name "new-name"}]}]}
|
:name "new-name"}]}]}
|
||||||
"payload"
|
"payload"
|
||||||
member-3)
|
member-3)
|
||||||
actual-chat (get-in actual [:db :chats chat-id])]
|
actual-chat (get-in actual [:db :chats chat-id])]
|
||||||
(testing "the chat is updated"
|
(testing "the chat is updated"
|
||||||
(is actual-chat))
|
(is actual-chat))
|
||||||
(testing "admins are updated"
|
(testing "admins are updated"
|
||||||
(is (= #{member-2} (:admins actual-chat))))
|
(is (= #{member-2} (:admins actual-chat))))
|
||||||
(testing "members are updated"
|
(testing "members are updated"
|
||||||
(is (= #{member-1 member-2 member-4} (:contacts actual-chat))))
|
(is (= #{member-1 member-2 member-4} (:contacts actual-chat))))
|
||||||
(testing "the name is updated"
|
(testing "the name is updated"
|
||||||
(is (= "new-name" (:name actual-chat))))
|
(is (= "new-name" (:name actual-chat))))
|
||||||
(testing "it adds a system message"
|
(testing "it adds a system message"
|
||||||
(is (= 7 (count (:messages actual-chat)))))
|
(is (= 7 (count (:messages actual-chat)))))
|
||||||
(testing "it sets the right text"
|
(testing "it sets the right text"
|
||||||
(is (= ["group-chat-created"
|
(is (= ["group-chat-created"
|
||||||
"group-chat-member-added"
|
"group-chat-member-added"
|
||||||
"group-chat-member-added"
|
"group-chat-member-added"
|
||||||
"group-chat-admin-added"
|
"group-chat-admin-added"
|
||||||
"group-chat-member-added"
|
"group-chat-member-added"
|
||||||
"group-chat-member-removed"
|
"group-chat-member-removed"
|
||||||
"group-chat-name-changed"]
|
"group-chat-name-changed"]
|
||||||
(map (comp :text :content) (sort-by :clock-value (vals (:messages actual-chat)))))))))))))
|
(map (comp :text :content) (sort-by :clock-value (vals (:messages actual-chat))))))))))))
|
||||||
|
|
||||||
(deftest set-up-topic
|
(deftest set-up-topic
|
||||||
(with-redefs [config/group-chats-enabled? true]
|
(let [cofx {:now 0 :db {:account/account {:public-key admin}}}]
|
||||||
(let [cofx {:now 0 :db {:account/account {:public-key admin}}}]
|
(testing "a brand new chat"
|
||||||
(testing "a brand new chat"
|
(let [actual (group-chats/handle-membership-update cofx initial-message "payload" admin)]
|
||||||
(let [actual (group-chats/handle-membership-update cofx initial-message "payload" admin)]
|
(testing "it sets up a topic"
|
||||||
(testing "it sets up a topic"
|
(is (:shh/add-discovery-filters actual)))))
|
||||||
(is (:shh/add-discovery-filters actual)))))
|
(testing "an existing chat"
|
||||||
(testing "an existing chat"
|
(let [cofx (assoc cofx
|
||||||
(let [cofx (assoc cofx
|
:db
|
||||||
:db
|
(:db (group-chats/handle-membership-update cofx initial-message "payload" admin)))
|
||||||
(:db (group-chats/handle-membership-update cofx initial-message "payload" admin)))
|
new-message {:chat-id chat-id
|
||||||
new-message {:chat-id chat-id
|
:membership-updates [{:from member-1
|
||||||
:membership-updates [{:from member-1
|
:events [{:type "chat-created"
|
||||||
:events [{:type "chat-created"
|
:clock-value 1
|
||||||
:clock-value 1
|
:name "group-name"}
|
||||||
:name "group-name"}
|
{:type "admins-added"
|
||||||
{:type "admins-added"
|
:clock-value 10
|
||||||
:clock-value 10
|
:members [member-2]}
|
||||||
:members [member-2]}
|
{:type "admin-removed"
|
||||||
{:type "admin-removed"
|
:clock-value 11
|
||||||
:clock-value 11
|
:member member-1}]}
|
||||||
:member member-1}]}
|
{:from member-1
|
||||||
{:from member-1
|
:events [{:type "member-removed"
|
||||||
:events [{:type "member-removed"
|
:clock-value 12
|
||||||
:clock-value 12
|
:member member-1}]}]}
|
||||||
:member member-1}]}]}
|
actual (group-chats/handle-membership-update cofx new-message "payload" admin)]
|
||||||
actual (group-chats/handle-membership-update cofx new-message "payload" admin)]
|
(testing "it removes the topic"
|
||||||
(testing "it removes the topic"
|
(is (:shh/remove-filter actual)))))))
|
||||||
(is (:shh/remove-filter actual))))))))
|
|
||||||
|
|
||||||
(deftest build-group-test
|
(deftest build-group-test
|
||||||
(testing "only adds"
|
(testing "only adds"
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
"public-chat": "Public chat",
|
"public-chat": "Public chat",
|
||||||
"description": "Description",
|
"description": "Description",
|
||||||
"devices": "Devices",
|
"devices": "Devices",
|
||||||
|
"learn-more": "Learn more",
|
||||||
"pair": "Pair devices",
|
"pair": "Pair devices",
|
||||||
"pair-this-device": "Pair this device",
|
"pair-this-device": "Pair this device",
|
||||||
"pair-this-device-description": "Pair your devices to sync contacts and chats between them",
|
"pair-this-device-description": "Pair your devices to sync contacts and chats between them",
|
||||||
|
|
Loading…
Reference in New Issue