Handle deleting legacy note/tag relationships
This commit is contained in:
6
package-lock.json
generated
6
package-lock.json
generated
@@ -9353,9 +9353,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"standard-file-js": {
|
||||
"version": "0.3.8",
|
||||
"resolved": "https://registry.npmjs.org/standard-file-js/-/standard-file-js-0.3.8.tgz",
|
||||
"integrity": "sha512-AneFUxvD5GG9U3ha5vKDbjE/cp76QdRgh1fGNtTivjDxtTt5QUSeQWXklGDPL7KTJN6z3hgK8Ka5AcZSN14eUA==",
|
||||
"version": "0.3.10",
|
||||
"resolved": "https://registry.npmjs.org/standard-file-js/-/standard-file-js-0.3.10.tgz",
|
||||
"integrity": "sha512-eS9cFTG+IiLDyQ/ghKUV1rhMKEz1Aea42Jsu5YY9fxGJ43+W+PnMydCVTf9YRZW3bfh+sRr0ut7QgWa8hTMJ7A==",
|
||||
"dev": true
|
||||
},
|
||||
"statuses": {
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
"karma-jasmine": "^1.1.0",
|
||||
"karma-phantomjs-launcher": "^1.0.2",
|
||||
"sn-stylekit": "1.0.15",
|
||||
"standard-file-js": "0.3.8",
|
||||
"standard-file-js": "0.3.10",
|
||||
"sn-models": "0.1.1",
|
||||
"connect": "^3.6.6",
|
||||
"mocha": "^5.2.0",
|
||||
|
||||
@@ -376,6 +376,38 @@ describe("notes and tags", () => {
|
||||
expect(newNote.referencingObjects.length).to.equal(1);
|
||||
expect(newNote.tags.length).to.equal(1);
|
||||
});
|
||||
|
||||
it('deleting a tag from a note with bi-directional relationship', () => {
|
||||
// Tags now reference notes, but it used to be that tags referenced notes and notes referenced tags.
|
||||
// After the change, there was an issue where removing an old tag relationship from a note would only
|
||||
// remove one way, and thus keep it intact on the visual level.
|
||||
|
||||
let modelManager = Factory.createModelManager();
|
||||
|
||||
let pair = createRelatedNoteTagPair();
|
||||
let noteParams = pair[0];
|
||||
let tagParams = pair[1];
|
||||
|
||||
noteParams.content.references = [{
|
||||
content_type: tagParams.content_type,
|
||||
uuid: tagParams.uuid
|
||||
}]
|
||||
|
||||
modelManager.mapResponseItemsToLocalModels([noteParams, tagParams]);
|
||||
let note = modelManager.allItemsMatchingTypes(["Note"])[0];
|
||||
let tag = modelManager.allItemsMatchingTypes(["Tag"])[0];
|
||||
|
||||
expect(tag.notes.length).to.equal(1);
|
||||
expect(note.tags.length).to.equal(1);
|
||||
|
||||
tag.removeItemAsRelationship(note);
|
||||
|
||||
expect(tag.notes.length).to.equal(0);
|
||||
expect(note.tags.length).to.equal(0);
|
||||
|
||||
expect(note.content.references.length).to.equal(0);
|
||||
expect(tag.content.references.length).to.equal(0);
|
||||
})
|
||||
});
|
||||
|
||||
describe("syncing", () => {
|
||||
|
||||
Reference in New Issue
Block a user