tests: vault tests 3 (#2373)

This commit is contained in:
Mo
2023-07-27 07:35:38 -05:00
committed by GitHub
parent 1fef36d601
commit 14bae5e895
26 changed files with 350 additions and 283 deletions

View File

@@ -0,0 +1,58 @@
import * as Factory from '../lib/factory.js'
import * as Collaboration from '../lib/Collaboration.js'
chai.use(chaiAsPromised)
const expect = chai.expect
describe.skip('vault importing', 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 import vaulted items with synced root key', async () => {
console.error('TODO: implement')
})
it('should import vaulted items with non-present root key', async () => {
const vault = await context.vaults.createUserInputtedPasswordVault({
name: 'test vault',
userInputtedPassword: 'test password',
storagePreference: KeySystemRootKeyStorageMode.Ephemeral,
})
const note = await context.createSyncedNote('foo', 'bar')
await Collaboration.moveItemToVault(context, vault, note)
const backupData = await context.application.createEncryptedBackupFileForAutomatedDesktopBackups()
const otherContext = await Factory.createAppContextWithRealCrypto()
await otherContext.launch()
await otherContext.application.importData(backupData)
const expectedImportedItems = ['vault-items-key', 'note']
const invalidItems = otherContext.items.invalidItems
expect(invalidItems.length).to.equal(expectedImportedItems.length)
const encryptedItem = invalidItems[0]
expect(encryptedItem.key_system_identifier).to.equal(vault.systemIdentifier)
expect(encryptedItem.errorDecrypting).to.be.true
expect(encryptedItem.uuid).to.equal(note.uuid)
await otherContext.deinit()
})
})