chore: enable vault tests (#2518)

This commit is contained in:
Karol Sójko
2023-09-22 15:09:45 +02:00
committed by GitHub
parent 41ae1dae83
commit c084dcd11e
10 changed files with 116 additions and 51 deletions

View File

@@ -15,6 +15,7 @@ import {
InternalFeatureService,
InternalFeature,
PreferenceServiceInterface,
Result,
} from '@standardnotes/snjs'
import { FilesController } from './FilesController'
import { ItemListController } from './ItemList/ItemListController'
@@ -246,7 +247,7 @@ describe('LinkingController', () => {
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', {
uuid: 'note',

View File

@@ -213,7 +213,10 @@ export class LinkingController extends AbstractViewController implements Interna
const noteVault = this.vaults.getItemVault(note)
const fileVault = this.vaults.getItemVault(updatedFile)
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)
if (itemVault) {
const movedTag = await this.vaults.moveItemToVault(itemVault, newTag)
if (!movedTag) {
throw new Error('Failed to move tag to item vault')
const movedTagOrError = await this.vaults.moveItemToVault(itemVault, newTag)
if (movedTagOrError.isFailed()) {
throw new Error(`Failed to move tag to item vault: ${movedTagOrError.getError()}`)
}
const movedTag = movedTagOrError.getValue()
await this.addTagToItem(movedTag as SNTag, activeItem)
} else {
await this.addTagToItem(newTag, activeItem)