From b2fcf5fa6cd7c76742c5773ad9ac212bb64cf662 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Thu, 9 Oct 2025 12:18:39 +0300 Subject: [PATCH] test(server): tests failing due to CLS and lack of content --- apps/server/src/routes/api/clipper.spec.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/apps/server/src/routes/api/clipper.spec.ts b/apps/server/src/routes/api/clipper.spec.ts index 1efa6915e..17b43f3b9 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, "

Hello world.

"); + const processed = cls.init(() => processContent([], note, "

Hello world.

")); expect(processed).toStrictEqual("

Hello world.

") }); it("processes plain text", () => { - const processed = processContent([], note, "Hello world."); + const processed = cls.init(() => processContent([], note, "Hello world.")); expect(processed).toStrictEqual("

Hello world.

") }); it("replaces images", () => { - const processed = processContent( + const processed = cls.init(() => processContent( [{"imageId":"OKZxZA3MonZJkwFcEhId","src":"inline.png","dataUrl":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAkAAAAQCAYAAADESFVDAAAAF0lEQVQoU2P8DwQMBADjqKLRIGAgKggAzHs/0SoYCGwAAAAASUVORK5CYII="}], note, `` - ); + )); expect(processed).toStrictEqual(``); }); 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, `` - ); + )); expect(processed).toStrictEqual(``); } });