* chore: upgrade @standardnotes/domain-core * chore: enable vault tests by default * chore: fix asymmetric messages paths * chore: fix message property from user_uuid to recipient_uuid * chore: fix server response properties for messages and notifications * chore: fix user_uuid to recipient_uuid in resend all message use case * chore: use notification payload and type from domain-core * chore: fix non existent uuid in conflicts tests * chore: use shared vault user permission from domain-core * chore: enable all e2e tests * chore: upgrade domain-core * chore: mark failing tests as skipped * chore: skip test * chore: fix recipient_uuid in specs * chore: skip test * chore: skip test * chore: skip test * chore: skip test * chore: fix remove unused var and unskip test * Revert "chore: skip test" This reverts commit 26bb876cf55e2c4fa9eeea56f73b3c2917a26f5c. * chore: unskip passing tests * chore: skip test * chore: skip test * fix: handle invite creation error * chore: skip tests * fix: disable vault tests to merge the PR * chore: unskip asymmetric messages tests
145 lines
5.3 KiB
JavaScript
145 lines
5.3 KiB
JavaScript
import * as Factory from '../lib/factory.js'
|
|
import * as Collaboration from '../lib/Collaboration.js'
|
|
|
|
chai.use(chaiAsPromised)
|
|
const expect = chai.expect
|
|
|
|
describe('shared vault items', function () {
|
|
this.timeout(Factory.TwentySecondTimeout)
|
|
|
|
let context
|
|
|
|
afterEach(async function () {
|
|
await context.deinit()
|
|
localStorage.clear()
|
|
})
|
|
|
|
beforeEach(async function () {
|
|
localStorage.clear()
|
|
|
|
context = await Factory.createAppContextWithRealCrypto()
|
|
|
|
await context.launch()
|
|
await context.register()
|
|
})
|
|
|
|
it('should add item to shared vault with no other members', async () => {
|
|
const note = await context.createSyncedNote('foo', 'bar')
|
|
|
|
const sharedVault = await Collaboration.createSharedVault(context)
|
|
|
|
await Collaboration.moveItemToVault(context, sharedVault, note)
|
|
|
|
const updatedNote = context.items.findItem(note.uuid)
|
|
expect(updatedNote.key_system_identifier).to.equal(sharedVault.systemIdentifier)
|
|
expect(updatedNote.shared_vault_uuid).to.equal(sharedVault.sharing.sharedVaultUuid)
|
|
})
|
|
|
|
it('should add item to shared vault with contact', async () => {
|
|
const note = await context.createSyncedNote('foo', 'bar')
|
|
|
|
const { sharedVault, deinitContactContext } = await Collaboration.createSharedVaultWithAcceptedInvite(context)
|
|
|
|
await Collaboration.moveItemToVault(context, sharedVault, note)
|
|
|
|
const updatedNote = context.items.findItem(note.uuid)
|
|
expect(updatedNote.key_system_identifier).to.equal(sharedVault.systemIdentifier)
|
|
|
|
await deinitContactContext()
|
|
})
|
|
|
|
it('received items from previously trusted contact should be decrypted', async () => {
|
|
const note = await context.createSyncedNote('foo', 'bar')
|
|
const { contactContext, deinitContactContext } = await Collaboration.createContactContext()
|
|
const sharedVault = await Collaboration.createSharedVault(context)
|
|
|
|
await Collaboration.createTrustedContactForUserOfContext(contactContext, context)
|
|
const currentContextContact = await Collaboration.createTrustedContactForUserOfContext(context, contactContext)
|
|
|
|
contactContext.lockSyncing()
|
|
await context.vaultInvites.inviteContactToSharedVault(
|
|
sharedVault,
|
|
currentContextContact,
|
|
SharedVaultUserPermission.PERMISSIONS.Write,
|
|
)
|
|
await Collaboration.moveItemToVault(context, sharedVault, note)
|
|
|
|
const promise = contactContext.awaitNextSyncSharedVaultFromScratchEvent()
|
|
contactContext.unlockSyncing()
|
|
await contactContext.sync()
|
|
await Collaboration.acceptAllInvites(contactContext)
|
|
await promise
|
|
|
|
const receivedItemsKey = contactContext.keys.getPrimaryKeySystemItemsKey(sharedVault.systemIdentifier)
|
|
expect(receivedItemsKey).to.not.be.undefined
|
|
expect(receivedItemsKey.itemsKey).to.not.be.undefined
|
|
|
|
const receivedNote = contactContext.items.findItem(note.uuid)
|
|
expect(receivedNote.title).to.equal('foo')
|
|
expect(receivedNote.text).to.equal(note.text)
|
|
|
|
await deinitContactContext()
|
|
})
|
|
|
|
it('shared vault creator should receive changes from other members', async () => {
|
|
const { sharedVault, contactContext, deinitContactContext } =
|
|
await Collaboration.createSharedVaultWithAcceptedInvite(context)
|
|
const note = await context.createSyncedNote('foo', 'bar')
|
|
await Collaboration.moveItemToVault(context, sharedVault, note)
|
|
await contactContext.sync()
|
|
|
|
await contactContext.mutator.changeItem({ uuid: note.uuid }, (mutator) => {
|
|
mutator.title = 'new title'
|
|
})
|
|
await contactContext.sync()
|
|
await context.sync()
|
|
|
|
const receivedNote = context.items.findItem(note.uuid)
|
|
expect(receivedNote.title).to.equal('new title')
|
|
|
|
await deinitContactContext()
|
|
})
|
|
|
|
it('items added by collaborator should be received by shared vault owner', async () => {
|
|
const { sharedVault, contactContext, deinitContactContext } =
|
|
await Collaboration.createSharedVaultWithAcceptedInviteAndNote(context)
|
|
|
|
const newNote = await contactContext.createSyncedNote('new note', 'new note text')
|
|
await Collaboration.moveItemToVault(contactContext, sharedVault, newNote)
|
|
|
|
await context.sync()
|
|
|
|
const receivedNote = context.items.findItem(newNote.uuid)
|
|
expect(receivedNote).to.not.be.undefined
|
|
expect(receivedNote.title).to.equal('new note')
|
|
|
|
await deinitContactContext()
|
|
})
|
|
|
|
it('adding item to vault while belonging to other vault should move the item to new vault', async () => {
|
|
const { note, sharedVault, contactContext, contact, deinitContactContext } =
|
|
await Collaboration.createSharedVaultWithAcceptedInviteAndNote(context)
|
|
|
|
const { sharedVault: otherSharedVault } = await Collaboration.createSharedVaultAndInviteContact(
|
|
context,
|
|
contactContext,
|
|
contact,
|
|
)
|
|
|
|
const updatedNote = await Collaboration.moveItemToVault(context, otherSharedVault, note)
|
|
|
|
expect(updatedNote.key_system_identifier).to.equal(otherSharedVault.systemIdentifier)
|
|
expect(updatedNote.shared_vault_uuid).to.equal(otherSharedVault.sharing.sharedVaultUuid)
|
|
|
|
await contactContext.sync()
|
|
|
|
const receivedNote = contactContext.items.findItem(note.uuid)
|
|
expect(receivedNote).to.not.be.undefined
|
|
expect(receivedNote.title).to.equal(note.title)
|
|
expect(receivedNote.key_system_identifier).to.equal(otherSharedVault.systemIdentifier)
|
|
expect(receivedNote.shared_vault_uuid).to.equal(otherSharedVault.sharing.sharedVaultUuid)
|
|
|
|
await deinitContactContext()
|
|
})
|
|
})
|