Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
test(collection/presentation): test slide order
Elian Doran7e6231698c64
diff --git a/apps/client/src/test/easy-froca.ts b/apps/client/src/test/easy-froca.tsindex 045819ab5a..c282baf230 100644--- a/apps/client/src/test/easy-froca.ts+++ b/apps/client/src/test/easy-froca.ts@@ -3,6 +3,7 @@ import FNote from "../entities/fnote.js";import froca from "../services/froca.js";import FAttribute from "../entities/fattribute.js";import noteAttributeCache from "../services/note_attribute_cache.js";+import FBranch from "../entities/fbranch.js";type AttributeDefinitions = { [key in `#${string}`]: string; };type RelationDefinitions = { [key in `~${string}`]: string; };@@ -10,6 +11,7 @@ type RelationDefinitions = { [key in `~${string}`]: string; };interface NoteDefinition extends AttributeDefinitions, RelationDefinitions {id?: string | undefined;title: string;+ children?: NoteDefinition[];}/**@@ -47,6 +49,24 @@ export function buildNote(noteDef: NoteDefinition) {blobId: ""});froca.notes[note.noteId] = note;+ let childNotePosition = 0;++ if (noteDef.children) {+ for (const childDef of noteDef.children) {+ const childNote = buildNote(childDef);+ const branchId = `${note.noteId}_${childNote.noteId}`;+ const branch = new FBranch(froca, {+ branchId,+ noteId: childNote.noteId,+ parentNoteId: note.noteId,+ notePosition: childNotePosition,+ fromSearchNote: false+ });+ froca.branches[branchId] = branch;+ note.addChild(childNote.noteId, branchId, false);+ childNotePosition += 10;+ }+ }let position = 0;for (const [ key, value ] of Object.entries(noteDef)) {diff --git a/apps/client/src/widgets/collections/presentation/model.spec.ts b/apps/client/src/widgets/collections/presentation/model.spec.tsnew file mode 100644index 0000000000..59e9707f79--- /dev/null+++ b/apps/client/src/widgets/collections/presentation/model.spec.ts@@ -0,0 +1,62 @@+import { beforeAll, describe, expect, it } from "vitest";+import { buildNote } from "../../../test/easy-froca";+import FNote from "../../../entities/fnote";+import { buildPresentationModel, PresentationModel } from "./model";++let presentationNote!: FNote;+let data!: PresentationModel;++describe("Presentation model", () => {+ beforeAll(async () => {+ presentationNote = buildNote({+ title: "Presentation",+ "#viewType": "presentation",+ "children": [+ {+ id: "slide1",+ title: "First slide",+ children: [+ {+ id: "slide2",+ title: "First-sub"+ }+ ]+ },+ {+ title: "Second slide",+ id: "slide3",+ children: [+ {+ id: "slide4",+ title: "Second-sub"+ }+ ]+ }+ ]+ });+ data = await buildPresentationModel(presentationNote);+ });++ it("it correctly maps horizontal and vertical slides", () => {+ expect(data).toMatchObject({+ slides: [+ {+ noteId: "slide1",+ verticalSlides: [+ {+ noteId: "slide2"+ }+ ]+ },+ {+ noteId: "slide3",+ verticalSlides: [+ {+ noteId: "slide4"+ }+ ]+ }+ ]+ })+ });+});