@@ -70,25 +70,39 @@ describe('shared vault invites', function () {
70
70
await deinitContactContext ( )
71
71
} )
72
72
73
- it ( 'invite should include delegated trusted contacts' , async ( ) => {
73
+ it ( 'invite should include delegated trusted contacts and add them when accepted ' , async ( ) => {
74
74
const { sharedVault, contactContext, deinitContactContext } =
75
75
await Collaboration . createSharedVaultWithAcceptedInvite ( context )
76
76
77
- const { thirdPartyContext, deinitThirdPartyContext } = await Collaboration . inviteNewPartyToSharedVault (
78
- context ,
79
- sharedVault ,
80
- )
77
+ const { thirdPartyContext : party1Context , deinitThirdPartyContext : deinitParty1Context } =
78
+ await Collaboration . inviteNewPartyToSharedVault ( context , sharedVault )
79
+
80
+ await Collaboration . acceptAllInvites ( party1Context )
81
81
82
- const invites = thirdPartyContext . vaultInvites . getCachedPendingInviteRecords ( )
82
+ const { thirdPartyContext : party2Context , deinitThirdPartyContext : deinitParty2Context } =
83
+ await Collaboration . inviteNewPartyToSharedVault ( context , sharedVault )
84
+
85
+ const invites = party2Context . vaultInvites . getCachedPendingInviteRecords ( )
83
86
84
87
const message = invites [ 0 ] . message
85
88
const delegatedContacts = message . data . trustedContacts
86
- expect ( delegatedContacts . length ) . to . equal ( 2 )
89
+ expect ( delegatedContacts . length ) . to . equal ( 3 )
87
90
88
91
expect ( delegatedContacts . some ( ( contact ) => contact . contactUuid === context . userUuid ) ) . to . be . true
89
92
expect ( delegatedContacts . some ( ( contact ) => contact . contactUuid === contactContext . userUuid ) ) . to . be . true
93
+ expect ( delegatedContacts . some ( ( contact ) => contact . contactUuid === party1Context . userUuid ) ) . to . be . true
94
+
95
+ await Collaboration . acceptAllInvites ( party2Context )
96
+
97
+ const trustedContacts = party2Context . contacts . getAllContacts ( )
98
+ expect ( trustedContacts . length ) . to . equal ( 4 )
99
+
100
+ expect ( trustedContacts . some ( ( contact ) => contact . contactUuid === context . userUuid ) ) . to . be . true
101
+ expect ( trustedContacts . some ( ( contact ) => contact . contactUuid === contactContext . userUuid ) ) . to . be . true
102
+ expect ( trustedContacts . some ( ( contact ) => contact . contactUuid === party1Context . userUuid ) ) . to . be . true
90
103
91
- await deinitThirdPartyContext ( )
104
+ await deinitParty1Context ( )
105
+ await deinitParty2Context ( )
92
106
await deinitContactContext ( )
93
107
} )
94
108
0 commit comments