From a7ea1196c15227dd7508b7b062e9e2599b9d8b97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20S=C3=B3jko?= Date: Thu, 28 Sep 2023 14:58:57 +0200 Subject: [PATCH 1/3] chore: re-enable tests with changed behavior --- packages/snjs/mocha/vaults/surviving.test.js | 50 +++++++------------- 1 file changed, 18 insertions(+), 32 deletions(-) diff --git a/packages/snjs/mocha/vaults/surviving.test.js b/packages/snjs/mocha/vaults/surviving.test.js index 255d0eb9742..8d5122770f4 100644 --- a/packages/snjs/mocha/vaults/surviving.test.js +++ b/packages/snjs/mocha/vaults/surviving.test.js @@ -52,8 +52,8 @@ describe('designated survival', function () { expect(vault.sharing.designatedSurvivor).to.equal(contactContext.userUuid) }) - describe.skip('owner of a shared vault with a designated survivor removing the vault', () => { - it('should not remove all users from the vault upon shared vault removal', async () => { + describe('owner of a shared vault with a designated survivor removing the vault', () => { + it('should remove all users from the vault upon shared vault removal', async () => { const { sharedVault, contactContext } = await Collaboration.createSharedVaultWithAcceptedInvite(context) secondContext = contactContext @@ -74,23 +74,20 @@ describe('designated survival', function () { await secondContext.syncAndAwaitNotificationsProcessing() await thirdContext.syncAndAwaitNotificationsProcessing() - const sharedVaultUsers = await secondContext.vaultUsers.getSharedVaultUsersFromServer(sharedVault) - expect(sharedVaultUsers.length).to.equal(2) - expect(context.vaults.getVault({ keySystemIdentifier: sharedVault.systemIdentifier }).isFailed()).to.be.true expect(context.keys.getPrimaryKeySystemRootKey(sharedVault.systemIdentifier)).to.be.undefined expect(context.keys.getKeySystemItemsKeys(sharedVault.systemIdentifier)).to.be.empty - expect(secondContext.vaults.getVault({ keySystemIdentifier: sharedVault.systemIdentifier }).getValue()).to.not.be.undefined - expect(secondContext.keys.getPrimaryKeySystemRootKey(sharedVault.systemIdentifier)).to.not.be.undefined - expect(secondContext.keys.getKeySystemItemsKeys(sharedVault.systemIdentifier)).to.not.be.empty + expect(secondContext.vaults.getVault({ keySystemIdentifier: sharedVault.systemIdentifier }).isFailed()).to.be.true + expect(secondContext.keys.getPrimaryKeySystemRootKey(sharedVault.systemIdentifier)).to.be.undefined + expect(secondContext.keys.getKeySystemItemsKeys(sharedVault.systemIdentifier)).to.be.empty - expect(thirdContext.vaults.getVault({ keySystemIdentifier: sharedVault.systemIdentifier }).getValue()).to.not.be.undefined - expect(thirdContext.keys.getPrimaryKeySystemRootKey(sharedVault.systemIdentifier)).to.not.be.undefined - expect(thirdContext.keys.getKeySystemItemsKeys(sharedVault.systemIdentifier)).to.not.be.empty + expect(thirdContext.vaults.getVault({ keySystemIdentifier: sharedVault.systemIdentifier }).isFailed()).to.be.true + expect(thirdContext.keys.getPrimaryKeySystemRootKey(sharedVault.systemIdentifier)).to.be.undefined + expect(thirdContext.keys.getKeySystemItemsKeys(sharedVault.systemIdentifier)).to.be.empty }) - it('should transition items of the owner in the vault to the designated survivor', async () => { + it('should not transition items of the owner in the vault to the designated survivor', async () => { const { sharedVault, contactContext } = await Collaboration.createSharedVaultWithAcceptedInvite(context) secondContext = contactContext @@ -113,19 +110,14 @@ describe('designated survival', function () { await secondContext.syncAndAwaitNotificationsProcessing() await thirdContext.syncAndAwaitNotificationsProcessing() - const sharedVaultUsers = await secondContext.vaultUsers.getSharedVaultUsersFromServer(sharedVault) - expect(sharedVaultUsers.length).to.equal(2) - const contactNote = secondContext.items.findItem(note.uuid) - expect(contactNote.key_system_identifier).to.equal(sharedVault.systemIdentifier) - expect(contactNote.user_uuid).to.equal(secondContext.userUuid) + expect(contactNote).to.be.undefined const thirdPartyNote = thirdContext.items.findItem(note.uuid) - expect(thirdPartyNote.key_system_identifier).to.equal(sharedVault.systemIdentifier) - expect(thirdPartyNote.user_uuid).to.equal(secondContext.userUuid) + expect(thirdPartyNote).to.be.undefined }) - it('should still allow to download files of the owner in the vault', async () => { + it('should not allow to download files of the owner in the vault', async () => { await context.activatePaidSubscriptionForUser() const { sharedVault, contactContext } = @@ -157,14 +149,10 @@ describe('designated survival', function () { await secondContext.syncAndAwaitNotificationsProcessing() const sharedFileAfter = secondContext.items.findItem(uploadedFile.uuid) - expect(sharedFileAfter).to.not.be.undefined - expect(sharedFileAfter.remoteIdentifier).to.equal(uploadedFile.remoteIdentifier) - - const downloadedBytes = await Files.downloadFile(secondContext.files, sharedFileAfter) - expect(downloadedBytes).to.eql(buffer) + expect(sharedFileAfter).to.be.undefined }) - it('should transition vault ownership to the designated survivor', async () => { + it('should not transition vault ownership to the designated survivor', async () => { const { sharedVault, contactContext } = await Collaboration.createSharedVaultWithAcceptedInvite(context) secondContext = contactContext @@ -184,13 +172,11 @@ describe('designated survival', function () { await secondContext.syncAndAwaitNotificationsProcessing() await thirdContext.syncAndAwaitNotificationsProcessing() - const contactVault = secondContext.vaults.getVault({ keySystemIdentifier: sharedVault.systemIdentifier }).getValue() - expect(contactVault.sharing.ownerUserUuid).to.not.equal(context.userUuid) - expect(contactVault.sharing.ownerUserUuid).to.equal(secondContext.userUuid) + const contactVaultOrError = secondContext.vaults.getVault({ keySystemIdentifier: sharedVault.systemIdentifier }) + expect(contactVaultOrError.isFailed()).to.be.true - const thirdPartyVault = thirdContext.vaults.getVault({ keySystemIdentifier: sharedVault.systemIdentifier }).getValue() - expect(thirdPartyVault.sharing.ownerUserUuid).to.not.equal(context.userUuid) - expect(thirdPartyVault.sharing.ownerUserUuid).to.equal(secondContext.userUuid) + const thirdPartyVaultOrError = thirdContext.vaults.getVault({ keySystemIdentifier: sharedVault.systemIdentifier }) + expect(thirdPartyVaultOrError.isFailed()).to.be.true }) }) From 0a351df2654cc55cce1e4aa79c9bdea8e51ae788 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20S=C3=B3jko?= Date: Fri, 29 Sep 2023 10:53:03 +0200 Subject: [PATCH 2/3] fix: deiniting context on deleted account tests --- packages/snjs/mocha/vaults/surviving.test.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/snjs/mocha/vaults/surviving.test.js b/packages/snjs/mocha/vaults/surviving.test.js index 8d5122770f4..1746c7779fd 100644 --- a/packages/snjs/mocha/vaults/surviving.test.js +++ b/packages/snjs/mocha/vaults/surviving.test.js @@ -22,7 +22,9 @@ describe('designated survival', function () { }) afterEach(async function () { - await context.deinit() + if (context && !context.application.dealloced) { + await context.deinit() + } localStorage.clear() sinon.restore() context = undefined From 7cb3c54f6bdfa49eae1479fb53a9cd03b820cd46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karol=20S=C3=B3jko?= Date: Fri, 29 Sep 2023 11:50:20 +0200 Subject: [PATCH 3/3] fix test --- packages/snjs/mocha/vaults/surviving.test.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/snjs/mocha/vaults/surviving.test.js b/packages/snjs/mocha/vaults/surviving.test.js index 1746c7779fd..f404252fdec 100644 --- a/packages/snjs/mocha/vaults/surviving.test.js +++ b/packages/snjs/mocha/vaults/surviving.test.js @@ -274,6 +274,7 @@ describe('designated survival', function () { const uploadedFile = await Files.uploadFile(context.files, buffer, 'my-file', 'md', 1000, sharedVault) await secondContext.syncAndAwaitNotificationsProcessing() + await context.syncAndAwaitNotificationsProcessing() const sharedFileBefore = secondContext.items.findItem(uploadedFile.uuid) expect(sharedFileBefore).to.not.be.undefined