chore: enable vault tests (#2518)
This commit is contained in:
@@ -146,7 +146,7 @@ export class VaultService
|
|||||||
async moveItemToVault(
|
async moveItemToVault(
|
||||||
vault: VaultListingInterface,
|
vault: VaultListingInterface,
|
||||||
item: DecryptedItemInterface,
|
item: DecryptedItemInterface,
|
||||||
): Promise<DecryptedItemInterface | undefined> {
|
): Promise<Result<DecryptedItemInterface>> {
|
||||||
if (this.vaultLocks.isVaultLocked(vault)) {
|
if (this.vaultLocks.isVaultLocked(vault)) {
|
||||||
throw new Error('Attempting to add item to locked vault')
|
throw new Error('Attempting to add item to locked vault')
|
||||||
}
|
}
|
||||||
@@ -167,13 +167,16 @@ export class VaultService
|
|||||||
text: 'This item is linked to other items that are not in the same vault. Please move those items to this vault first.',
|
text: 'This item is linked to other items that are not in the same vault. Please move those items to this vault first.',
|
||||||
})
|
})
|
||||||
.catch(console.error)
|
.catch(console.error)
|
||||||
return undefined
|
|
||||||
|
return Result.fail(
|
||||||
|
'This item is linked to other items that are not in the same vault. Please move those items to this vault first.',
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await this._moveItemsToVault.execute({ vault, items: [item] })
|
await this._moveItemsToVault.execute({ vault, items: [item] })
|
||||||
|
|
||||||
return this.items.findSureItem(item.uuid)
|
return Result.ok(this.items.findSureItem(item.uuid))
|
||||||
}
|
}
|
||||||
|
|
||||||
async removeItemFromVault(item: DecryptedItemInterface): Promise<DecryptedItemInterface> {
|
async removeItemFromVault(item: DecryptedItemInterface): Promise<DecryptedItemInterface> {
|
||||||
@@ -248,16 +251,16 @@ export class VaultService
|
|||||||
}
|
}
|
||||||
|
|
||||||
getItemVault(item: DecryptedItemInterface): VaultListingInterface | undefined {
|
getItemVault(item: DecryptedItemInterface): VaultListingInterface | undefined {
|
||||||
if (this.items.isTemplateItem(item)) {
|
|
||||||
return undefined
|
|
||||||
}
|
|
||||||
|
|
||||||
const latestItem = this.items.findItem(item.uuid)
|
const latestItem = this.items.findItem(item.uuid)
|
||||||
|
|
||||||
if (!latestItem) {
|
if (!latestItem) {
|
||||||
throw new Error('Cannot find latest version of item to get vault for')
|
throw new Error('Cannot find latest version of item to get vault for')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.items.isTemplateItem(item)) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
|
||||||
if (!latestItem.key_system_identifier) {
|
if (!latestItem.key_system_identifier) {
|
||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,10 +32,7 @@ export interface VaultServiceInterface
|
|||||||
authorizeVaultDeletion(vault: VaultListingInterface): Promise<Result<boolean>>
|
authorizeVaultDeletion(vault: VaultListingInterface): Promise<Result<boolean>>
|
||||||
deleteVault(vault: VaultListingInterface): Promise<boolean>
|
deleteVault(vault: VaultListingInterface): Promise<boolean>
|
||||||
|
|
||||||
moveItemToVault(
|
moveItemToVault(vault: VaultListingInterface, item: DecryptedItemInterface): Promise<Result<DecryptedItemInterface>>
|
||||||
vault: VaultListingInterface,
|
|
||||||
item: DecryptedItemInterface,
|
|
||||||
): Promise<DecryptedItemInterface | undefined>
|
|
||||||
removeItemFromVault(item: DecryptedItemInterface): Promise<DecryptedItemInterface>
|
removeItemFromVault(item: DecryptedItemInterface): Promise<DecryptedItemInterface>
|
||||||
isItemInVault(item: DecryptedItemInterface): boolean
|
isItemInVault(item: DecryptedItemInterface): boolean
|
||||||
getItemVault(item: DecryptedItemInterface): VaultListingInterface | undefined
|
getItemVault(item: DecryptedItemInterface): VaultListingInterface | undefined
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
export const VaultTests = {
|
export const VaultTests = {
|
||||||
enabled: false,
|
enabled: true,
|
||||||
exclusive: false,
|
exclusive: false,
|
||||||
files: [
|
files: [
|
||||||
'vaults/vaults.test.js',
|
'vaults/vaults.test.js',
|
||||||
|
|||||||
@@ -198,7 +198,12 @@ export const createSharedVaultWithNote = async (context) => {
|
|||||||
|
|
||||||
export const moveItemToVault = async (context, sharedVault, item) => {
|
export const moveItemToVault = async (context, sharedVault, item) => {
|
||||||
const promise = context.resolveWhenItemCompletesAddingToVault(item)
|
const promise = context.resolveWhenItemCompletesAddingToVault(item)
|
||||||
const updatedItem = await context.vaults.moveItemToVault(sharedVault, item)
|
const result = await context.vaults.moveItemToVault(sharedVault, item)
|
||||||
await promise
|
await promise
|
||||||
return updatedItem
|
|
||||||
|
if (result.isFailed()) {
|
||||||
|
throw new Error(result.getError())
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.getValue()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,13 +142,13 @@ describe('shared vault deletion', function () {
|
|||||||
const { sharedVault, contactContext, deinitContactContext } =
|
const { sharedVault, contactContext, deinitContactContext } =
|
||||||
await Collaboration.createSharedVaultWithAcceptedInvite(context)
|
await Collaboration.createSharedVaultWithAcceptedInvite(context)
|
||||||
|
|
||||||
const originalSharedVaultUsers = await context.vaultUsers.getSharedVaultUsers(sharedVault)
|
const originalSharedVaultUsers = await context.vaultUsers.getSharedVaultUsersFromServer(sharedVault)
|
||||||
expect(originalSharedVaultUsers.length).to.equal(2)
|
expect(originalSharedVaultUsers.length).to.equal(2)
|
||||||
|
|
||||||
const result = await context.vaultUsers.removeUserFromSharedVault(sharedVault, contactContext.userUuid)
|
const result = await context.vaultUsers.removeUserFromSharedVault(sharedVault, contactContext.userUuid)
|
||||||
expect(result.isFailed()).to.be.false
|
expect(result.isFailed()).to.be.false
|
||||||
|
|
||||||
const updatedSharedVaultUsers = await context.vaultUsers.getSharedVaultUsers(sharedVault)
|
const updatedSharedVaultUsers = await context.vaultUsers.getSharedVaultUsersFromServer(sharedVault)
|
||||||
expect(updatedSharedVaultUsers.length).to.equal(1)
|
expect(updatedSharedVaultUsers.length).to.equal(1)
|
||||||
|
|
||||||
await deinitContactContext()
|
await deinitContactContext()
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ describe('shared vault files', function () {
|
|||||||
const uploadedFile = await Files.uploadFile(context.files, buffer, 'my-file', 'md', 1000)
|
const uploadedFile = await Files.uploadFile(context.files, buffer, 'my-file', 'md', 1000)
|
||||||
|
|
||||||
const sharedVault = await Collaboration.createSharedVault(context)
|
const sharedVault = await Collaboration.createSharedVault(context)
|
||||||
const addedFile = await context.vaults.moveItemToVault(sharedVault, uploadedFile)
|
const addedFile = await Collaboration.moveItemToVault(context, sharedVault, uploadedFile)
|
||||||
|
|
||||||
const downloadedBytes = await Files.downloadFile(context.files, addedFile)
|
const downloadedBytes = await Files.downloadFile(context.files, addedFile)
|
||||||
expect(downloadedBytes).to.eql(buffer)
|
expect(downloadedBytes).to.eql(buffer)
|
||||||
@@ -81,7 +81,7 @@ describe('shared vault files', function () {
|
|||||||
const uploadedFile = await Files.uploadFile(context.files, buffer, 'my-file', 'md', 1000, firstVault)
|
const uploadedFile = await Files.uploadFile(context.files, buffer, 'my-file', 'md', 1000, firstVault)
|
||||||
|
|
||||||
const secondVault = await Collaboration.createSharedVault(context)
|
const secondVault = await Collaboration.createSharedVault(context)
|
||||||
const movedFile = await context.vaults.moveItemToVault(secondVault, uploadedFile)
|
const movedFile = await Collaboration.moveItemToVault(context, secondVault, uploadedFile)
|
||||||
|
|
||||||
const downloadedBytes = await Files.downloadFile(context.files, movedFile)
|
const downloadedBytes = await Files.downloadFile(context.files, movedFile)
|
||||||
expect(downloadedBytes).to.eql(buffer)
|
expect(downloadedBytes).to.eql(buffer)
|
||||||
@@ -95,13 +95,13 @@ describe('shared vault files', function () {
|
|||||||
const uploadedFile = await Files.uploadFile(context.files, buffer, 'my-file', 'md', 1000, firstVault)
|
const uploadedFile = await Files.uploadFile(context.files, buffer, 'my-file', 'md', 1000, firstVault)
|
||||||
const privateVault = await Collaboration.createPrivateVault(context)
|
const privateVault = await Collaboration.createPrivateVault(context)
|
||||||
|
|
||||||
const addedFile = await context.vaults.moveItemToVault(privateVault, uploadedFile)
|
const addedFile = await Collaboration.moveItemToVault(context, privateVault, uploadedFile)
|
||||||
|
|
||||||
const downloadedBytes = await Files.downloadFile(context.files, addedFile)
|
const downloadedBytes = await Files.downloadFile(context.files, addedFile)
|
||||||
expect(downloadedBytes).to.eql(buffer)
|
expect(downloadedBytes).to.eql(buffer)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('moving a note to a vault should also moved linked files', async () => {
|
it('should not move a note to a vault that is linked with files ', async () => {
|
||||||
const note = await context.createSyncedNote()
|
const note = await context.createSyncedNote()
|
||||||
const response = await fetch('/mocha/assets/small_file.md')
|
const response = await fetch('/mocha/assets/small_file.md')
|
||||||
const buffer = new Uint8Array(await response.arrayBuffer())
|
const buffer = new Uint8Array(await response.arrayBuffer())
|
||||||
@@ -111,17 +111,12 @@ describe('shared vault files', function () {
|
|||||||
|
|
||||||
const sharedVault = await Collaboration.createSharedVault(context)
|
const sharedVault = await Collaboration.createSharedVault(context)
|
||||||
|
|
||||||
context.vaults.alerts.confirmV2 = () => Promise.resolve(true)
|
context.vaults.alerts.alertV2 = () => Promise.resolve(true)
|
||||||
|
|
||||||
await context.vaults.moveItemToVault(sharedVault, note)
|
await Factory.expectThrowsAsync(
|
||||||
|
() => Collaboration.moveItemToVault(context, sharedVault, note),
|
||||||
const latestFile = context.items.findItem(updatedFile.uuid)
|
'This item is linked to other items that are not in the same vault. Please move those items to this vault first.',
|
||||||
|
)
|
||||||
expect(context.vaults.getItemVault(latestFile).uuid).to.equal(sharedVault.uuid)
|
|
||||||
expect(context.vaults.getItemVault(context.items.findItem(note.uuid)).uuid).to.equal(sharedVault.uuid)
|
|
||||||
|
|
||||||
const downloadedBytes = await Files.downloadFile(context.files, latestFile)
|
|
||||||
expect(downloadedBytes).to.eql(buffer)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should be able to move a file out of its vault', async () => {
|
it('should be able to move a file out of its vault', async () => {
|
||||||
@@ -225,7 +220,7 @@ describe('shared vault files', function () {
|
|||||||
const response = await fetch('/mocha/assets/small_file.md')
|
const response = await fetch('/mocha/assets/small_file.md')
|
||||||
const buffer = new Uint8Array(await response.arrayBuffer())
|
const buffer = new Uint8Array(await response.arrayBuffer())
|
||||||
const uploadedFile = await Files.uploadFile(context.files, buffer, 'my-file', 'md', 1000)
|
const uploadedFile = await Files.uploadFile(context.files, buffer, 'my-file', 'md', 1000)
|
||||||
const addedFile = await context.vaults.moveItemToVault(sharedVault, uploadedFile)
|
const addedFile = await Collaboration.moveItemToVault(context, sharedVault, uploadedFile)
|
||||||
|
|
||||||
await contactContext.sync()
|
await contactContext.sync()
|
||||||
|
|
||||||
|
|||||||
@@ -46,11 +46,29 @@ describe('shared vault revisions', function () {
|
|||||||
await Factory.sleep(Factory.ServerRevisionCreationDelay)
|
await Factory.sleep(Factory.ServerRevisionCreationDelay)
|
||||||
|
|
||||||
const contactItemHistoryOrError = await contactContext.application.listRevisions.execute({ itemUuid: note.uuid })
|
const contactItemHistoryOrError = await contactContext.application.listRevisions.execute({ itemUuid: note.uuid })
|
||||||
const contactItemHistory = contactItemHistoryOrError.getValue()
|
expect(contactItemHistoryOrError.isFailed()).to.equal(false)
|
||||||
|
let contactItemHistory = contactItemHistoryOrError.getValue()
|
||||||
|
if (contactItemHistory.length < 2) {
|
||||||
|
await Factory.sleep(Factory.ServerRevisionCreationDelay, 'Not enough revisions found on the server. This is likely a delay issue. Retrying...')
|
||||||
|
|
||||||
|
const contactItemHistoryOrError = await contactContext.application.listRevisions.execute({ itemUuid: note.uuid })
|
||||||
|
expect(contactItemHistoryOrError.isFailed()).to.equal(false)
|
||||||
|
|
||||||
|
contactItemHistory = contactItemHistoryOrError.getValue()
|
||||||
|
}
|
||||||
expect(contactItemHistory.length >= 2).to.be.true
|
expect(contactItemHistory.length >= 2).to.be.true
|
||||||
|
|
||||||
const itemHistoryOrError = await context.application.listRevisions.execute({ itemUuid: note.uuid })
|
const itemHistoryOrError = await context.application.listRevisions.execute({ itemUuid: note.uuid })
|
||||||
const itemHistory = itemHistoryOrError.getValue()
|
expect(itemHistoryOrError.isFailed()).to.equal(false)
|
||||||
|
let itemHistory = itemHistoryOrError.getValue()
|
||||||
|
if (itemHistory.length < 2) {
|
||||||
|
await Factory.sleep(Factory.ServerRevisionCreationDelay, 'Not enough revisions found on the server. This is likely a delay issue. Retrying...')
|
||||||
|
|
||||||
|
const itemHistoryOrError = await context.application.listRevisions.execute({ itemUuid: note.uuid })
|
||||||
|
expect(itemHistoryOrError.isFailed()).to.equal(false)
|
||||||
|
|
||||||
|
itemHistory = itemHistoryOrError.getValue()
|
||||||
|
}
|
||||||
expect(itemHistory.length >= 2).to.be.true
|
expect(itemHistory.length >= 2).to.be.true
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -67,7 +85,16 @@ describe('shared vault revisions', function () {
|
|||||||
await Factory.sleep(Factory.ServerRevisionCreationDelay)
|
await Factory.sleep(Factory.ServerRevisionCreationDelay)
|
||||||
|
|
||||||
const itemHistoryOrError = await context.application.listRevisions.execute({ itemUuid: note.uuid })
|
const itemHistoryOrError = await context.application.listRevisions.execute({ itemUuid: note.uuid })
|
||||||
const itemHistory = itemHistoryOrError.getValue()
|
expect(itemHistoryOrError.isFailed()).to.equal(false)
|
||||||
|
let itemHistory = itemHistoryOrError.getValue()
|
||||||
|
if (itemHistory.length < 2) {
|
||||||
|
await Factory.sleep(Factory.ServerRevisionCreationDelay, 'Not enough revisions found on the server. This is likely a delay issue. Retrying...')
|
||||||
|
|
||||||
|
const itemHistoryOrError = await context.application.listRevisions.execute({ itemUuid: note.uuid })
|
||||||
|
expect(itemHistoryOrError.isFailed()).to.equal(false)
|
||||||
|
|
||||||
|
itemHistory = itemHistoryOrError.getValue()
|
||||||
|
}
|
||||||
expect(itemHistory.length >= 2).to.be.true
|
expect(itemHistory.length >= 2).to.be.true
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -82,7 +109,16 @@ describe('shared vault revisions', function () {
|
|||||||
await Factory.sleep(Factory.ServerRevisionCreationDelay)
|
await Factory.sleep(Factory.ServerRevisionCreationDelay)
|
||||||
|
|
||||||
const itemHistoryOrError = await contactContext.application.listRevisions.execute({ itemUuid: note.uuid })
|
const itemHistoryOrError = await contactContext.application.listRevisions.execute({ itemUuid: note.uuid })
|
||||||
const itemHistory = itemHistoryOrError.getValue()
|
expect(itemHistoryOrError.isFailed()).to.equal(false)
|
||||||
|
let itemHistory = itemHistoryOrError.getValue()
|
||||||
|
if (itemHistory.length < 1) {
|
||||||
|
await Factory.sleep(Factory.ServerRevisionCreationDelay, 'Not enough revisions found on the server. This is likely a delay issue. Retrying...')
|
||||||
|
|
||||||
|
const itemHistoryOrError = await contactContext.application.listRevisions.execute({ itemUuid: note.uuid })
|
||||||
|
expect(itemHistoryOrError.isFailed()).to.equal(false)
|
||||||
|
|
||||||
|
itemHistory = itemHistoryOrError.getValue()
|
||||||
|
}
|
||||||
const newestRevision = itemHistory[0]
|
const newestRevision = itemHistory[0]
|
||||||
|
|
||||||
const fetchedOrError = await contactContext.application.getRevision.execute({
|
const fetchedOrError = await contactContext.application.getRevision.execute({
|
||||||
@@ -110,9 +146,16 @@ describe('shared vault revisions', function () {
|
|||||||
await Factory.sleep(Factory.ServerRevisionCreationDelay)
|
await Factory.sleep(Factory.ServerRevisionCreationDelay)
|
||||||
|
|
||||||
const itemHistoryOrError = await contactContext.application.listRevisions.execute({ itemUuid: note.uuid })
|
const itemHistoryOrError = await contactContext.application.listRevisions.execute({ itemUuid: note.uuid })
|
||||||
expect(itemHistoryOrError.isFailed()).to.be.false
|
expect(itemHistoryOrError.isFailed()).to.equal(false)
|
||||||
|
let itemHistory = itemHistoryOrError.getValue()
|
||||||
|
if (itemHistory.length != 0) {
|
||||||
|
await Factory.sleep(Factory.ServerRevisionCreationDelay, 'Not enough revisions found on the server. This is likely a delay issue. Retrying...')
|
||||||
|
|
||||||
const itemHistory = itemHistoryOrError.getValue()
|
const itemHistoryOrError = await contactContext.application.listRevisions.execute({ itemUuid: note.uuid })
|
||||||
|
expect(itemHistoryOrError.isFailed()).to.equal(false)
|
||||||
|
|
||||||
|
itemHistory = itemHistoryOrError.getValue()
|
||||||
|
}
|
||||||
expect(itemHistory.length).to.equal(0)
|
expect(itemHistory.length).to.equal(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -127,19 +170,32 @@ describe('shared vault revisions', function () {
|
|||||||
|
|
||||||
await Factory.sleep(Factory.ServerRevisionCreationDelay)
|
await Factory.sleep(Factory.ServerRevisionCreationDelay)
|
||||||
|
|
||||||
let itemHistoryOrError = await contactContext.application.listRevisions.execute({ itemUuid: note.uuid })
|
const itemHistoryBeforeOrError = await contactContext.application.listRevisions.execute({ itemUuid: note.uuid })
|
||||||
expect(itemHistoryOrError.isFailed()).to.be.false
|
expect(itemHistoryBeforeOrError.isFailed()).to.equal(false)
|
||||||
let itemHistory = itemHistoryOrError.getValue()
|
let itemHistoryBefore = itemHistoryBeforeOrError.getValue()
|
||||||
|
if (itemHistoryBefore.length < 1) {
|
||||||
|
await Factory.sleep(Factory.ServerRevisionCreationDelay, 'Not enough revisions found on the server. This is likely a delay issue. Retrying...')
|
||||||
|
|
||||||
expect(itemHistory.length >= 1).to.be.true
|
const itemHistoryOrError = await contactContext.application.listRevisions.execute({ itemUuid: note.uuid })
|
||||||
|
expect(itemHistoryOrError.isFailed()).to.equal(false)
|
||||||
|
|
||||||
|
itemHistoryBefore = itemHistoryOrError.getValue()
|
||||||
|
}
|
||||||
|
expect(itemHistoryBefore.length >= 1).to.be.true
|
||||||
|
|
||||||
await context.vaultUsers.removeUserFromSharedVault(sharedVault, contactContext.userUuid)
|
await context.vaultUsers.removeUserFromSharedVault(sharedVault, contactContext.userUuid)
|
||||||
await Factory.sleep(Factory.ServerRevisionCreationDelay)
|
await Factory.sleep(Factory.ServerRevisionCreationDelay)
|
||||||
|
|
||||||
itemHistoryOrError = await contactContext.application.listRevisions.execute({ itemUuid: note.uuid })
|
const itemHistoryAfterOrError = await contactContext.application.listRevisions.execute({ itemUuid: note.uuid })
|
||||||
expect(itemHistoryOrError.isFailed()).to.be.false
|
let itemHistoryAfter = itemHistoryAfterOrError.getValue()
|
||||||
itemHistory = itemHistoryOrError.getValue()
|
if (itemHistoryAfter.length != 0) {
|
||||||
|
await Factory.sleep(Factory.ServerRevisionCreationDelay, 'Not enough revisions found on the server. This is likely a delay issue. Retrying...')
|
||||||
|
|
||||||
expect(itemHistory.length).to.equal(0)
|
const itemHistoryOrError = await contactContext.application.listRevisions.execute({ itemUuid: note.uuid })
|
||||||
|
expect(itemHistoryOrError.isFailed()).to.equal(false)
|
||||||
|
|
||||||
|
itemHistoryAfter = itemHistoryOrError.getValue()
|
||||||
|
}
|
||||||
|
expect(itemHistoryAfter.length).to.equal(0)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -22,7 +22,10 @@ const VaultMenu = observer(({ items }: { items: DecryptedItemInterface[] }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const item of items) {
|
for (const item of items) {
|
||||||
await application.vaults.moveItemToVault(vault, item)
|
const result = await application.vaults.moveItemToVault(vault, item)
|
||||||
|
if (result.isFailed()) {
|
||||||
|
console.error(result.getError())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[application, items],
|
[application, items],
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import {
|
|||||||
InternalFeatureService,
|
InternalFeatureService,
|
||||||
InternalFeature,
|
InternalFeature,
|
||||||
PreferenceServiceInterface,
|
PreferenceServiceInterface,
|
||||||
|
Result,
|
||||||
} from '@standardnotes/snjs'
|
} from '@standardnotes/snjs'
|
||||||
import { FilesController } from './FilesController'
|
import { FilesController } from './FilesController'
|
||||||
import { ItemListController } from './ItemList/ItemListController'
|
import { ItemListController } from './ItemList/ItemListController'
|
||||||
@@ -246,7 +247,7 @@ describe('LinkingController', () => {
|
|||||||
|
|
||||||
application.mutator.associateFileWithNote = jest.fn().mockReturnValue({})
|
application.mutator.associateFileWithNote = jest.fn().mockReturnValue({})
|
||||||
|
|
||||||
const moveToVaultSpy = (application.vaults.moveItemToVault = jest.fn())
|
const moveToVaultSpy = (application.vaults.moveItemToVault = jest.fn().mockReturnValue(Result.ok()))
|
||||||
|
|
||||||
const note = createNote('test', {
|
const note = createNote('test', {
|
||||||
uuid: 'note',
|
uuid: 'note',
|
||||||
|
|||||||
@@ -213,7 +213,10 @@ export class LinkingController extends AbstractViewController implements Interna
|
|||||||
const noteVault = this.vaults.getItemVault(note)
|
const noteVault = this.vaults.getItemVault(note)
|
||||||
const fileVault = this.vaults.getItemVault(updatedFile)
|
const fileVault = this.vaults.getItemVault(updatedFile)
|
||||||
if (noteVault && !fileVault) {
|
if (noteVault && !fileVault) {
|
||||||
await this.vaults.moveItemToVault(noteVault, file)
|
const result = await this.vaults.moveItemToVault(noteVault, file)
|
||||||
|
if (result.isFailed()) {
|
||||||
|
console.error(result.getError())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -305,10 +308,12 @@ export class LinkingController extends AbstractViewController implements Interna
|
|||||||
const itemVault = this.vaults.getItemVault(activeItem)
|
const itemVault = this.vaults.getItemVault(activeItem)
|
||||||
|
|
||||||
if (itemVault) {
|
if (itemVault) {
|
||||||
const movedTag = await this.vaults.moveItemToVault(itemVault, newTag)
|
const movedTagOrError = await this.vaults.moveItemToVault(itemVault, newTag)
|
||||||
if (!movedTag) {
|
if (movedTagOrError.isFailed()) {
|
||||||
throw new Error('Failed to move tag to item vault')
|
throw new Error(`Failed to move tag to item vault: ${movedTagOrError.getError()}`)
|
||||||
}
|
}
|
||||||
|
const movedTag = movedTagOrError.getValue()
|
||||||
|
|
||||||
await this.addTagToItem(movedTag as SNTag, activeItem)
|
await this.addTagToItem(movedTag as SNTag, activeItem)
|
||||||
} else {
|
} else {
|
||||||
await this.addTagToItem(newTag, activeItem)
|
await this.addTagToItem(newTag, activeItem)
|
||||||
|
|||||||
Reference in New Issue
Block a user