refactor: application dependency management (#2363)

This commit is contained in:
Mo
2023-07-23 15:54:31 -05:00
committed by GitHub
parent e698b1c990
commit a77535456c
299 changed files with 7415 additions and 4890 deletions

View File

@@ -19,7 +19,7 @@ describe('offline syncing', () => {
})
afterEach(async function () {
expect(this.application.syncService.isOutOfSync()).to.equal(false)
expect(this.application.sync.isOutOfSync()).to.equal(false)
await Factory.safeDeinit(this.application)
})
@@ -38,19 +38,19 @@ describe('offline syncing', () => {
await Factory.alternateUuidForItem(this.application, note.uuid)
await this.application.sync.sync(syncOptions)
const notes = this.application.itemManager.getDisplayableNotes()
const notes = this.application.items.getDisplayableNotes()
expect(notes.length).to.equal(1)
expect(notes[0].uuid).to.not.equal(note.uuid)
const items = this.application.itemManager.allTrackedItems()
const items = this.application.items.allTrackedItems()
expect(items.length).to.equal(this.expectedItemCount)
})
it('should sync item with no passcode', async function () {
let note = await Factory.createMappedNote(this.application)
expect(Uuids(this.application.itemManager.getDirtyItems()).includes(note.uuid))
expect(Uuids(this.application.items.getDirtyItems()).includes(note.uuid))
await this.application.syncService.sync(syncOptions)
await this.application.sync.sync(syncOptions)
note = this.application.items.findItem(note.uuid)
@@ -59,9 +59,9 @@ describe('offline syncing', () => {
this.expectedItemCount++
expect(this.application.itemManager.getDirtyItems().length).to.equal(0)
expect(this.application.items.getDirtyItems().length).to.equal(0)
const rawPayloads2 = await this.application.diskStorageService.getAllRawPayloads()
const rawPayloads2 = await this.application.storage.getAllRawPayloads()
expect(rawPayloads2.length).to.equal(this.expectedItemCount)
const itemsKeyRaw = (await Factory.getStoragePayloadsOfType(this.application, ContentType.TYPES.ItemsKey))[0]
@@ -77,26 +77,26 @@ describe('offline syncing', () => {
it('should sync item encrypted with passcode', async function () {
await this.application.addPasscode('foobar')
await Factory.createMappedNote(this.application)
expect(this.application.itemManager.getDirtyItems().length).to.equal(1)
const rawPayloads1 = await this.application.diskStorageService.getAllRawPayloads()
expect(this.application.items.getDirtyItems().length).to.equal(1)
const rawPayloads1 = await this.application.storage.getAllRawPayloads()
expect(rawPayloads1.length).to.equal(this.expectedItemCount)
await this.application.syncService.sync(syncOptions)
await this.application.sync.sync(syncOptions)
this.expectedItemCount++
expect(this.application.itemManager.getDirtyItems().length).to.equal(0)
const rawPayloads2 = await this.application.diskStorageService.getAllRawPayloads()
expect(this.application.items.getDirtyItems().length).to.equal(0)
const rawPayloads2 = await this.application.storage.getAllRawPayloads()
expect(rawPayloads2.length).to.equal(this.expectedItemCount)
const payload = rawPayloads2[0]
expect(typeof payload.content).to.equal('string')
expect(payload.content.startsWith(this.application.encryptionService.getLatestVersion())).to.equal(true)
expect(payload.content.startsWith(this.application.encryption.getLatestVersion())).to.equal(true)
})
it('signing out while offline should succeed', async function () {
await Factory.createMappedNote(this.application)
this.expectedItemCount++
await this.application.syncService.sync(syncOptions)
await this.application.sync.sync(syncOptions)
this.application = await Factory.signOutApplicationAndReturnNew(this.application)
expect(this.application.noAccount()).to.equal(true)
expect(this.application.getUser()).to.not.be.ok