Skip to content

Build your personal knowledge base with Trilium Notes

test(core): minor typecheck fixes

Elian Dorana303122f8489
diff --git a/packages/trilium-core/src/services/bulk_actions.spec.ts b/packages/trilium-core/src/services/bulk_actions.spec.ts
index 6761337fd0..b40494a5ac 100644
--- a/packages/trilium-core/src/services/bulk_actions.spec.ts
+++ b/packages/trilium-core/src/services/bulk_actions.spec.ts
@@ -199,14 +199,14 @@ describe("bulk_actions service (real DB)", () => {
it("is a no-op for an empty / whitespace-only script", () => {
const note = createNote("root");
- const labelsBefore = note.note.getOwnedLabels().length;
+ const labelsBefore = note.note.getOwnedAttributes().length;
expect(() =>
withContext(() =>
bulkActionService.executeActions([{ name: "executeScript", script: " " }], [note.note.noteId])
)
).not.toThrow();
- expect(note.note.getOwnedLabels().length).toBe(labelsBefore);
+ expect(note.note.getOwnedAttributes().length).toBe(labelsBefore);
});
});
diff --git a/packages/trilium-core/src/services/cloning.spec.ts b/packages/trilium-core/src/services/cloning.spec.ts
index d78b2825f8..ffd8d51395 100644
--- a/packages/trilium-core/src/services/cloning.spec.ts
+++ b/packages/trilium-core/src/services/cloning.spec.ts
@@ -109,7 +109,7 @@ describe("cloning service (real DB)", () => {
targetParent.branch.isExpanded = false;
const res = withContext(() =>
- cloningService.cloneNoteToBranch(source.note.noteId, targetParent.branch.branchId, "px")
+ cloningService.cloneNoteToBranch(source.note.noteId, targetParent.branch.branchId!, "px")
) as { success: boolean; branchId?: string };
expect(res.success).toBe(true);
@@ -263,7 +263,7 @@ describe("cloning service (real DB)", () => {
const afterPos = first.branch.notePosition;
const res = withContext(() =>
- cloningService.cloneNoteAfter(source.note.noteId, first.branch.branchId)
+ cloningService.cloneNoteAfter(source.note.noteId, first.branch.branchId!)
) as { success: boolean; branchId?: string };
expect(res.success).toBe(true);
@@ -286,7 +286,7 @@ describe("cloning service (real DB)", () => {
it("forbids cloning protected structural notes", () => {
const target = createNote("root");
- const res = cloningService.cloneNoteAfter("root", target.branch.branchId);
+ const res = cloningService.cloneNoteAfter("root", target.branch.branchId!);
expect(res.success).toBe(false);
expect(res.message).toBe("Cloning the note 'root' is forbidden.");
@@ -308,7 +308,7 @@ describe("cloning service (real DB)", () => {
// `existing` already lives under `parent`; cloning it after `reference`
// (same parent) is rejected by validateParentChild.
- const res = cloningService.cloneNoteAfter(existing.note.noteId, reference.branch.branchId);
+ const res = cloningService.cloneNoteAfter(existing.note.noteId, reference.branch.branchId!);
expect(res.success).toBe(false);
expect(typeof res.message).toBe("string");
diff --git a/packages/trilium-core/src/services/context.spec.ts b/packages/trilium-core/src/services/context.spec.ts
index a0ad2c3eeb..446ec5be35 100644
--- a/packages/trilium-core/src/services/context.spec.ts
+++ b/packages/trilium-core/src/services/context.spec.ts
@@ -36,7 +36,7 @@ function makeEntityChange(id: string): EntityChange {
isErased: false,
utcDateChanged: "2026-01-01 00:00:00Z",
isSynced: true
- } as EntityChange;
+ } as unknown as EntityChange;
}
describe("context", () => {
diff --git a/packages/trilium-core/src/services/erase.spec.ts b/packages/trilium-core/src/services/erase.spec.ts
index a86740d976..e4ca9d8038 100644
--- a/packages/trilium-core/src/services/erase.spec.ts
+++ b/packages/trilium-core/src/services/erase.spec.ts
@@ -52,7 +52,7 @@ describe("erase service (real DB)", () => {
const note = createNote();
const noteId = note.noteId;
const branch = note.getParentBranches()[0];
- const branchId = branch.branchId;
+ const branchId = branch.branchId!;
const attribute = withContext(() => note.addLabel("eraseMe", "v"));
const attributeId = attribute.attributeId;
@@ -113,7 +113,7 @@ describe("erase service (real DB)", () => {
it("erases entities deleted in the past (cutoff 0 seconds)", () => {
const note = createNote();
const noteId = note.noteId;
- const branchId = note.getParentBranches()[0].branchId;
+ const branchId = note.getParentBranches()[0].branchId!;
// deleteNote soft-deletes the note, its branch and attributes.
withContext(() => note.deleteNote());
diff --git a/packages/trilium-core/src/services/export/zip/markdown.spec.ts b/packages/trilium-core/src/services/export/zip/markdown.spec.ts
index c467b1cd73..1ca4a45d97 100644
--- a/packages/trilium-core/src/services/export/zip/markdown.spec.ts
+++ b/packages/trilium-core/src/services/export/zip/markdown.spec.ts
@@ -114,10 +114,11 @@ describe("MarkdownExportProvider", () => {
const metaFile: NoteMetaFile = { formatVersion: 1, appVersion: "1.0.0", files: [] };
const rootMeta: NoteMeta = { noteId: "root", title: "Root", children: [] };
- expect(() => provider.prepareMeta(metaFile)).not.toThrow();
- expect(() => provider.afterDone(rootMeta)).not.toThrow();
+ expect(() => provider.prepareMeta()).not.toThrow();
+ expect(() => provider.afterDone()).not.toThrow();
expect(metaFile.files).toHaveLength(0);
+ expect(rootMeta.children).toHaveLength(0);
expect(provider.archive.append).not.toHaveBeenCalled();
});
});
diff --git a/packages/trilium-core/tsconfig.spec.json b/packages/trilium-core/tsconfig.spec.json
index 6026943caa..a242bba645 100644
--- a/packages/trilium-core/tsconfig.spec.json
+++ b/packages/trilium-core/tsconfig.spec.json
@@ -24,7 +24,8 @@
"src/**/*.test.jsx",
"src/**/*.spec.jsx",
"src/**/*.d.ts",
- "src/**/*.json"
+ "src/**/*.json",
+ "package.json"
],
"references": [
{