@@ -157,9 +157,83 @@ def test_download_on_demand(acfactory, tmp_path) -> None:
157
157
wait_for_chatlist_specific_item (alice , chat_id )
158
158
159
159
160
- # TODO
161
- # - [ ] change protection (1:1 chat gets guranteed encryption)
162
- # - [ ] Imap sync seen messages - chatlist item should update
163
- # - [ ] multidevice sync (chat visibility; chat muted)
164
- # - [ ] syncing chat visibility and muting across multiple devices
165
- # - [ ] Chatlist correctly updated after AEAP
160
+ def get_multi_account_test_setup (acfactory ) -> [Account , Account , Account ]:
161
+ # explicit type Annotations are needed for vscode
162
+ alice : Account
163
+ bob : Account
164
+ alice , bob = acfactory .get_online_accounts (2 )
165
+
166
+ bob_addr = bob .get_config ("addr" )
167
+ alice_contact_bob = alice .create_contact (bob_addr , "Bob" )
168
+ alice_chat_bob = alice_contact_bob .create_chat ()
169
+ alice_chat_bob .send_text ("hi" )
170
+
171
+ alice_second_device : Account = acfactory .get_unconfigured_account ()
172
+
173
+ # TODO somehow call provide_backup on alice without blocking on it
174
+
175
+ backup_code = alice ._rpc .get_backup_qr (alice .id )
176
+ logging .info ("backup_code" , backup_code )
177
+ alice_second_device ._rpc .get_backup (alice_second_device .id , backup_code )
178
+ alice .clear_all_events ()
179
+ alice_second_device .clear_all_events ()
180
+ bob .clear_all_events ()
181
+ return [alice , alice_second_device , bob , alice_chat_bob ]
182
+
183
+
184
+ def test_imap_sync_seen_msgs (acfactory , tmp_path ) -> None :
185
+ """
186
+ Test that chatlist changed events are emitted for the second device
187
+ when the message is marked as read on the first device
188
+ """
189
+ alice , alice_second_device , bob , alice_chat_bob = get_multi_account_test_setup (acfactory )
190
+
191
+ while True :
192
+ event = bob .wait_for_event ()
193
+ if event .kind == EventType .INCOMING_MSG :
194
+ msg = bob .get_message_by_id (event .msg_id )
195
+ bob_chat_id = msg .get_snapshot ().chat_id
196
+ bob ._rpc .accept_chat (bob .id , bob_chat_id )
197
+ break
198
+
199
+ alice .clear_all_events ()
200
+ alice_second_device .clear_all_events ()
201
+ bob .get_chat_by_id (bob_chat_id ).send_text ("hello" )
202
+
203
+ # make sure alice_second_device already received the message
204
+ while True :
205
+ event = alice_second_device .wait_for_event ()
206
+ if event .kind == EventType .INCOMING_MSG :
207
+ break
208
+
209
+ while True :
210
+ event = alice .wait_for_event ()
211
+ if event .kind == EventType .INCOMING_MSG :
212
+ msg = alice .get_message_by_id (event .msg_id )
213
+ alice_second_device .clear_all_events ()
214
+ alice .mark_seen_messages ([msg ])
215
+ break
216
+
217
+ wait_for_chatlist_specific_item (bob , bob_chat_id )
218
+ wait_for_chatlist_specific_item (alice , alice_chat_bob .id )
219
+
220
+
221
+ def test_multidevice_sync (acfactory , tmp_path ) -> None :
222
+ """
223
+ Test multidevice sync: syncing chat visibility and muting across multiple devices
224
+ """
225
+ alice , alice_second_device , bob , alice_chat_bob = get_multi_account_test_setup (acfactory )
226
+
227
+ alice_chat_bob .archive ()
228
+ wait_for_chatlist_specific_item (alice_second_device , alice_chat_bob .id )
229
+ assert alice_second_device .get_chat_by_id (alice_chat_bob .id ).get_basic_snapshot ().archived
230
+
231
+ alice_second_device .clear_all_events ()
232
+ alice_chat_bob .pin ()
233
+ wait_for_chatlist_specific_item (alice_second_device , alice_chat_bob .id )
234
+
235
+ alice_second_device .clear_all_events ()
236
+ alice_chat_bob .mute ()
237
+ wait_for_chatlist_specific_item (alice_second_device , alice_chat_bob .id )
238
+ assert alice_second_device .get_chat_by_id (alice_chat_bob .id ).get_basic_snapshot ().is_muted
239
+
0 commit comments