refactor(web): dependency management (#2386)

This commit is contained in:
Mo
2023-08-05 12:48:39 -05:00
committed by GitHub
parent b07da5b663
commit d8d4052a52
274 changed files with 4065 additions and 3873 deletions

View File

@@ -813,7 +813,7 @@ describe('importing', function () {
},
})
await application.launch(false)
await application.setHost(Factory.getDefaultHost())
await application.setHost.execute(Factory.getDefaultHost())
const backupFile = {
items: [

View File

@@ -50,17 +50,19 @@ describe('items', () => {
const item = this.application.items.items[0]
expect(item.pinned).to.not.be.ok
const refreshedItem = await this.application.changeAndSaveItem(
item,
(mutator) => {
mutator.pinned = true
mutator.archived = true
mutator.locked = true
},
undefined,
undefined,
syncOptions,
)
const refreshedItem = (
await this.application.changeAndSaveItem.execute(
item,
(mutator) => {
mutator.pinned = true
mutator.archived = true
mutator.locked = true
},
undefined,
undefined,
syncOptions,
)
).getValue()
expect(refreshedItem.pinned).to.equal(true)
expect(refreshedItem.archived).to.equal(true)
expect(refreshedItem.locked).to.equal(true)
@@ -77,94 +79,110 @@ describe('items', () => {
expect(item1.isItemContentEqualWith(item2)).to.equal(true)
// items should ignore this field when checking for equality
item1 = await this.application.changeAndSaveItem(
item1,
(mutator) => {
mutator.userModifiedDate = new Date()
},
undefined,
undefined,
syncOptions,
)
item2 = await this.application.changeAndSaveItem(
item2,
(mutator) => {
mutator.userModifiedDate = undefined
},
undefined,
undefined,
syncOptions,
)
item1 = (
await this.application.changeAndSaveItem.execute(
item1,
(mutator) => {
mutator.userModifiedDate = new Date()
},
undefined,
undefined,
syncOptions,
)
).getValue()
item2 = (
await this.application.changeAndSaveItem.execute(
item2,
(mutator) => {
mutator.userModifiedDate = undefined
},
undefined,
undefined,
syncOptions,
)
).getValue()
expect(item1.isItemContentEqualWith(item2)).to.equal(true)
item1 = await this.application.changeAndSaveItem(
item1,
(mutator) => {
mutator.mutableContent.foo = 'bar'
},
undefined,
undefined,
syncOptions,
)
item1 = (
await this.application.changeAndSaveItem.execute(
item1,
(mutator) => {
mutator.mutableContent.foo = 'bar'
},
undefined,
undefined,
syncOptions,
)
).getValue()
expect(item1.isItemContentEqualWith(item2)).to.equal(false)
item2 = await this.application.changeAndSaveItem(
item2,
(mutator) => {
mutator.mutableContent.foo = 'bar'
},
undefined,
undefined,
syncOptions,
)
item2 = (
await this.application.changeAndSaveItem.execute(
item2,
(mutator) => {
mutator.mutableContent.foo = 'bar'
},
undefined,
undefined,
syncOptions,
)
).getValue()
expect(item1.isItemContentEqualWith(item2)).to.equal(true)
expect(item2.isItemContentEqualWith(item1)).to.equal(true)
item1 = await this.application.changeAndSaveItem(
item1,
(mutator) => {
mutator.e2ePendingRefactor_addItemAsRelationship(item2)
},
undefined,
undefined,
syncOptions,
)
item2 = await this.application.changeAndSaveItem(
item2,
(mutator) => {
mutator.e2ePendingRefactor_addItemAsRelationship(item1)
},
undefined,
undefined,
syncOptions,
)
item1 = (
await this.application.changeAndSaveItem.execute(
item1,
(mutator) => {
mutator.e2ePendingRefactor_addItemAsRelationship(item2)
},
undefined,
undefined,
syncOptions,
)
).getValue()
item2 = (
await this.application.changeAndSaveItem.execute(
item2,
(mutator) => {
mutator.e2ePendingRefactor_addItemAsRelationship(item1)
},
undefined,
undefined,
syncOptions,
)
).getValue()
expect(item1.content.references.length).to.equal(1)
expect(item2.content.references.length).to.equal(1)
expect(item1.isItemContentEqualWith(item2)).to.equal(false)
item1 = await this.application.changeAndSaveItem(
item1,
(mutator) => {
mutator.removeItemAsRelationship(item2)
},
undefined,
undefined,
syncOptions,
)
item2 = await this.application.changeAndSaveItem(
item2,
(mutator) => {
mutator.removeItemAsRelationship(item1)
},
undefined,
undefined,
syncOptions,
)
item1 = (
await this.application.changeAndSaveItem.execute(
item1,
(mutator) => {
mutator.removeItemAsRelationship(item2)
},
undefined,
undefined,
syncOptions,
)
).getValue()
item2 = (
await this.application.changeAndSaveItem.execute(
item2,
(mutator) => {
mutator.removeItemAsRelationship(item1)
},
undefined,
undefined,
syncOptions,
)
).getValue()
expect(item1.isItemContentEqualWith(item2)).to.equal(true)
expect(item1.content.references.length).to.equal(0)
@@ -179,15 +197,17 @@ describe('items', () => {
let item1 = this.application.items.getDisplayableNotes()[0]
const item2 = this.application.items.getDisplayableNotes()[1]
item1 = await this.application.changeAndSaveItem(
item1,
(mutator) => {
mutator.mutableContent.foo = 'bar'
},
undefined,
undefined,
syncOptions,
)
item1 = (
await this.application.changeAndSaveItem.execute(
item1,
(mutator) => {
mutator.mutableContent.foo = 'bar'
},
undefined,
undefined,
syncOptions,
)
).getValue()
expect(item1.content.foo).to.equal('bar')

View File

@@ -184,15 +184,17 @@ describe('notes and tags', () => {
expect(note.content.references.length).to.equal(0)
expect(tag.content.references.length).to.equal(1)
tag = await this.application.changeAndSaveItem(
tag,
(mutator) => {
mutator.removeItemAsRelationship(note)
},
undefined,
undefined,
syncOptions,
)
tag = (
await this.application.changeAndSaveItem.execute(
tag,
(mutator) => {
mutator.removeItemAsRelationship(note)
},
undefined,
undefined,
syncOptions,
)
).getValue()
expect(this.application.items.itemsReferencingItem(note).length).to.equal(0)
expect(tag.noteCount).to.equal(0)
@@ -265,15 +267,17 @@ describe('notes and tags', () => {
const notePayload = Factory.createNotePayload()
await this.application.mutator.emitItemsFromPayloads([notePayload], PayloadEmitSource.LocalChanged)
let note = this.application.items.getItems([ContentType.TYPES.Note])[0]
note = await this.application.changeAndSaveItem(
note,
(mutator) => {
mutator.mutableContent.title = Math.random()
},
undefined,
undefined,
syncOptions,
)
note = (
await this.application.changeAndSaveItem.execute(
note,
(mutator) => {
mutator.mutableContent.title = Math.random()
},
undefined,
undefined,
syncOptions,
)
).getValue()
expect(note.content.title).to.not.equal(notePayload.content.title)
})