Skip to content

Build your personal knowledge base with Trilium Notes

test(server): tests failing due to CLS and lack of content

Elian Doranb2fcf5fa6cd7
diff --git a/apps/server/src/routes/api/clipper.spec.ts b/apps/server/src/routes/api/clipper.spec.ts
index 1efa6915e5..17b43f3b9e 100644
--- a/apps/server/src/routes/api/clipper.spec.ts
+++ b/apps/server/src/routes/api/clipper.spec.ts
@@ -1,4 +1,5 @@
import { BNote } from "../../services/backend_script_entrypoint";
+import cls from "../../services/cls";
import { buildNote } from "../../test/becca_easy_mocking";
import { processContent } from "./clipper";
@@ -6,7 +7,9 @@ let note!: BNote;
describe("processContent", () => {
beforeAll(() => {
- note = buildNote({});
+ note = buildNote({
+ content: "Hi there"
+ });
note.saveAttachment = () => {};
vi.mock("../../services/image.js", () => ({
default: {
@@ -21,29 +24,29 @@ describe("processContent", () => {
});
it("processes basic note", () => {
- const processed = processContent([], note, "<p>Hello world.</p>");
+ const processed = cls.init(() => processContent([], note, "<p>Hello world.</p>"));
expect(processed).toStrictEqual("<p>Hello world.</p>")
});
it("processes plain text", () => {
- const processed = processContent([], note, "Hello world.");
+ const processed = cls.init(() => processContent([], note, "Hello world."));
expect(processed).toStrictEqual("<p>Hello world.</p>")
});
it("replaces images", () => {
- const processed = processContent(
+ const processed = cls.init(() => processContent(
[{"imageId":"OKZxZA3MonZJkwFcEhId","src":"inline.png","dataUrl":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAQCAYAAADESFVDAAAAF0lEQVQoU2P8DwQMBADjqKLRIGAgKggAzHs/0SoYCGwAAAAASUVORK5CYII="}],
note, `<img src="OKZxZA3MonZJkwFcEhId">`
- );
+ ));
expect(processed).toStrictEqual(`<img src="api/attachments/foo/image/encodedTitle" >`);
});
it("skips over non-data images", () => {
for (const url of [ "foo", "" ]) {
- const processed = processContent(
+ const processed = cls.init(() => processContent(
[{"imageId":"OKZxZA3MonZJkwFcEhId","src":"inline.png","dataUrl": url}],
note, `<img src="OKZxZA3MonZJkwFcEhId">`
- );
+ ));
expect(processed).toStrictEqual(`<img src="OKZxZA3MonZJkwFcEhId" >`);
}
});