refactoring van de cmap structuren bijna compleet
This commit is contained in:
@@ -6,15 +6,16 @@ import {
|
||||
ConceptOwnership,
|
||||
ConceptRelation,
|
||||
ConceptRepository
|
||||
} from "../static/cmap/model/concept-repository.js";
|
||||
} from "../static/js/cmap/model/concept-repository.js";
|
||||
import {
|
||||
CmapModel,
|
||||
ConceptMap,
|
||||
ConceptMapConcept,
|
||||
ConceptMapConnector,
|
||||
ConceptMapPhrase
|
||||
} from "../static/cmap/model/concept-map.js";
|
||||
import { buildBundle } from "../static/cmap/model/interchange.js";
|
||||
} from "../static/js/cmap/model/concept-map.js";
|
||||
import { buildBundle } from "../static/js/cmap/model/interchange.js";
|
||||
import { CmapReferenceIndex } from "../static/js/cmap/model/cmap-reference-index.js";
|
||||
|
||||
const firstId = "11111111-1111-4111-8111-111111111111";
|
||||
const secondId = "22222222-2222-4222-8222-222222222222";
|
||||
@@ -24,6 +25,7 @@ function sampleDocument() {
|
||||
return {
|
||||
schemaVersion: 2,
|
||||
metadata: {
|
||||
namespace: "",
|
||||
tags: ["architecture"],
|
||||
summary: "System overview",
|
||||
explanationPageSlug: "cmap:architecture"
|
||||
@@ -246,6 +248,7 @@ test("an embedded submap becomes an independent map linked from its owner", () =
|
||||
{ tags: ["retained"], summary: "Edited child metadata", explanationPageSlug: "" }
|
||||
);
|
||||
assert.deepEqual(convertedDerivedMap.childModel.metadata(), {
|
||||
namespace: "",
|
||||
tags: ["retained"], summary: "Edited child metadata", explanationPageSlug: ""
|
||||
});
|
||||
});
|
||||
@@ -274,3 +277,74 @@ test("a model document is accepted by the complete JSON bundle export", async ()
|
||||
assert.deepEqual(bundle.cmaps[0].document.items, model.toDocument().items);
|
||||
assert.equal(bundle.concepts[0].label, "Application");
|
||||
});
|
||||
|
||||
test("CMap reference index stores lightweight destinations per concept", () => {
|
||||
const index = new CmapReferenceIndex().load([
|
||||
{ conceptId: firstId, label: "Application", cmapSlug: "architecture", count: 2 },
|
||||
{ conceptId: firstId, label: "Application", cmapSlug: "operations", count: 1 }
|
||||
], [
|
||||
{ slug: "architecture", title: "Architecture" },
|
||||
{ slug: "operations", title: "Operations" }
|
||||
]);
|
||||
|
||||
assert.deepEqual(index.mapsFor(firstId), [
|
||||
{ slug: "architecture", title: "Architecture", count: 2 },
|
||||
{ slug: "operations", title: "Operations", count: 1 }
|
||||
]);
|
||||
assert.equal(index.countFor(firstId), 3);
|
||||
assert.equal(index.conceptIdForName("Application"), firstId);
|
||||
});
|
||||
|
||||
test("model finds boundary references from active submap crossings", () => {
|
||||
const model = CmapModel.fromDocument({
|
||||
concepts: [
|
||||
{ id: firstId, label: "Submap" },
|
||||
{ id: secondId, label: "Inside" },
|
||||
{ id: thirdId, label: "Remote", cmapSlug: "remote-map" }
|
||||
],
|
||||
items: [
|
||||
{ id: 10, kind: "submap", conceptId: firstId, x: 0, y: 0, width: 800, height: 500 },
|
||||
{ id: 1, conceptId: secondId, parentSubmapId: 10, x: 100, y: 120, width: 200, height: 60 },
|
||||
{ id: 2, conceptId: thirdId, x: 420, y: 120, width: 200, height: 60 }
|
||||
],
|
||||
connectors: [{ id: 1, sourceId: 1, targetId: 2 }],
|
||||
conceptMaps: [{ id: "remote-map", title: "Remote map" }]
|
||||
});
|
||||
|
||||
assert.deepEqual(model.boundaryReferencesFor(10), [{
|
||||
connector: {
|
||||
id: 1, sourceId: 1, targetId: 2, hasArrow: true,
|
||||
lineColor: "#333", lineWidth: 2
|
||||
},
|
||||
inside: { id: 1, x: 100, y: 120, width: 200, height: 60 },
|
||||
outside: { id: 2, x: 420, y: 120, width: 200, height: 60 },
|
||||
sourceInside: true,
|
||||
conceptId: thirdId,
|
||||
label: "Remote",
|
||||
linkingPhraseLabel: null,
|
||||
targetMaps: []
|
||||
}]);
|
||||
});
|
||||
|
||||
test("model anchors boundary references on the connected concept beyond a phrase", () => {
|
||||
const model = CmapModel.fromDocument({
|
||||
concepts: [
|
||||
{ id: firstId, label: "Submap" },
|
||||
{ id: secondId, label: "Inside" },
|
||||
{ id: thirdId, label: "Remote", cmapSlug: "remote-map" }
|
||||
],
|
||||
items: [
|
||||
{ id: 10, kind: "submap", conceptId: firstId, x: 0, y: 0, width: 800, height: 500 },
|
||||
{ id: 1, conceptId: secondId, parentSubmapId: 10, x: 100, y: 120, width: 200, height: 60 },
|
||||
{ id: 2, kind: "phrase", label: "relates", parentSubmapId: 10, x: 330, y: 120, width: 80, height: 30 },
|
||||
{ id: 3, conceptId: thirdId, x: 480, y: 120, width: 200, height: 60 }
|
||||
],
|
||||
connectors: [
|
||||
{ id: 1, sourceId: 1, targetId: 2 },
|
||||
{ id: 2, sourceId: 2, targetId: 3 }
|
||||
],
|
||||
conceptMaps: [{ id: "remote-map", title: "Remote map" }]
|
||||
});
|
||||
|
||||
assert.equal(model.boundaryReferencesFor(10)[0].inside.id, 1);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user