chore: designated survivor test suite (#2540)

* chore: designated survivor test suite

* add more tests

* fix: tests exclusivness

* fix removing account from shared vaults test
This commit is contained in:
Karol Sójko
2023-09-27 14:27:12 +02:00
committed by GitHub
parent 70cc15c6d9
commit 981417f952
17 changed files with 537 additions and 95 deletions

View File

@@ -1,4 +1,5 @@
import * as Factory from '../lib/factory.js'
import * as Utils from '../lib/Utils.js'
import * as Collaboration from '../lib/Collaboration.js'
chai.use(chaiAsPromised)
@@ -167,4 +168,47 @@ describe('shared vault deletion', function () {
await deinitContactContext()
})
it('should remove a user from all shared vaults upon account removal', async () => {
const secondContext = await Factory.createVaultsContextWithRealCrypto()
await secondContext.launch()
await secondContext.register()
const thirdContext = await Factory.createVaultsContextWithRealCrypto()
await thirdContext.launch()
await thirdContext.register()
const firstVault = await Collaboration.createSharedVault(context)
const secondVault = await Collaboration.createSharedVault(thirdContext)
const firstToSecondContact = await Collaboration.createTrustedContactForUserOfContext(context, secondContext)
await Collaboration.createTrustedContactForUserOfContext(secondContext, context)
const thirdToSecondContact = await Collaboration.createTrustedContactForUserOfContext(thirdContext, secondContext)
await Collaboration.createTrustedContactForUserOfContext(thirdContext, context)
await Collaboration.inviteContext(context, secondContext, firstVault, firstToSecondContact, SharedVaultUserPermission.PERMISSIONS.Write)
await Collaboration.inviteContext(thirdContext, secondContext, secondVault, thirdToSecondContact, SharedVaultUserPermission.PERMISSIONS.Write)
const promise = secondContext.awaitNextSyncSharedVaultFromScratchEvent()
await Collaboration.acceptAllInvites(secondContext)
await Utils.awaitPromiseOrThrow(promise, 2.0, 'Waiting for vault to sync')
Factory.handlePasswordChallenges(secondContext.application, secondContext.password)
await secondContext.application.user.deleteAccount()
await context.syncAndAwaitNotificationsProcessing()
await thirdContext.syncAndAwaitNotificationsProcessing()
const sharedVaultUsersInFirstVault = await context.vaultUsers.getSharedVaultUsersFromServer(firstVault)
expect(sharedVaultUsersInFirstVault.length).to.equal(1)
const sharedVaultUsersInSecondVault = await thirdContext.vaultUsers.getSharedVaultUsersFromServer(secondVault)
expect(sharedVaultUsersInSecondVault.length).to.equal(1)
await secondContext.deinit()
await thirdContext.deinit()
})
})