chore: fix ContentType usage (#2353)
* chore: fix ContentType usage * chore: fix specs
This commit is contained in:
@@ -71,7 +71,7 @@ describe('004 protocol operations', function () {
|
||||
it('properly encrypts and decrypts', async function () {
|
||||
const payload = new DecryptedPayload({
|
||||
uuid: '123',
|
||||
content_type: ContentType.ItemsKey,
|
||||
content_type: ContentType.TYPES.ItemsKey,
|
||||
content: FillItemContent({
|
||||
title: 'foo',
|
||||
text: 'bar',
|
||||
@@ -90,7 +90,7 @@ describe('004 protocol operations', function () {
|
||||
it('fails to decrypt non-matching aad', async function () {
|
||||
const payload = new DecryptedPayload({
|
||||
uuid: '123',
|
||||
content_type: ContentType.ItemsKey,
|
||||
content_type: ContentType.TYPES.ItemsKey,
|
||||
content: FillItemContent({
|
||||
title: 'foo',
|
||||
text: 'bar',
|
||||
|
||||
@@ -110,7 +110,7 @@ describe('actions service', () => {
|
||||
|
||||
const payload = new DecryptedPayload({
|
||||
uuid: Utils.generateUuid(),
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
content: {
|
||||
title: 'Testing',
|
||||
},
|
||||
@@ -170,7 +170,7 @@ describe('actions service', () => {
|
||||
})
|
||||
|
||||
// Extension item
|
||||
const extensionItem = await this.application.mutator.createItem(ContentType.ActionsExtension, this.actionsExtension)
|
||||
const extensionItem = await this.application.mutator.createItem(ContentType.TYPES.ActionsExtension, this.actionsExtension)
|
||||
this.extensionItemUuid = extensionItem.uuid
|
||||
})
|
||||
|
||||
@@ -182,7 +182,7 @@ describe('actions service', () => {
|
||||
})
|
||||
|
||||
it('should get extension items', async function () {
|
||||
await this.application.mutator.createItem(ContentType.Note, {
|
||||
await this.application.mutator.createItem(ContentType.TYPES.Note, {
|
||||
title: 'A simple note',
|
||||
text: 'Standard Notes rocks! lml.',
|
||||
})
|
||||
@@ -191,7 +191,7 @@ describe('actions service', () => {
|
||||
})
|
||||
|
||||
it('should get extensions in context of item', async function () {
|
||||
const noteItem = await this.application.mutator.createItem(ContentType.Note, {
|
||||
const noteItem = await this.application.mutator.createItem(ContentType.TYPES.Note, {
|
||||
title: 'Another note',
|
||||
text: 'Whiskey In The Jar',
|
||||
})
|
||||
@@ -202,7 +202,7 @@ describe('actions service', () => {
|
||||
})
|
||||
|
||||
it('should get actions based on item context', async function () {
|
||||
const tagItem = await this.application.mutator.createItem(ContentType.Tag, {
|
||||
const tagItem = await this.application.mutator.createItem(ContentType.TYPES.Tag, {
|
||||
title: 'Music',
|
||||
})
|
||||
|
||||
@@ -214,7 +214,7 @@ describe('actions service', () => {
|
||||
})
|
||||
|
||||
it('should load extension in context of item', async function () {
|
||||
const noteItem = await this.application.mutator.createItem(ContentType.Note, {
|
||||
const noteItem = await this.application.mutator.createItem(ContentType.TYPES.Note, {
|
||||
title: 'Yet another note',
|
||||
text: 'And all things will end ♫',
|
||||
})
|
||||
@@ -246,7 +246,7 @@ describe('actions service', () => {
|
||||
const sandbox = sinon.createSandbox()
|
||||
|
||||
before(async function () {
|
||||
this.noteItem = await this.application.mutator.createItem(ContentType.Note, {
|
||||
this.noteItem = await this.application.mutator.createItem(ContentType.TYPES.Note, {
|
||||
title: 'Hey',
|
||||
text: 'Welcome To Paradise',
|
||||
})
|
||||
@@ -328,7 +328,7 @@ describe('actions service', () => {
|
||||
const sandbox = sinon.createSandbox()
|
||||
|
||||
before(async function () {
|
||||
this.noteItem = await this.application.mutator.createItem(ContentType.Note, {
|
||||
this.noteItem = await this.application.mutator.createItem(ContentType.TYPES.Note, {
|
||||
title: 'Excuse Me',
|
||||
text: 'Time To Be King 8)',
|
||||
})
|
||||
|
||||
@@ -106,7 +106,7 @@ describe('backups', function () {
|
||||
it('backup file item should have correct fields', async function () {
|
||||
await Factory.createSyncedNote(this.application)
|
||||
let backupData = await this.application.createDecryptedBackupFile()
|
||||
let rawItem = backupData.items.find((i) => i.content_type === ContentType.Note)
|
||||
let rawItem = backupData.items.find((i) => i.content_type === ContentType.TYPES.Note)
|
||||
|
||||
expect(rawItem.fields).to.not.be.ok
|
||||
expect(rawItem.source).to.not.be.ok
|
||||
@@ -125,7 +125,7 @@ describe('backups', function () {
|
||||
})
|
||||
|
||||
backupData = await this.application.createEncryptedBackupFileForAutomatedDesktopBackups()
|
||||
rawItem = backupData.items.find((i) => i.content_type === ContentType.Note)
|
||||
rawItem = backupData.items.find((i) => i.content_type === ContentType.TYPES.Note)
|
||||
|
||||
expect(rawItem.fields).to.not.be.ok
|
||||
expect(rawItem.source).to.not.be.ok
|
||||
@@ -195,21 +195,21 @@ describe('backups', function () {
|
||||
|
||||
it('decrypted backup file should not have itemsKeys', async function () {
|
||||
const backup = await this.application.createDecryptedBackupFile()
|
||||
expect(backup.items.some((item) => item.content_type === ContentType.ItemsKey)).to.be.false
|
||||
expect(backup.items.some((item) => item.content_type === ContentType.TYPES.ItemsKey)).to.be.false
|
||||
})
|
||||
|
||||
it('encrypted backup file should have itemsKeys', async function () {
|
||||
await this.application.addPasscode('passcode')
|
||||
const backup = await this.application.createEncryptedBackupFileForAutomatedDesktopBackups()
|
||||
expect(backup.items.some((item) => item.content_type === ContentType.ItemsKey)).to.be.true
|
||||
expect(backup.items.some((item) => item.content_type === ContentType.TYPES.ItemsKey)).to.be.true
|
||||
})
|
||||
|
||||
it('backup file with no account and no passcode should be decrypted', async function () {
|
||||
const note = await Factory.createSyncedNote(this.application)
|
||||
const backup = await this.application.createDecryptedBackupFile()
|
||||
expect(backup).to.not.haveOwnProperty('keyParams')
|
||||
expect(backup.items.some((item) => item.content_type === ContentType.ItemsKey)).to.be.false
|
||||
expect(backup.items.find((item) => item.content_type === ContentType.Note).uuid).to.equal(note.uuid)
|
||||
expect(backup.items.some((item) => item.content_type === ContentType.TYPES.ItemsKey)).to.be.false
|
||||
expect(backup.items.find((item) => item.content_type === ContentType.TYPES.Note).uuid).to.equal(note.uuid)
|
||||
let error
|
||||
try {
|
||||
await this.application.createEncryptedBackupFileForAutomatedDesktopBackups()
|
||||
|
||||
@@ -41,11 +41,11 @@ describe('payload collections', () => {
|
||||
it('references by content type', async () => {
|
||||
const [notePayload1, tagPayload1] = createRelatedNoteTagPairPayload()
|
||||
const collection = ImmutablePayloadCollection.WithPayloads([notePayload1, tagPayload1])
|
||||
const referencingTags = collection.elementsReferencingElement(notePayload1, ContentType.Tag)
|
||||
const referencingTags = collection.elementsReferencingElement(notePayload1, ContentType.TYPES.Tag)
|
||||
expect(referencingTags.length).to.equal(1)
|
||||
expect(referencingTags[0].uuid).to.equal(tagPayload1.uuid)
|
||||
|
||||
const referencingNotes = collection.elementsReferencingElement(notePayload1, ContentType.Note)
|
||||
const referencingNotes = collection.elementsReferencingElement(notePayload1, ContentType.TYPES.Note)
|
||||
expect(referencingNotes.length).to.equal(0)
|
||||
})
|
||||
|
||||
@@ -78,7 +78,7 @@ describe('payload collections', () => {
|
||||
collection.set([payload])
|
||||
collection.set([payload, copy])
|
||||
|
||||
const sorted = collection.all(ContentType.Note)
|
||||
const sorted = collection.all(ContentType.TYPES.Note)
|
||||
expect(sorted.length).to.equal(1)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -84,7 +84,7 @@ describe('features', () => {
|
||||
expect(application.apiService.getUserFeatures.callCount).to.equal(1)
|
||||
expect(application.mutator.createItem.callCount).to.equal(2)
|
||||
|
||||
const themeItems = application.items.getItems(ContentType.Theme)
|
||||
const themeItems = application.items.getItems(ContentType.TYPES.Theme)
|
||||
const systemThemeCount = 1
|
||||
expect(themeItems).to.have.lengthOf(1 + systemThemeCount)
|
||||
expect(themeItems[1].content).to.containSubset(
|
||||
@@ -97,7 +97,7 @@ describe('features', () => {
|
||||
),
|
||||
)
|
||||
|
||||
const editorItems = application.items.getItems(ContentType.Component)
|
||||
const editorItems = application.items.getItems(ContentType.TYPES.Component)
|
||||
expect(editorItems).to.have.lengthOf(1)
|
||||
expect(editorItems[0].content).to.containSubset(
|
||||
JSON.parse(
|
||||
@@ -118,7 +118,7 @@ describe('features', () => {
|
||||
await application.featuresService.setOnlineRoles([])
|
||||
// Create pre-existing item for theme without all the info
|
||||
await application.mutator.createItem(
|
||||
ContentType.Theme,
|
||||
ContentType.TYPES.Theme,
|
||||
FillItemContent({
|
||||
package_info: {
|
||||
identifier: FeatureIdentifier.MidnightTheme,
|
||||
@@ -130,7 +130,7 @@ describe('features', () => {
|
||||
// Timeout since we don't await for features update
|
||||
await new Promise((resolve) => setTimeout(resolve, 1000))
|
||||
expect(application.mutator.changeComponent.callCount).to.equal(1)
|
||||
const themeItems = application.items.getItems(ContentType.Theme)
|
||||
const themeItems = application.items.getItems(ContentType.TYPES.Theme)
|
||||
expect(themeItems).to.have.lengthOf(1)
|
||||
expect(themeItems[0].content).to.containSubset(
|
||||
JSON.parse(
|
||||
@@ -161,7 +161,7 @@ describe('features', () => {
|
||||
})
|
||||
|
||||
const themeItem = application.items
|
||||
.getItems(ContentType.Theme)
|
||||
.getItems(ContentType.TYPES.Theme)
|
||||
.find((theme) => theme.identifier === midnightThemeFeature.identifier)
|
||||
|
||||
// Wipe roles from initial sync
|
||||
@@ -177,7 +177,7 @@ describe('features', () => {
|
||||
)
|
||||
|
||||
const noTheme = application.items
|
||||
.getItems(ContentType.Theme)
|
||||
.getItems(ContentType.TYPES.Theme)
|
||||
.find((theme) => theme.identifier === midnightThemeFeature.identifier)
|
||||
expect(noTheme).to.not.be.ok
|
||||
})
|
||||
@@ -203,7 +203,7 @@ describe('features', () => {
|
||||
})
|
||||
|
||||
await application.mutator.createItem(
|
||||
ContentType.ExtensionRepo,
|
||||
ContentType.TYPES.ExtensionRepo,
|
||||
FillItemContent({
|
||||
url: `https://extensions.standardnotes.org/${extensionKey}`,
|
||||
}),
|
||||
@@ -225,7 +225,7 @@ describe('features', () => {
|
||||
.callsFake(() => {})
|
||||
const extensionKey = UuidGenerator.GenerateUuid().split('-').join('')
|
||||
await application.mutator.createItem(
|
||||
ContentType.ExtensionRepo,
|
||||
ContentType.TYPES.ExtensionRepo,
|
||||
FillItemContent({
|
||||
url: `https://extensions.standardnotes.org/${extensionKey}`,
|
||||
}),
|
||||
@@ -256,7 +256,7 @@ describe('features', () => {
|
||||
})
|
||||
const extensionKey = UuidGenerator.GenerateUuid().split('-').join('')
|
||||
await application.mutator.createItem(
|
||||
ContentType.ExtensionRepo,
|
||||
ContentType.TYPES.ExtensionRepo,
|
||||
FillItemContent({
|
||||
url: `https://extensions.standardnotes.org/${extensionKey}`,
|
||||
}),
|
||||
@@ -282,7 +282,7 @@ describe('features', () => {
|
||||
expect(await application.settings.getDoesSensitiveSettingExist(SettingName.ExtensionKey)).to.equal(false)
|
||||
const extensionKey = UuidGenerator.GenerateUuid().split('-').join('')
|
||||
const promise = new Promise((resolve) => {
|
||||
application.streamItems(ContentType.ExtensionRepo, ({ changed }) => {
|
||||
application.streamItems(ContentType.TYPES.ExtensionRepo, ({ changed }) => {
|
||||
for (const item of changed) {
|
||||
if (item.content.migratedToUserSetting) {
|
||||
resolve()
|
||||
@@ -291,7 +291,7 @@ describe('features', () => {
|
||||
})
|
||||
})
|
||||
await application.mutator.createItem(
|
||||
ContentType.ExtensionRepo,
|
||||
ContentType.TYPES.ExtensionRepo,
|
||||
FillItemContent({
|
||||
url: `https://extensions.standardnotes.org/${extensionKey}`,
|
||||
}),
|
||||
@@ -305,7 +305,7 @@ describe('features', () => {
|
||||
application = await Factory.signOutApplicationAndReturnNew(application)
|
||||
const extensionKey = UuidGenerator.GenerateUuid().split('-').join('')
|
||||
await application.mutator.createItem(
|
||||
ContentType.ExtensionRepo,
|
||||
ContentType.TYPES.ExtensionRepo,
|
||||
FillItemContent({
|
||||
url: `https://extensions.standardnotes.org/${extensionKey}`,
|
||||
}),
|
||||
|
||||
@@ -97,7 +97,7 @@ describe('history manager', () => {
|
||||
it('creating new item and making 1 change should create 0 revisions', async function () {
|
||||
const context = await Factory.createAppContext()
|
||||
await context.launch()
|
||||
const item = await context.application.items.createTemplateItem(ContentType.Note, {
|
||||
const item = await context.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
references: [],
|
||||
})
|
||||
await context.application.mutator.insertItem(item)
|
||||
|
||||
@@ -9,7 +9,7 @@ describe('item', () => {
|
||||
this.createBarePayload = () => {
|
||||
return new DecryptedPayload({
|
||||
uuid: '123',
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
content: {
|
||||
title: 'hello',
|
||||
},
|
||||
@@ -30,7 +30,7 @@ describe('item', () => {
|
||||
return new SNTag(
|
||||
new DecryptedPayload({
|
||||
uuid: Factory.generateUuidish(),
|
||||
content_type: ContentType.Tag,
|
||||
content_type: ContentType.TYPES.Tag,
|
||||
content: {
|
||||
title: 'thoughts',
|
||||
references: references,
|
||||
|
||||
@@ -25,7 +25,7 @@ describe('item manager', function () {
|
||||
})
|
||||
|
||||
const createNote = async () => {
|
||||
return application.mutator.createItem(ContentType.Note, {
|
||||
return application.mutator.createItem(ContentType.TYPES.Note, {
|
||||
title: 'hello',
|
||||
text: 'world',
|
||||
})
|
||||
@@ -38,7 +38,7 @@ describe('item manager', function () {
|
||||
content_type: note.content_type,
|
||||
}
|
||||
})
|
||||
return application.mutator.createItem(ContentType.Tag, {
|
||||
return application.mutator.createItem(ContentType.TYPES.Tag, {
|
||||
title: 'thoughts',
|
||||
references: references,
|
||||
})
|
||||
@@ -110,7 +110,7 @@ describe('item manager', function () {
|
||||
|
||||
it('observer', async function () {
|
||||
const observed = []
|
||||
application.items.addObserver(ContentType.Any, ({ changed, inserted, removed, source, sourceKey }) => {
|
||||
application.items.addObserver(ContentType.TYPES.Any, ({ changed, inserted, removed, source, sourceKey }) => {
|
||||
observed.push({ changed, inserted, removed, source, sourceKey })
|
||||
})
|
||||
const note = await createNote()
|
||||
@@ -184,7 +184,7 @@ describe('item manager', function () {
|
||||
|
||||
it('remove all items from memory', async function () {
|
||||
const observed = []
|
||||
application.items.addObserver(ContentType.Any, ({ changed, inserted, removed, ignored }) => {
|
||||
application.items.addObserver(ContentType.TYPES.Any, ({ changed, inserted, removed, ignored }) => {
|
||||
observed.push({ changed, inserted, removed, ignored })
|
||||
})
|
||||
await createNote()
|
||||
@@ -197,7 +197,7 @@ describe('item manager', function () {
|
||||
|
||||
it('remove item locally', async function () {
|
||||
const observed = []
|
||||
application.items.addObserver(ContentType.Any, ({ changed, inserted, removed, ignored }) => {
|
||||
application.items.addObserver(ContentType.TYPES.Any, ({ changed, inserted, removed, ignored }) => {
|
||||
observed.push({ changed, inserted, removed, ignored })
|
||||
})
|
||||
const note = await createNote()
|
||||
@@ -220,7 +220,7 @@ describe('item manager', function () {
|
||||
const changedTitle = 'changed title'
|
||||
let didEmit = false
|
||||
let latestVersion
|
||||
application.items.addObserver(ContentType.Note, ({ changed, inserted }) => {
|
||||
application.items.addObserver(ContentType.TYPES.Note, ({ changed, inserted }) => {
|
||||
const all = changed.concat(inserted)
|
||||
if (!didEmit) {
|
||||
didEmit = true
|
||||
|
||||
@@ -272,7 +272,7 @@ describe('key recovery service', function () {
|
||||
const result = await contextB.application.changePassword(contextA.password, newPassword)
|
||||
|
||||
expect(result.error).to.not.be.ok
|
||||
expect(contextB.application.items.getAnyItems(ContentType.ItemsKey).length).to.equal(2)
|
||||
expect(contextB.application.items.getAnyItems(ContentType.TYPES.ItemsKey).length).to.equal(2)
|
||||
|
||||
const newItemsKey = contextB.application.items
|
||||
.getDisplayableItemsKeys()
|
||||
@@ -288,7 +288,7 @@ describe('key recovery service', function () {
|
||||
await recoveryPromise
|
||||
|
||||
/** Same previously errored key should now no longer be errored, */
|
||||
expect(contextA.application.items.getAnyItems(ContentType.ItemsKey).length).to.equal(2)
|
||||
expect(contextA.application.items.getAnyItems(ContentType.TYPES.ItemsKey).length).to.equal(2)
|
||||
for (const key of contextA.application.itemManager.getDisplayableItemsKeys()) {
|
||||
expect(key.errorDecrypting).to.not.be.ok
|
||||
}
|
||||
@@ -321,7 +321,7 @@ describe('key recovery service', function () {
|
||||
password: contextA.password,
|
||||
})
|
||||
|
||||
expect(appA.items.getItems(ContentType.ItemsKey).length).to.equal(1)
|
||||
expect(appA.items.getItems(ContentType.TYPES.ItemsKey).length).to.equal(1)
|
||||
|
||||
/** Create simultaneous appB signed into same account */
|
||||
const appB = await Factory.createApplicationWithFakeCrypto('another-namespace')
|
||||
|
||||
@@ -33,10 +33,10 @@ describe('keys', function () {
|
||||
})
|
||||
|
||||
it('validates content types requiring root encryption', function () {
|
||||
expect(ContentTypeUsesRootKeyEncryption(ContentType.ItemsKey)).to.equal(true)
|
||||
expect(ContentTypeUsesRootKeyEncryption(ContentType.EncryptedStorage)).to.equal(true)
|
||||
expect(ContentTypeUsesRootKeyEncryption(ContentType.Item)).to.equal(false)
|
||||
expect(ContentTypeUsesRootKeyEncryption(ContentType.Note)).to.equal(false)
|
||||
expect(ContentTypeUsesRootKeyEncryption(ContentType.TYPES.ItemsKey)).to.equal(true)
|
||||
expect(ContentTypeUsesRootKeyEncryption(ContentType.TYPES.EncryptedStorage)).to.equal(true)
|
||||
expect(ContentTypeUsesRootKeyEncryption(ContentType.TYPES.Item)).to.equal(false)
|
||||
expect(ContentTypeUsesRootKeyEncryption(ContentType.TYPES.Note)).to.equal(false)
|
||||
})
|
||||
|
||||
it('generating export params with no account or passcode should produce encrypted payload', async function () {
|
||||
@@ -126,7 +126,7 @@ describe('keys', function () {
|
||||
await this.application.sync.sync()
|
||||
|
||||
const rawPayloads = await this.application.diskStorageService.getAllRawPayloads()
|
||||
const rawNotePayload = rawPayloads.find((r) => r.content_type === ContentType.Note)
|
||||
const rawNotePayload = rawPayloads.find((r) => r.content_type === ContentType.TYPES.Note)
|
||||
expect(typeof rawNotePayload.content).to.equal('string')
|
||||
})
|
||||
|
||||
@@ -143,7 +143,7 @@ describe('keys', function () {
|
||||
it('should use items key for encryption of note', async function () {
|
||||
const notePayload = Factory.createNotePayload()
|
||||
const keyToUse = await this.application.encryptionService.itemsEncryption.keyToUseForItemEncryption(notePayload)
|
||||
expect(keyToUse.content_type).to.equal(ContentType.ItemsKey)
|
||||
expect(keyToUse.content_type).to.equal(ContentType.TYPES.ItemsKey)
|
||||
})
|
||||
|
||||
it('encrypting an item should associate an items key to it', async function () {
|
||||
@@ -848,7 +848,7 @@ describe('keys', function () {
|
||||
password: this.password,
|
||||
})
|
||||
await Factory.createSyncedNote(this.application)
|
||||
const itemsKey = this.application.items.getItems(ContentType.ItemsKey)[0]
|
||||
const itemsKey = this.application.items.getItems(ContentType.TYPES.ItemsKey)[0]
|
||||
|
||||
/** Create another client and sign into account */
|
||||
await Factory.loginToApplication({
|
||||
@@ -862,7 +862,7 @@ describe('keys', function () {
|
||||
expect(defaultKeys.length).to.equal(1)
|
||||
|
||||
const rawPayloads = await otherClient.diskStorageService.getAllRawPayloads()
|
||||
const notePayload = rawPayloads.find((p) => p.content_type === ContentType.Note)
|
||||
const notePayload = rawPayloads.find((p) => p.content_type === ContentType.TYPES.Note)
|
||||
|
||||
expect(notePayload.items_key_id).to.equal(itemsKey.uuid)
|
||||
})
|
||||
|
||||
@@ -415,7 +415,7 @@ export class AppContext {
|
||||
if (!didCompleteRelevantSync) {
|
||||
if (data?.savedPayloads) {
|
||||
const matching = data.savedPayloads.find((p) => {
|
||||
return p.content_type === ContentType.UserPrefs
|
||||
return p.content_type === ContentType.TYPES.UserPrefs
|
||||
})
|
||||
if (matching) {
|
||||
didCompleteRelevantSync = true
|
||||
@@ -510,7 +510,7 @@ export class AppContext {
|
||||
}
|
||||
|
||||
spyOnChangedItems(callback) {
|
||||
this.application.items.addObserver(ContentType.Any, ({ changed, unerrored }) => {
|
||||
this.application.items.addObserver(ContentType.TYPES.Any, ({ changed, unerrored }) => {
|
||||
callback([...changed, ...unerrored])
|
||||
})
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ export function createItemParams(contentType) {
|
||||
export function createNoteParams({ title, text, dirty = true } = {}) {
|
||||
const params = {
|
||||
uuid: Utils.generateUuid(),
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
dirty: dirty,
|
||||
dirtyIndex: dirty ? getIncrementedDirtyIndex() : undefined,
|
||||
content: FillItemContent({
|
||||
@@ -34,7 +34,7 @@ export function createNoteParams({ title, text, dirty = true } = {}) {
|
||||
export function createTagParams({ title, dirty = true, uuid = undefined } = {}) {
|
||||
const params = {
|
||||
uuid: uuid || Utils.generateUuid(),
|
||||
content_type: ContentType.Tag,
|
||||
content_type: ContentType.TYPES.Tag,
|
||||
dirty: dirty,
|
||||
dirtyIndex: dirty ? getIncrementedDirtyIndex() : undefined,
|
||||
content: FillItemContent({
|
||||
|
||||
@@ -99,7 +99,7 @@ describe('migrations', () => {
|
||||
const noDistractionItem = CreateDecryptedItemFromPayload(
|
||||
new DecryptedPayload({
|
||||
uuid: '123',
|
||||
content_type: ContentType.Theme,
|
||||
content_type: ContentType.TYPES.Theme,
|
||||
content: FillItemContent({
|
||||
package_info: {
|
||||
identifier: 'org.standardnotes.theme-no-distraction',
|
||||
@@ -111,14 +111,14 @@ describe('migrations', () => {
|
||||
await application.sync.sync()
|
||||
|
||||
const systemThemeCount = 1
|
||||
expect(application.items.getItems(ContentType.Theme).length).to.equal(1 + systemThemeCount)
|
||||
expect(application.items.getItems(ContentType.TYPES.Theme).length).to.equal(1 + systemThemeCount)
|
||||
|
||||
/** Run migration */
|
||||
const migration = new Migration2_42_0(application.migrationService.services)
|
||||
await migration.handleStage(ApplicationStage.FullSyncCompleted_13)
|
||||
await application.sync.sync()
|
||||
|
||||
expect(application.items.getItems(ContentType.Theme).length).to.equal(systemThemeCount)
|
||||
expect(application.items.getItems(ContentType.TYPES.Theme).length).to.equal(systemThemeCount)
|
||||
|
||||
await Factory.safeDeinit(application)
|
||||
})
|
||||
|
||||
@@ -361,11 +361,11 @@ describe('app models', () => {
|
||||
|
||||
it('maintains editor reference when duplicating note', async function () {
|
||||
const editor = await this.application.mutator.createItem(
|
||||
ContentType.Component,
|
||||
ContentType.TYPES.Component,
|
||||
{ area: ComponentArea.Editor, package_info: { identifier: 'foo-editor' } },
|
||||
true,
|
||||
)
|
||||
const note = await Factory.insertItemWithOverride(this.application, ContentType.Note, {
|
||||
const note = await Factory.insertItemWithOverride(this.application, ContentType.TYPES.Note, {
|
||||
editorIdentifier: 'foo-editor',
|
||||
})
|
||||
|
||||
|
||||
@@ -73,8 +73,8 @@ describe('importing', function () {
|
||||
|
||||
await application.mutator.emitItemsFromPayloads([notePayload, tagPayload], PayloadEmitSource.LocalChanged)
|
||||
expectedItemCount += 2
|
||||
const note = application.itemManager.getItems([ContentType.Note])[0]
|
||||
const tag = application.itemManager.getItems([ContentType.Tag])[0]
|
||||
const note = application.itemManager.getItems([ContentType.TYPES.Note])[0]
|
||||
const tag = application.itemManager.getItems([ContentType.TYPES.Tag])[0]
|
||||
|
||||
expect(tag.content.references.length).to.equal(1)
|
||||
expect(tag.noteCount).to.equal(1)
|
||||
@@ -352,8 +352,8 @@ describe('importing', function () {
|
||||
|
||||
const storedPayloads = await application.diskStorageService.getAllRawPayloads()
|
||||
expect(application.itemManager.items.length).to.equal(storedPayloads.length)
|
||||
const notes = storedPayloads.filter((p) => p.content_type === ContentType.Note)
|
||||
const itemsKeys = storedPayloads.filter((p) => p.content_type === ContentType.ItemsKey)
|
||||
const notes = storedPayloads.filter((p) => p.content_type === ContentType.TYPES.Note)
|
||||
const itemsKeys = storedPayloads.filter((p) => p.content_type === ContentType.TYPES.ItemsKey)
|
||||
expect(notes.length).to.equal(1)
|
||||
expect(itemsKeys.length).to.equal(1)
|
||||
})
|
||||
@@ -449,7 +449,7 @@ describe('importing', function () {
|
||||
version: oldVersion,
|
||||
})
|
||||
|
||||
const noteItem = await application.mutator.createItem(ContentType.Note, {
|
||||
const noteItem = await application.mutator.createItem(ContentType.TYPES.Note, {
|
||||
title: 'Encrypted note',
|
||||
text: 'On protocol version 003.',
|
||||
})
|
||||
@@ -530,7 +530,7 @@ describe('importing', function () {
|
||||
password: password,
|
||||
})
|
||||
|
||||
const noteItem = await application.mutator.createItem(ContentType.Note, {
|
||||
const noteItem = await application.mutator.createItem(ContentType.TYPES.Note, {
|
||||
title: 'Encrypted note',
|
||||
text: 'On protocol version 004.',
|
||||
})
|
||||
@@ -560,7 +560,7 @@ describe('importing', function () {
|
||||
password: password,
|
||||
})
|
||||
|
||||
const noteItem = await application.mutator.createItem(ContentType.Note, {
|
||||
const noteItem = await application.mutator.createItem(ContentType.TYPES.Note, {
|
||||
title: 'This is a valid, encrypted note',
|
||||
text: 'On protocol version 004.',
|
||||
})
|
||||
@@ -598,7 +598,7 @@ describe('importing', function () {
|
||||
version: oldVersion,
|
||||
})
|
||||
|
||||
await application.mutator.createItem(ContentType.Note, {
|
||||
await application.mutator.createItem(ContentType.TYPES.Note, {
|
||||
title: 'Encrypted note',
|
||||
text: 'On protocol version 003.',
|
||||
})
|
||||
@@ -635,7 +635,7 @@ describe('importing', function () {
|
||||
password: password,
|
||||
})
|
||||
|
||||
await application.mutator.createItem(ContentType.Note, {
|
||||
await application.mutator.createItem(ContentType.TYPES.Note, {
|
||||
title: 'This is a valid, encrypted note',
|
||||
text: 'On protocol version 004.',
|
||||
})
|
||||
@@ -666,7 +666,7 @@ describe('importing', function () {
|
||||
password: password,
|
||||
})
|
||||
|
||||
await application.mutator.createItem(ContentType.Note, {
|
||||
await application.mutator.createItem(ContentType.TYPES.Note, {
|
||||
title: 'Encrypted note',
|
||||
text: 'On protocol version 004.',
|
||||
})
|
||||
@@ -691,13 +691,13 @@ describe('importing', function () {
|
||||
})
|
||||
Factory.handlePasswordChallenges(application, password)
|
||||
|
||||
await application.mutator.createItem(ContentType.Note, {
|
||||
await application.mutator.createItem(ContentType.TYPES.Note, {
|
||||
title: 'Encrypted note',
|
||||
text: 'On protocol version 004.',
|
||||
})
|
||||
|
||||
const backupData = await application.createEncryptedBackupFileForAutomatedDesktopBackups()
|
||||
backupData.items = backupData.items.filter((payload) => payload.content_type !== ContentType.ItemsKey)
|
||||
backupData.items = backupData.items.filter((payload) => payload.content_type !== ContentType.TYPES.ItemsKey)
|
||||
|
||||
await Factory.safeDeinit(application)
|
||||
application = await Factory.createInitAppWithFakeCrypto()
|
||||
|
||||
@@ -118,7 +118,7 @@ describe('model manager mapping', () => {
|
||||
await this.application.mutator.emitItemsFromPayloads([payload], PayloadEmitSource.LocalChanged)
|
||||
const item = this.application.itemManager.items[0]
|
||||
return new Promise((resolve) => {
|
||||
this.application.itemManager.addObserver(ContentType.Any, ({ changed }) => {
|
||||
this.application.itemManager.addObserver(ContentType.TYPES.Any, ({ changed }) => {
|
||||
expect(changed[0].uuid === item.uuid)
|
||||
resolve()
|
||||
})
|
||||
|
||||
@@ -26,14 +26,14 @@ describe('notes and tags', () => {
|
||||
it('uses proper class for note', async function () {
|
||||
const payload = Factory.createNotePayload()
|
||||
await this.application.mutator.emitItemFromPayload(payload, PayloadEmitSource.LocalChanged)
|
||||
const note = this.application.itemManager.getItems([ContentType.Note])[0]
|
||||
const note = this.application.itemManager.getItems([ContentType.TYPES.Note])[0]
|
||||
expect(note.constructor === SNNote).to.equal(true)
|
||||
})
|
||||
|
||||
it('properly constructs syncing params', async function () {
|
||||
const title = 'Foo'
|
||||
const text = 'Bar'
|
||||
const note = await this.application.items.createTemplateItem(ContentType.Note, {
|
||||
const note = await this.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title,
|
||||
text,
|
||||
})
|
||||
@@ -41,7 +41,7 @@ describe('notes and tags', () => {
|
||||
expect(note.content.title).to.equal(title)
|
||||
expect(note.content.text).to.equal(text)
|
||||
|
||||
const tag = await this.application.items.createTemplateItem(ContentType.Tag, {
|
||||
const tag = await this.application.items.createTemplateItem(ContentType.TYPES.Tag, {
|
||||
title,
|
||||
})
|
||||
|
||||
@@ -74,8 +74,8 @@ describe('notes and tags', () => {
|
||||
})
|
||||
|
||||
await this.application.mutator.emitItemsFromPayloads([mutatedNote, mutatedTag], PayloadEmitSource.LocalChanged)
|
||||
const note = this.application.itemManager.getItems([ContentType.Note])[0]
|
||||
const tag = this.application.itemManager.getItems([ContentType.Tag])[0]
|
||||
const note = this.application.itemManager.getItems([ContentType.TYPES.Note])[0]
|
||||
const tag = this.application.itemManager.getItems([ContentType.TYPES.Tag])[0]
|
||||
|
||||
expect(note.content.references.length).to.equal(1)
|
||||
expect(this.application.itemManager.itemsReferencingItem(tag).length).to.equal(1)
|
||||
@@ -131,8 +131,8 @@ describe('notes and tags', () => {
|
||||
const tagPayload = pair[1]
|
||||
|
||||
await this.application.mutator.emitItemsFromPayloads(pair, PayloadEmitSource.LocalChanged)
|
||||
let note = this.application.itemManager.getItems([ContentType.Note])[0]
|
||||
let tag = this.application.itemManager.getItems([ContentType.Tag])[0]
|
||||
let note = this.application.itemManager.getItems([ContentType.TYPES.Note])[0]
|
||||
let tag = this.application.itemManager.getItems([ContentType.TYPES.Tag])[0]
|
||||
|
||||
expect(note.content.references.length).to.equal(0)
|
||||
expect(tag.content.references.length).to.equal(1)
|
||||
@@ -178,8 +178,8 @@ describe('notes and tags', () => {
|
||||
const tagPayload = pair[1]
|
||||
|
||||
await this.application.mutator.emitItemsFromPayloads([notePayload, tagPayload], PayloadEmitSource.LocalChanged)
|
||||
const note = this.application.itemManager.getItems([ContentType.Note])[0]
|
||||
let tag = this.application.itemManager.getItems([ContentType.Tag])[0]
|
||||
const note = this.application.itemManager.getItems([ContentType.TYPES.Note])[0]
|
||||
let tag = this.application.itemManager.getItems([ContentType.TYPES.Tag])[0]
|
||||
|
||||
expect(note.content.references.length).to.equal(0)
|
||||
expect(tag.content.references.length).to.equal(1)
|
||||
@@ -233,7 +233,7 @@ describe('notes and tags', () => {
|
||||
const notePayload = pair[0]
|
||||
const tagPayload = pair[1]
|
||||
await this.application.mutator.emitItemsFromPayloads([notePayload, tagPayload], PayloadEmitSource.LocalChanged)
|
||||
const note = this.application.itemManager.getItems([ContentType.Note])[0]
|
||||
const note = this.application.itemManager.getItems([ContentType.TYPES.Note])[0]
|
||||
const duplicateNote = await this.application.mutator.duplicateItem(note, true)
|
||||
expect(note.uuid).to.not.equal(duplicateNote.uuid)
|
||||
|
||||
@@ -247,8 +247,8 @@ describe('notes and tags', () => {
|
||||
const notePayload = pair[0]
|
||||
const tagPayload = pair[1]
|
||||
await this.application.mutator.emitItemsFromPayloads([notePayload, tagPayload], PayloadEmitSource.LocalChanged)
|
||||
const note = this.application.itemManager.getItems([ContentType.Note])[0]
|
||||
let tag = this.application.itemManager.getItems([ContentType.Tag])[0]
|
||||
const note = this.application.itemManager.getItems([ContentType.TYPES.Note])[0]
|
||||
let tag = this.application.itemManager.getItems([ContentType.TYPES.Tag])[0]
|
||||
|
||||
expect(tag.content.references.length).to.equal(1)
|
||||
expect(tag.noteCount).to.equal(1)
|
||||
@@ -264,7 +264,7 @@ describe('notes and tags', () => {
|
||||
it('modifying item content should not modify payload content', async function () {
|
||||
const notePayload = Factory.createNotePayload()
|
||||
await this.application.mutator.emitItemsFromPayloads([notePayload], PayloadEmitSource.LocalChanged)
|
||||
let note = this.application.itemManager.getItems([ContentType.Note])[0]
|
||||
let note = this.application.itemManager.getItems([ContentType.TYPES.Note])[0]
|
||||
note = await this.application.changeAndSaveItem(
|
||||
note,
|
||||
(mutator) => {
|
||||
@@ -286,8 +286,8 @@ describe('notes and tags', () => {
|
||||
const tagPayload = pair[1]
|
||||
|
||||
await this.application.mutator.emitItemsFromPayloads([notePayload, tagPayload], PayloadEmitSource.LocalChanged)
|
||||
let note = this.application.itemManager.getItems([ContentType.Note])[0]
|
||||
let tag = this.application.itemManager.getItems([ContentType.Tag])[0]
|
||||
let note = this.application.itemManager.getItems([ContentType.TYPES.Note])[0]
|
||||
let tag = this.application.itemManager.getItems([ContentType.TYPES.Tag])[0]
|
||||
|
||||
await this.application.syncService.sync(syncOptions)
|
||||
await this.application.mutator.setItemToBeDeleted(tag)
|
||||
@@ -302,7 +302,7 @@ describe('notes and tags', () => {
|
||||
await Promise.all(
|
||||
['Y', 'Z', 'A', 'B'].map(async (title) => {
|
||||
return this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.Note, { title }),
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.Note, { title }),
|
||||
)
|
||||
}),
|
||||
)
|
||||
@@ -316,7 +316,7 @@ describe('notes and tags', () => {
|
||||
})
|
||||
|
||||
it('setting a note dirty should collapse its properties into content', async function () {
|
||||
let note = await this.application.items.createTemplateItem(ContentType.Note, {
|
||||
let note = await this.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title: 'Foo',
|
||||
})
|
||||
await this.application.mutator.insertItem(note)
|
||||
@@ -339,7 +339,7 @@ describe('notes and tags', () => {
|
||||
mutator.e2ePendingRefactor_addItemAsRelationship(taggedNote)
|
||||
})
|
||||
await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.Note, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title: 'A',
|
||||
}),
|
||||
)
|
||||
@@ -379,7 +379,7 @@ describe('notes and tags', () => {
|
||||
await Promise.all(
|
||||
['Y', 'Z', 'A', 'B'].map(async (title) => {
|
||||
return this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.Note, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title,
|
||||
}),
|
||||
)
|
||||
@@ -413,17 +413,17 @@ describe('notes and tags', () => {
|
||||
describe('Smart views', function () {
|
||||
it('"title", "startsWith", "Foo"', async function () {
|
||||
const note = await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.Note, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title: 'Foo 🎲',
|
||||
}),
|
||||
)
|
||||
await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.Note, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title: 'Not Foo 🎲',
|
||||
}),
|
||||
)
|
||||
const view = await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.SmartView, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.SmartView, {
|
||||
title: 'Foo Notes',
|
||||
predicate: {
|
||||
keypath: 'title',
|
||||
@@ -447,7 +447,7 @@ describe('notes and tags', () => {
|
||||
|
||||
it('"pinned", "=", true', async function () {
|
||||
const note = await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.Note, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title: 'A',
|
||||
}),
|
||||
)
|
||||
@@ -455,13 +455,13 @@ describe('notes and tags', () => {
|
||||
mutator.pinned = true
|
||||
})
|
||||
await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.Note, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title: 'B',
|
||||
pinned: false,
|
||||
}),
|
||||
)
|
||||
const view = await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.SmartView, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.SmartView, {
|
||||
title: 'Pinned',
|
||||
predicate: {
|
||||
keypath: 'pinned',
|
||||
@@ -485,7 +485,7 @@ describe('notes and tags', () => {
|
||||
|
||||
it('"pinned", "=", false', async function () {
|
||||
const pinnedNote = await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.Note, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title: 'A',
|
||||
}),
|
||||
)
|
||||
@@ -493,12 +493,12 @@ describe('notes and tags', () => {
|
||||
mutator.pinned = true
|
||||
})
|
||||
const unpinnedNote = await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.Note, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title: 'B',
|
||||
}),
|
||||
)
|
||||
const view = await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.SmartView, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.SmartView, {
|
||||
title: 'Not pinned',
|
||||
predicate: {
|
||||
keypath: 'pinned',
|
||||
@@ -522,19 +522,19 @@ describe('notes and tags', () => {
|
||||
|
||||
it('"text.length", ">", 500', async function () {
|
||||
const longNote = await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.Note, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title: 'A',
|
||||
text: Array(501).fill(0).join(''),
|
||||
}),
|
||||
)
|
||||
await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.Note, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title: 'B',
|
||||
text: 'b',
|
||||
}),
|
||||
)
|
||||
const view = await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.SmartView, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.SmartView, {
|
||||
title: 'Long',
|
||||
predicate: {
|
||||
keypath: 'text.length',
|
||||
@@ -563,7 +563,7 @@ describe('notes and tags', () => {
|
||||
})
|
||||
|
||||
const recentNote = await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.Note, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title: 'A',
|
||||
}),
|
||||
true,
|
||||
@@ -572,7 +572,7 @@ describe('notes and tags', () => {
|
||||
await this.application.sync.sync()
|
||||
|
||||
const olderNote = await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.Note, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title: 'B',
|
||||
text: 'b',
|
||||
}),
|
||||
@@ -584,13 +584,13 @@ describe('notes and tags', () => {
|
||||
|
||||
/** Create an unsynced note which shouldn't get an updated_at */
|
||||
await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.Note, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title: 'B',
|
||||
text: 'b',
|
||||
}),
|
||||
)
|
||||
const view = await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.SmartView, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.SmartView, {
|
||||
title: 'One day ago',
|
||||
predicate: {
|
||||
keypath: 'serverUpdatedAt',
|
||||
@@ -614,7 +614,7 @@ describe('notes and tags', () => {
|
||||
|
||||
it('"tags.length", "=", 0', async function () {
|
||||
const untaggedNote = await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.Note, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title: 'A',
|
||||
}),
|
||||
)
|
||||
@@ -625,7 +625,7 @@ describe('notes and tags', () => {
|
||||
})
|
||||
|
||||
const view = await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.SmartView, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.SmartView, {
|
||||
title: 'Untagged',
|
||||
predicate: {
|
||||
keypath: 'tags.length',
|
||||
@@ -653,13 +653,13 @@ describe('notes and tags', () => {
|
||||
mutator.e2ePendingRefactor_addItemAsRelationship(taggedNote)
|
||||
})
|
||||
await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.Note, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title: 'A',
|
||||
}),
|
||||
)
|
||||
|
||||
const view = await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.SmartView, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.SmartView, {
|
||||
title: 'B-tags',
|
||||
predicate: {
|
||||
keypath: 'tags',
|
||||
@@ -688,7 +688,7 @@ describe('notes and tags', () => {
|
||||
})
|
||||
|
||||
const pinnedNote = await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.Note, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title: 'A',
|
||||
}),
|
||||
)
|
||||
@@ -697,7 +697,7 @@ describe('notes and tags', () => {
|
||||
})
|
||||
|
||||
const lockedNote = await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.Note, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title: 'A',
|
||||
}),
|
||||
)
|
||||
@@ -706,7 +706,7 @@ describe('notes and tags', () => {
|
||||
})
|
||||
|
||||
const view = await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.SmartView, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.SmartView, {
|
||||
title: 'Pinned & Locked',
|
||||
predicate: {
|
||||
operator: 'and',
|
||||
@@ -736,7 +736,7 @@ describe('notes and tags', () => {
|
||||
})
|
||||
|
||||
const pinnedNote = await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.Note, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title: 'A',
|
||||
}),
|
||||
)
|
||||
@@ -745,7 +745,7 @@ describe('notes and tags', () => {
|
||||
})
|
||||
|
||||
const pinnedAndProtectedNote = await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.Note, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title: 'A',
|
||||
}),
|
||||
)
|
||||
@@ -755,13 +755,13 @@ describe('notes and tags', () => {
|
||||
})
|
||||
|
||||
await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.Note, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title: 'A',
|
||||
}),
|
||||
)
|
||||
|
||||
const view = await this.application.mutator.insertItem(
|
||||
await this.application.items.createTemplateItem(ContentType.SmartView, {
|
||||
await this.application.items.createTemplateItem(ContentType.TYPES.SmartView, {
|
||||
title: 'Protected or Pinned',
|
||||
predicate: {
|
||||
operator: 'or',
|
||||
|
||||
@@ -20,7 +20,7 @@ describe('mapping performance', () => {
|
||||
for (let i = 0; i < tagCount; i++) {
|
||||
var tag = {
|
||||
uuid: UuidGenerator.GenerateUuid(),
|
||||
content_type: ContentType.Tag,
|
||||
content_type: ContentType.TYPES.Tag,
|
||||
content: {
|
||||
title: `${Math.random()}`,
|
||||
references: [],
|
||||
@@ -31,7 +31,7 @@ describe('mapping performance', () => {
|
||||
for (let i = 0; i < noteCount; i++) {
|
||||
const note = {
|
||||
uuid: UuidGenerator.GenerateUuid(),
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
content: {
|
||||
title: `${Math.random()}`,
|
||||
text: `${Math.random()}`,
|
||||
@@ -40,7 +40,7 @@ describe('mapping performance', () => {
|
||||
}
|
||||
const randomTag = Factory.randomArrayValue(tags)
|
||||
randomTag.content.references.push({
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
uuid: note.uuid,
|
||||
})
|
||||
notes.push(note)
|
||||
@@ -65,7 +65,7 @@ describe('mapping performance', () => {
|
||||
const expectedRunTime = 3 // seconds
|
||||
expect(seconds).to.be.at.most(expectedRunTime)
|
||||
|
||||
for (const note of application.itemManager.getItems(ContentType.Note)) {
|
||||
for (const note of application.itemManager.getItems(ContentType.TYPES.Note)) {
|
||||
expect(application.itemManager.itemsReferencingItem(note).length).to.be.above(0)
|
||||
}
|
||||
await Factory.safeDeinit(application)
|
||||
@@ -84,7 +84,7 @@ describe('mapping performance', () => {
|
||||
|
||||
const tag = {
|
||||
uuid: UuidGenerator.GenerateUuid(),
|
||||
content_type: ContentType.Tag,
|
||||
content_type: ContentType.TYPES.Tag,
|
||||
content: {
|
||||
title: `${Math.random()}`,
|
||||
references: [],
|
||||
@@ -94,7 +94,7 @@ describe('mapping performance', () => {
|
||||
for (let i = 0; i < noteCount; i++) {
|
||||
const note = {
|
||||
uuid: UuidGenerator.GenerateUuid(),
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
content: {
|
||||
title: `${Math.random()}`,
|
||||
text: `${Math.random()}`,
|
||||
@@ -103,7 +103,7 @@ describe('mapping performance', () => {
|
||||
}
|
||||
|
||||
tag.content.references.push({
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
uuid: note.uuid,
|
||||
})
|
||||
notes.push(note)
|
||||
@@ -131,8 +131,8 @@ describe('mapping performance', () => {
|
||||
const MAX_RUN_TIME = 15.0 // seconds
|
||||
expect(seconds).to.be.at.most(MAX_RUN_TIME)
|
||||
|
||||
application.itemManager.getItems(ContentType.Tag)[0]
|
||||
for (const note of application.itemManager.getItems(ContentType.Note)) {
|
||||
application.itemManager.getItems(ContentType.TYPES.Tag)[0]
|
||||
for (const note of application.itemManager.getItems(ContentType.TYPES.Note)) {
|
||||
expect(application.itemManager.itemsReferencingItem(note).length).to.equal(1)
|
||||
}
|
||||
await Factory.safeDeinit(application)
|
||||
|
||||
@@ -9,7 +9,7 @@ describe('item mutator', () => {
|
||||
this.createBarePayload = () => {
|
||||
return new DecryptedPayload({
|
||||
uuid: '123',
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
content: {
|
||||
title: 'hello',
|
||||
},
|
||||
@@ -30,7 +30,7 @@ describe('item mutator', () => {
|
||||
return new SNTag(
|
||||
new DecryptedPayload({
|
||||
uuid: Factory.generateUuidish(),
|
||||
content_type: ContentType.Tag,
|
||||
content_type: ContentType.TYPES.Tag,
|
||||
content: {
|
||||
title: 'thoughts',
|
||||
references: references,
|
||||
|
||||
@@ -28,7 +28,7 @@ describe('mutator service', function () {
|
||||
})
|
||||
|
||||
const createNote = async () => {
|
||||
return mutator.createItem(ContentType.Note, {
|
||||
return mutator.createItem(ContentType.TYPES.Note, {
|
||||
title: 'hello',
|
||||
text: 'world',
|
||||
})
|
||||
@@ -41,7 +41,7 @@ describe('mutator service', function () {
|
||||
content_type: note.content_type,
|
||||
}
|
||||
})
|
||||
return mutator.createItem(ContentType.Tag, {
|
||||
return mutator.createItem(ContentType.TYPES.Tag, {
|
||||
title: 'thoughts',
|
||||
references: references,
|
||||
})
|
||||
@@ -127,7 +127,7 @@ describe('mutator service', function () {
|
||||
})
|
||||
|
||||
it('change non-existant item through uuid should fail', async function () {
|
||||
const note = await application.items.createTemplateItem(ContentType.Note, {
|
||||
const note = await application.items.createTemplateItem(ContentType.TYPES.Note, {
|
||||
title: 'hello',
|
||||
text: 'world',
|
||||
})
|
||||
@@ -219,7 +219,7 @@ describe('mutator service', function () {
|
||||
})
|
||||
|
||||
it('duplicates item with additional content', async function () {
|
||||
const note = await mutator.createItem(ContentType.Note, {
|
||||
const note = await mutator.createItem(ContentType.TYPES.Note, {
|
||||
title: 'hello',
|
||||
text: 'world',
|
||||
})
|
||||
|
||||
@@ -9,7 +9,7 @@ describe('note display criteria', function () {
|
||||
this.mutator = new MutatorService(this.itemManager, this.payloadManager)
|
||||
|
||||
this.createNote = async (title = 'hello', text = 'world') => {
|
||||
return this.mutator.createItem(ContentType.Note, {
|
||||
return this.mutator.createItem(ContentType.TYPES.Note, {
|
||||
title: title,
|
||||
text: text,
|
||||
})
|
||||
@@ -22,7 +22,7 @@ describe('note display criteria', function () {
|
||||
content_type: note.content_type,
|
||||
}
|
||||
})
|
||||
return this.mutator.createItem(ContentType.Tag, {
|
||||
return this.mutator.createItem(ContentType.TYPES.Tag, {
|
||||
title: title,
|
||||
references: references,
|
||||
})
|
||||
@@ -41,7 +41,7 @@ describe('note display criteria', function () {
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
criteria,
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -57,7 +57,7 @@ describe('note display criteria', function () {
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
criteria,
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(2)
|
||||
@@ -73,7 +73,7 @@ describe('note display criteria', function () {
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
criteria,
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -89,7 +89,7 @@ describe('note display criteria', function () {
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
criteria,
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(2)
|
||||
@@ -105,7 +105,7 @@ describe('note display criteria', function () {
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
criteria,
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -123,7 +123,7 @@ describe('note display criteria', function () {
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
criteria,
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(2)
|
||||
@@ -139,7 +139,7 @@ describe('note display criteria', function () {
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
criteria,
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -157,7 +157,7 @@ describe('note display criteria', function () {
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
criteria,
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(2)
|
||||
@@ -174,7 +174,7 @@ describe('note display criteria', function () {
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
criteria,
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
@@ -191,7 +191,7 @@ describe('note display criteria', function () {
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
criteria,
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -208,7 +208,7 @@ describe('note display criteria', function () {
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
matchingCriteria,
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -219,7 +219,7 @@ describe('note display criteria', function () {
|
||||
expect(
|
||||
notesAndFilesMatchingOptions(
|
||||
nonmatchingCriteria,
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
@@ -233,7 +233,7 @@ describe('note display criteria', function () {
|
||||
{
|
||||
views: [this.itemManager.allNotesSmartView],
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -243,7 +243,7 @@ describe('note display criteria', function () {
|
||||
{
|
||||
views: [this.itemManager.trashSmartView],
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
@@ -253,7 +253,7 @@ describe('note display criteria', function () {
|
||||
{
|
||||
views: [this.itemManager.archivedSmartView],
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
@@ -271,7 +271,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.allNotesSmartView],
|
||||
includeTrashed: false,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
@@ -281,7 +281,7 @@ describe('note display criteria', function () {
|
||||
{
|
||||
views: [this.itemManager.trashSmartView],
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -291,7 +291,7 @@ describe('note display criteria', function () {
|
||||
{
|
||||
views: [this.itemManager.archivedSmartView],
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
@@ -309,7 +309,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.allNotesSmartView],
|
||||
includeArchived: false,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
@@ -319,7 +319,7 @@ describe('note display criteria', function () {
|
||||
{
|
||||
views: [this.itemManager.trashSmartView],
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
@@ -329,7 +329,7 @@ describe('note display criteria', function () {
|
||||
{
|
||||
views: [this.itemManager.archivedSmartView],
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -347,7 +347,7 @@ describe('note display criteria', function () {
|
||||
{
|
||||
views: [this.itemManager.allNotesSmartView],
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -357,7 +357,7 @@ describe('note display criteria', function () {
|
||||
{
|
||||
views: [this.itemManager.trashSmartView],
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -367,7 +367,7 @@ describe('note display criteria', function () {
|
||||
{
|
||||
views: [this.itemManager.archivedSmartView],
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -384,7 +384,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.allNotesSmartView],
|
||||
includeTrashed: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -395,7 +395,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.trashSmartView],
|
||||
includeTrashed: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
@@ -414,7 +414,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.allNotesSmartView],
|
||||
includeTrashed: false,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
@@ -425,7 +425,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.allNotesSmartView],
|
||||
includeTrashed: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -436,7 +436,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.trashSmartView],
|
||||
includeTrashed: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -447,7 +447,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.archivedSmartView],
|
||||
includeTrashed: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
@@ -466,7 +466,7 @@ describe('note display criteria', function () {
|
||||
{
|
||||
views: [this.itemManager.allNotesSmartView],
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -476,7 +476,7 @@ describe('note display criteria', function () {
|
||||
{
|
||||
views: [this.itemManager.trashSmartView],
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -486,7 +486,7 @@ describe('note display criteria', function () {
|
||||
{
|
||||
views: [this.itemManager.archivedSmartView],
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -503,7 +503,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.allNotesSmartView],
|
||||
includeArchived: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -514,7 +514,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.trashSmartView],
|
||||
includeArchived: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
@@ -532,7 +532,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.allNotesSmartView],
|
||||
includeArchived: false,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
@@ -543,7 +543,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.allNotesSmartView],
|
||||
includeArchived: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -554,7 +554,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.trashSmartView],
|
||||
includeArchived: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
@@ -565,7 +565,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.archivedSmartView],
|
||||
includeArchived: false,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -584,7 +584,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.allNotesSmartView],
|
||||
includeArchived: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -595,7 +595,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.trashSmartView],
|
||||
includeArchived: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -606,7 +606,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.archivedSmartView],
|
||||
includeArchived: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -626,7 +626,7 @@ describe('note display criteria', function () {
|
||||
this.itemManager.trashSmartView,
|
||||
],
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -636,7 +636,7 @@ describe('note display criteria', function () {
|
||||
{
|
||||
views: [this.itemManager.trashSmartView],
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
@@ -654,7 +654,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.allNotesSmartView],
|
||||
includeArchived: false,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
@@ -665,7 +665,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.allNotesSmartView],
|
||||
includeArchived: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -676,7 +676,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.trashSmartView],
|
||||
includeArchived: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
@@ -687,7 +687,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.archivedSmartView],
|
||||
includeArchived: false,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -706,7 +706,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.allNotesSmartView],
|
||||
includeArchived: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
@@ -717,7 +717,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.trashSmartView],
|
||||
includeArchived: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(1)
|
||||
@@ -728,7 +728,7 @@ describe('note display criteria', function () {
|
||||
views: [this.itemManager.archivedSmartView],
|
||||
includeArchived: true,
|
||||
},
|
||||
this.itemManager.collection.all(ContentType.Note),
|
||||
this.itemManager.collection.all(ContentType.TYPES.Note),
|
||||
this.itemManager.collection,
|
||||
).length,
|
||||
).to.equal(0)
|
||||
|
||||
@@ -9,7 +9,7 @@ describe('payload', () => {
|
||||
this.createBarePayload = () => {
|
||||
return new DecryptedPayload({
|
||||
uuid: '123',
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
content: {
|
||||
title: 'hello',
|
||||
},
|
||||
@@ -19,7 +19,7 @@ describe('payload', () => {
|
||||
this.createEncryptedPayload = () => {
|
||||
return new EncryptedPayload({
|
||||
uuid: '123',
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
content: '004:foo:bar',
|
||||
})
|
||||
}
|
||||
@@ -36,7 +36,7 @@ describe('payload', () => {
|
||||
it('not supplying source should default to constructor source', function () {
|
||||
const payload = new DecryptedPayload({
|
||||
uuid: '123',
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
content: {
|
||||
title: 'hello',
|
||||
},
|
||||
@@ -74,7 +74,7 @@ describe('payload', () => {
|
||||
() =>
|
||||
new EncryptedPayload({
|
||||
uuid: '123',
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
content: '000:somebase64string',
|
||||
}),
|
||||
'Unrecognized protocol version 000',
|
||||
@@ -84,7 +84,7 @@ describe('payload', () => {
|
||||
it('payload format deleted', function () {
|
||||
const payload = new DeletedPayload({
|
||||
uuid: '123',
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
deleted: true,
|
||||
})
|
||||
|
||||
@@ -101,7 +101,7 @@ describe('payload', () => {
|
||||
const payload = this.createBarePayload()
|
||||
const merged = payload.copy({
|
||||
uuid: '123',
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
updated_at: new Date(),
|
||||
dirty: true,
|
||||
dirtyIndex: getIncrementedDirtyIndex(),
|
||||
@@ -116,7 +116,7 @@ describe('payload', () => {
|
||||
it('deleted and not dirty should be discardable', function () {
|
||||
const payload = new DeletedPayload({
|
||||
uuid: '123',
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
deleted: true,
|
||||
dirty: false,
|
||||
})
|
||||
|
||||
@@ -10,7 +10,7 @@ describe('payload manager', () => {
|
||||
this.createNotePayload = async () => {
|
||||
return new DecryptedPayload({
|
||||
uuid: Factory.generateUuidish(),
|
||||
content_type: ContentType.Note,
|
||||
content_type: ContentType.TYPES.Note,
|
||||
content: {
|
||||
title: 'hello',
|
||||
text: 'world',
|
||||
@@ -45,7 +45,7 @@ describe('payload manager', () => {
|
||||
|
||||
it('insertion observer', async function () {
|
||||
const observations = []
|
||||
this.payloadManager.addObserver(ContentType.Any, ({ inserted }) => {
|
||||
this.payloadManager.addObserver(ContentType.TYPES.Any, ({ inserted }) => {
|
||||
observations.push({ inserted })
|
||||
})
|
||||
const payload = await this.createNotePayload()
|
||||
@@ -57,7 +57,7 @@ describe('payload manager', () => {
|
||||
|
||||
it('change observer', async function () {
|
||||
const observations = []
|
||||
this.payloadManager.addObserver(ContentType.Any, ({ changed }) => {
|
||||
this.payloadManager.addObserver(ContentType.TYPES.Any, ({ changed }) => {
|
||||
if (changed.length > 0) {
|
||||
observations.push({ changed })
|
||||
}
|
||||
@@ -78,7 +78,7 @@ describe('payload manager', () => {
|
||||
})
|
||||
|
||||
it('reset state', async function () {
|
||||
this.payloadManager.addObserver(ContentType.Any, ({}) => {})
|
||||
this.payloadManager.addObserver(ContentType.TYPES.Any, ({}) => {})
|
||||
const payload = await this.createNotePayload()
|
||||
await this.payloadManager.emitPayload(payload)
|
||||
await this.payloadManager.resetState()
|
||||
|
||||
@@ -16,7 +16,7 @@ describe('singletons', function () {
|
||||
function createPrefsPayload() {
|
||||
const params = {
|
||||
uuid: UuidGenerator.GenerateUuid(),
|
||||
content_type: ContentType.UserPrefs,
|
||||
content_type: ContentType.TYPES.UserPrefs,
|
||||
content: {
|
||||
foo: 'bar',
|
||||
},
|
||||
@@ -25,7 +25,7 @@ describe('singletons', function () {
|
||||
}
|
||||
|
||||
function findOrCreatePrefsSingleton(application) {
|
||||
return application.singletonManager.findOrCreateContentTypeSingleton(ContentType.UserPrefs, FillItemContent({}))
|
||||
return application.singletonManager.findOrCreateContentTypeSingleton(ContentType.TYPES.UserPrefs, FillItemContent({}))
|
||||
}
|
||||
|
||||
beforeEach(async function () {
|
||||
@@ -59,13 +59,13 @@ describe('singletons', function () {
|
||||
this.extManagerId = 'org.standardnotes.extensions-manager'
|
||||
|
||||
this.extPred = new CompoundPredicate('and', [
|
||||
new Predicate('content_type', '=', ContentType.Component),
|
||||
new Predicate('content_type', '=', ContentType.TYPES.Component),
|
||||
new Predicate('package_info.identifier', '=', this.extManagerId),
|
||||
])
|
||||
|
||||
this.createExtMgr = () => {
|
||||
return this.application.mutator.createItem(
|
||||
ContentType.Component,
|
||||
ContentType.TYPES.Component,
|
||||
{
|
||||
package_info: {
|
||||
name: 'Extensions',
|
||||
@@ -121,14 +121,14 @@ describe('singletons', function () {
|
||||
|
||||
await this.application.sync.sync(syncOptions)
|
||||
|
||||
expect(this.application.itemManager.itemsMatchingPredicate(ContentType.Component, this.extPred).length).to.equal(1)
|
||||
expect(this.application.itemManager.itemsMatchingPredicate(ContentType.TYPES.Component, this.extPred).length).to.equal(1)
|
||||
})
|
||||
|
||||
it('resolves via find or create', async function () {
|
||||
/* Set to never synced as singleton manager will attempt to sync before resolving */
|
||||
this.application.syncService.ut_clearLastSyncDate()
|
||||
this.application.syncService.ut_setDatabaseLoaded(false)
|
||||
const contentType = ContentType.UserPrefs
|
||||
const contentType = ContentType.TYPES.UserPrefs
|
||||
const predicate = new Predicate('content_type', '=', contentType)
|
||||
/* Start a sync right after we await singleton resolve below */
|
||||
setTimeout(() => {
|
||||
@@ -198,7 +198,7 @@ describe('singletons', function () {
|
||||
didCompleteRelevantSync = true
|
||||
const saved = data.savedPayloads
|
||||
expect(saved.length).to.equal(1)
|
||||
const matching = saved.find((p) => p.content_type === ContentType.Component && p.deleted)
|
||||
const matching = saved.find((p) => p.content_type === ContentType.TYPES.Component && p.deleted)
|
||||
expect(matching).to.not.be.ok
|
||||
}
|
||||
})
|
||||
@@ -252,7 +252,7 @@ describe('singletons', function () {
|
||||
})
|
||||
|
||||
it('if only result is errorDecrypting, create new item', async function () {
|
||||
const item = this.application.itemManager.items.find((item) => item.content_type === ContentType.UserPrefs)
|
||||
const item = this.application.itemManager.items.find((item) => item.content_type === ContentType.TYPES.UserPrefs)
|
||||
|
||||
const erroredPayload = new EncryptedPayload({
|
||||
...item.payload.ejected(),
|
||||
@@ -292,7 +292,7 @@ describe('singletons', function () {
|
||||
const errorDecryptingFalse = false
|
||||
await Factory.insertItemWithOverride(
|
||||
this.application,
|
||||
ContentType.Component,
|
||||
ContentType.TYPES.Component,
|
||||
sharedContent,
|
||||
true,
|
||||
errorDecryptingFalse,
|
||||
@@ -301,7 +301,7 @@ describe('singletons', function () {
|
||||
const errorDecryptingTrue = true
|
||||
const errored = await Factory.insertItemWithOverride(
|
||||
this.application,
|
||||
ContentType.Component,
|
||||
ContentType.TYPES.Component,
|
||||
sharedContent,
|
||||
true,
|
||||
errorDecryptingTrue,
|
||||
@@ -324,7 +324,7 @@ describe('singletons', function () {
|
||||
await Factory.sleep(0)
|
||||
await this.application.syncService.sync(syncOptions)
|
||||
|
||||
expect(this.application.itemManager.itemsMatchingPredicate(ContentType.Component, this.extPred).length).to.equal(1)
|
||||
expect(this.application.itemManager.itemsMatchingPredicate(ContentType.TYPES.Component, this.extPred).length).to.equal(1)
|
||||
})
|
||||
|
||||
it('alternating the uuid of a singleton should return correct result', async function () {
|
||||
|
||||
@@ -62,7 +62,7 @@ describe('online conflict handling', function () {
|
||||
}
|
||||
|
||||
it('components should not be duplicated under any circumstances', async function () {
|
||||
const payload = createDirtyPayload(ContentType.Component)
|
||||
const payload = createDirtyPayload(ContentType.TYPES.Component)
|
||||
|
||||
const item = await this.application.mutator.emitItemFromPayload(payload, PayloadEmitSource.LocalChanged)
|
||||
|
||||
@@ -90,7 +90,7 @@ describe('online conflict handling', function () {
|
||||
})
|
||||
|
||||
it('items keys should not be duplicated under any circumstances', async function () {
|
||||
const payload = createDirtyPayload(ContentType.ItemsKey)
|
||||
const payload = createDirtyPayload(ContentType.TYPES.ItemsKey)
|
||||
const item = await this.application.mutator.emitItemFromPayload(payload, PayloadEmitSource.LocalChanged)
|
||||
this.expectedItemCount++
|
||||
await this.application.syncService.sync(syncOptions)
|
||||
@@ -527,13 +527,13 @@ describe('online conflict handling', function () {
|
||||
}).timeout(60000)
|
||||
|
||||
it('duplicating an item should maintian its relationships', async function () {
|
||||
const payload1 = Factory.createStorageItemPayload(ContentType.Tag)
|
||||
const payload2 = Factory.createStorageItemPayload(ContentType.UserPrefs)
|
||||
const payload1 = Factory.createStorageItemPayload(ContentType.TYPES.Tag)
|
||||
const payload2 = Factory.createStorageItemPayload(ContentType.TYPES.UserPrefs)
|
||||
this.expectedItemCount -= 1 /** auto-created user preferences */
|
||||
await this.application.mutator.emitItemsFromPayloads([payload1, payload2], PayloadEmitSource.LocalChanged)
|
||||
this.expectedItemCount += 2
|
||||
let tag = this.application.itemManager.getItems(ContentType.Tag)[0]
|
||||
let userPrefs = this.application.itemManager.getItems(ContentType.UserPrefs)[0]
|
||||
let tag = this.application.itemManager.getItems(ContentType.TYPES.Tag)[0]
|
||||
let userPrefs = this.application.itemManager.getItems(ContentType.TYPES.UserPrefs)[0]
|
||||
expect(tag).to.be.ok
|
||||
expect(userPrefs).to.be.ok
|
||||
|
||||
@@ -567,7 +567,7 @@ describe('online conflict handling', function () {
|
||||
const rawPayloads = await this.application.diskStorageService.getAllRawPayloads()
|
||||
expect(rawPayloads.length).to.equal(this.expectedItemCount)
|
||||
|
||||
const fooItems = this.application.itemManager.getItems(ContentType.Tag)
|
||||
const fooItems = this.application.itemManager.getItems(ContentType.TYPES.Tag)
|
||||
const fooItem2 = fooItems[1]
|
||||
|
||||
expect(fooItem2.content.conflict_of).to.equal(tag.uuid)
|
||||
@@ -772,9 +772,9 @@ describe('online conflict handling', function () {
|
||||
let backupFile = await this.application.createEncryptedBackupFileForAutomatedDesktopBackups()
|
||||
/** Sort matters, and is the cause of the original issue, where tag comes before the note */
|
||||
backupFile.items = [
|
||||
backupFile.items.find((i) => i.content_type === ContentType.ItemsKey),
|
||||
backupFile.items.find((i) => i.content_type === ContentType.Tag),
|
||||
backupFile.items.find((i) => i.content_type === ContentType.Note),
|
||||
backupFile.items.find((i) => i.content_type === ContentType.TYPES.ItemsKey),
|
||||
backupFile.items.find((i) => i.content_type === ContentType.TYPES.Tag),
|
||||
backupFile.items.find((i) => i.content_type === ContentType.TYPES.Note),
|
||||
]
|
||||
backupFile = JSON.parse(JSON.stringify(backupFile))
|
||||
/** Register new account and import this same data */
|
||||
@@ -806,10 +806,10 @@ describe('online conflict handling', function () {
|
||||
})
|
||||
let backupFile = await this.application.createEncryptedBackupFileForAutomatedDesktopBackups()
|
||||
backupFile.items = [
|
||||
backupFile.items.find((i) => i.content_type === ContentType.ItemsKey),
|
||||
backupFile.items.filter((i) => i.content_type === ContentType.Note)[0],
|
||||
backupFile.items.filter((i) => i.content_type === ContentType.Note)[1],
|
||||
backupFile.items.find((i) => i.content_type === ContentType.Tag),
|
||||
backupFile.items.find((i) => i.content_type === ContentType.TYPES.ItemsKey),
|
||||
backupFile.items.filter((i) => i.content_type === ContentType.TYPES.Note)[0],
|
||||
backupFile.items.filter((i) => i.content_type === ContentType.TYPES.Note)[1],
|
||||
backupFile.items.find((i) => i.content_type === ContentType.TYPES.Tag),
|
||||
]
|
||||
backupFile = JSON.parse(JSON.stringify(backupFile))
|
||||
/** Register new account and import this same data */
|
||||
|
||||
@@ -53,8 +53,8 @@ describe('notes + tags syncing', function () {
|
||||
const tagPayload = pair[1]
|
||||
|
||||
await this.application.mutator.emitItemsFromPayloads([notePayload, tagPayload], PayloadEmitSource.LocalChanged)
|
||||
const note = this.application.itemManager.getItems([ContentType.Note])[0]
|
||||
const tag = this.application.itemManager.getItems([ContentType.Tag])[0]
|
||||
const note = this.application.itemManager.getItems([ContentType.TYPES.Note])[0]
|
||||
const tag = this.application.itemManager.getItems([ContentType.TYPES.Tag])[0]
|
||||
expect(this.application.itemManager.getDisplayableNotes().length).to.equal(1)
|
||||
expect(this.application.itemManager.getDisplayableTags().length).to.equal(1)
|
||||
|
||||
|
||||
@@ -64,8 +64,8 @@ describe('offline syncing', () => {
|
||||
const rawPayloads2 = await this.application.diskStorageService.getAllRawPayloads()
|
||||
expect(rawPayloads2.length).to.equal(this.expectedItemCount)
|
||||
|
||||
const itemsKeyRaw = (await Factory.getStoragePayloadsOfType(this.application, ContentType.ItemsKey))[0]
|
||||
const noteRaw = (await Factory.getStoragePayloadsOfType(this.application, ContentType.Note))[0]
|
||||
const itemsKeyRaw = (await Factory.getStoragePayloadsOfType(this.application, ContentType.TYPES.ItemsKey))[0]
|
||||
const noteRaw = (await Factory.getStoragePayloadsOfType(this.application, ContentType.TYPES.Note))[0]
|
||||
|
||||
/** Encrypts with default items key */
|
||||
expect(typeof noteRaw.content).to.equal('string')
|
||||
|
||||
@@ -54,7 +54,7 @@ describe('online syncing', function () {
|
||||
})
|
||||
|
||||
function noteObjectsFromObjects(items) {
|
||||
return items.filter((item) => item.content_type === ContentType.Note)
|
||||
return items.filter((item) => item.content_type === ContentType.TYPES.Note)
|
||||
}
|
||||
|
||||
it('should register and sync basic model online', async function () {
|
||||
@@ -577,7 +577,7 @@ describe('online syncing', function () {
|
||||
await this.application.syncService.sync(syncOptions)
|
||||
this.expectedItemCount++
|
||||
const rawPayloads = await this.application.diskStorageService.getAllRawPayloads()
|
||||
const notePayload = rawPayloads.find((p) => p.content_type === ContentType.Note)
|
||||
const notePayload = rawPayloads.find((p) => p.content_type === ContentType.TYPES.Note)
|
||||
expect(typeof notePayload.content).to.equal('string')
|
||||
})
|
||||
|
||||
@@ -593,7 +593,7 @@ describe('online syncing', function () {
|
||||
await Factory.sleep(0.3)
|
||||
|
||||
const rawPayloads = await this.application.diskStorageService.getAllRawPayloads()
|
||||
const notePayload = rawPayloads.find((p) => p.content_type === ContentType.Note)
|
||||
const notePayload = rawPayloads.find((p) => p.content_type === ContentType.TYPES.Note)
|
||||
expect(typeof notePayload.content).to.equal('string')
|
||||
})
|
||||
|
||||
@@ -611,7 +611,7 @@ describe('online syncing', function () {
|
||||
)
|
||||
this.expectedItemCount++
|
||||
const rawPayloads = await this.application.diskStorageService.getAllRawPayloads()
|
||||
const notePayload = rawPayloads.find((p) => p.content_type === ContentType.Note)
|
||||
const notePayload = rawPayloads.find((p) => p.content_type === ContentType.TYPES.Note)
|
||||
expect(typeof notePayload.content).to.equal('string')
|
||||
expect(notePayload.content.length).to.be.above(text.length)
|
||||
})
|
||||
@@ -790,7 +790,7 @@ describe('online syncing', function () {
|
||||
/** Create an item and sync it */
|
||||
let note = await Factory.createMappedNote(this.application)
|
||||
|
||||
this.application.itemManager.addObserver(ContentType.Note, ({ source }) => {
|
||||
this.application.itemManager.addObserver(ContentType.TYPES.Note, ({ source }) => {
|
||||
if (source === PayloadEmitSource.RemoteSaved) {
|
||||
actualSaveCount++
|
||||
}
|
||||
@@ -837,7 +837,7 @@ describe('online syncing', function () {
|
||||
/** Create an item and sync it */
|
||||
let note = await Factory.createMappedNote(this.application)
|
||||
|
||||
this.application.itemManager.addObserver(ContentType.Note, ({ source }) => {
|
||||
this.application.itemManager.addObserver(ContentType.TYPES.Note, ({ source }) => {
|
||||
if (source === PayloadEmitSource.RemoteSaved) {
|
||||
actualSaveCount++
|
||||
}
|
||||
@@ -876,7 +876,7 @@ describe('online syncing', function () {
|
||||
let didPerformMutatation = false
|
||||
const newText = `${Math.random()}`
|
||||
|
||||
this.application.itemManager.addObserver(ContentType.Note, async ({ changed, source }) => {
|
||||
this.application.itemManager.addObserver(ContentType.TYPES.Note, async ({ changed, source }) => {
|
||||
if (source === PayloadEmitSource.RemoteSaved) {
|
||||
actualSaveCount++
|
||||
} else if (source === PayloadEmitSource.PreSyncSave && !didPerformMutatation) {
|
||||
@@ -1015,7 +1015,7 @@ describe('online syncing', function () {
|
||||
it('deleting an item permanently should include it in PayloadEmitSource.PreSyncSave item change observer', async function () {
|
||||
let conditionMet = false
|
||||
|
||||
this.application.streamItems([ContentType.Note], async ({ removed, source }) => {
|
||||
this.application.streamItems([ContentType.TYPES.Note], async ({ removed, source }) => {
|
||||
if (source === PayloadEmitSource.PreSyncSave && removed.length === 1) {
|
||||
conditionMet = true
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ describe('upgrading', () => {
|
||||
expect((await this.application.encryptionService.getRootKey()).keyVersion).to.equal(ProtocolVersion.V003)
|
||||
|
||||
/** Ensure note is encrypted with 003 */
|
||||
const notePayloads = await Factory.getStoragePayloadsOfType(this.application, ContentType.Note)
|
||||
const notePayloads = await Factory.getStoragePayloadsOfType(this.application, ContentType.TYPES.Note)
|
||||
expect(notePayloads.length).to.equal(1)
|
||||
expect(notePayloads[0].version).to.equal(ProtocolVersion.V003)
|
||||
|
||||
@@ -211,7 +211,7 @@ describe('upgrading', () => {
|
||||
const note = this.application.itemManager.getDisplayableNotes()[0]
|
||||
await Factory.markDirtyAndSyncItem(this.application, note)
|
||||
|
||||
const refreshedNotePayloads = await Factory.getStoragePayloadsOfType(this.application, ContentType.Note)
|
||||
const refreshedNotePayloads = await Factory.getStoragePayloadsOfType(this.application, ContentType.TYPES.Note)
|
||||
const refreshedNotePayload = refreshedNotePayloads[0]
|
||||
expect(refreshedNotePayload.version).to.equal(latestVersion)
|
||||
}).timeout(5000)
|
||||
|
||||
@@ -37,7 +37,7 @@ describe('shared vault conflicts', function () {
|
||||
|
||||
expect(conflicts.length).to.equal(1)
|
||||
expect(conflicts[0].type).to.equal(ConflictType.SharedVaultNotMemberError)
|
||||
expect(conflicts[0].unsaved_item.content_type).to.equal(ContentType.Note)
|
||||
expect(conflicts[0].unsaved_item.content_type).to.equal(ContentType.TYPES.Note)
|
||||
|
||||
const collaboratorNotes = contactContext.items.getDisplayableNotes()
|
||||
expect(collaboratorNotes.length).to.equal(1)
|
||||
@@ -89,7 +89,7 @@ describe('shared vault conflicts', function () {
|
||||
|
||||
expect(conflicts.length).to.equal(1)
|
||||
expect(conflicts[0].type).to.equal(ConflictType.SharedVaultInsufficientPermissionsError)
|
||||
expect(conflicts[0].unsaved_item.content_type).to.equal(ContentType.Note)
|
||||
expect(conflicts[0].unsaved_item.content_type).to.equal(ContentType.TYPES.Note)
|
||||
|
||||
await deinitContactContext()
|
||||
})
|
||||
@@ -135,7 +135,7 @@ describe('shared vault conflicts', function () {
|
||||
|
||||
expect(conflicts.length).to.equal(1)
|
||||
expect(conflicts[0].type).to.equal(ConflictType.SharedVaultNotMemberError)
|
||||
expect(conflicts[0].unsaved_item.content_type).to.equal(ContentType.Note)
|
||||
expect(conflicts[0].unsaved_item.content_type).to.equal(ContentType.TYPES.Note)
|
||||
})
|
||||
|
||||
it('should create a non-vaulted copy if attempting to move item from vault to user and item belongs to someone else', async () => {
|
||||
@@ -147,7 +147,7 @@ describe('shared vault conflicts', function () {
|
||||
const conflicts = await promise
|
||||
|
||||
expect(conflicts.length).to.equal(1)
|
||||
expect(conflicts[0].unsaved_item.content_type).to.equal(ContentType.Note)
|
||||
expect(conflicts[0].unsaved_item.content_type).to.equal(ContentType.TYPES.Note)
|
||||
|
||||
const duplicateNote = contactContext.findDuplicateNote(note.uuid)
|
||||
expect(duplicateNote).to.not.be.undefined
|
||||
@@ -172,7 +172,7 @@ describe('shared vault conflicts', function () {
|
||||
const conflicts = await promise
|
||||
|
||||
expect(conflicts.length).to.equal(1)
|
||||
expect(conflicts[0].unsaved_item.content_type).to.equal(ContentType.Note)
|
||||
expect(conflicts[0].unsaved_item.content_type).to.equal(ContentType.TYPES.Note)
|
||||
|
||||
const duplicateNote = context.findDuplicateNote(note.uuid)
|
||||
expect(duplicateNote).to.not.be.undefined
|
||||
|
||||
@@ -82,7 +82,7 @@ describe('shared vault permissions', function () {
|
||||
const conflicts = await promise
|
||||
|
||||
expect(conflicts.length).to.equal(1)
|
||||
expect(conflicts[0].unsaved_item.content_type).to.equal(ContentType.KeySystemItemsKey)
|
||||
expect(conflicts[0].unsaved_item.content_type).to.equal(ContentType.TYPES.KeySystemItemsKey)
|
||||
|
||||
await deinitContactContext()
|
||||
})
|
||||
@@ -103,7 +103,7 @@ describe('shared vault permissions', function () {
|
||||
const conflicts = await promise
|
||||
|
||||
expect(conflicts.length).to.equal(1)
|
||||
expect(conflicts[0].unsaved_item.content_type).to.equal(ContentType.Note)
|
||||
expect(conflicts[0].unsaved_item.content_type).to.equal(ContentType.TYPES.Note)
|
||||
|
||||
await deinitContactContext()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user