chore(vite): remove vite/global for server

This commit is contained in:
Elian Doran 2026-01-01 23:39:53 +02:00
parent da9c9ac346
commit 229636a796
No known key found for this signature in database
14 changed files with 52 additions and 34 deletions

View File

@ -1,3 +1,5 @@
import { describe, expect, it } from "vitest";
import BRevision from "./brevision.js";
describe("Revision", () => {

View File

@ -1,4 +1,6 @@
import { trimIndentation } from "@triliumnext/commons";
import { describe, expect, it } from "vitest";
import { buildNote } from "../test/becca_easy_mocking";
import { buildRewardMap } from "./similarity";

View File

@ -1,3 +1,5 @@
import { beforeAll, describe, expect, it, vi } from "vitest";
import BNote from '../../becca/entities/bnote.js';
import cls from "../../services/cls";
import { buildNote } from "../../test/becca_easy_mocking";
@ -17,7 +19,7 @@ describe("processContent", () => {
return {
attachmentId: "foo",
title: "encodedTitle",
}
};
}
}
}));
@ -25,12 +27,12 @@ describe("processContent", () => {
it("processes basic note", () => {
const processed = cls.init(() => processContent([], note, "<p>Hello world.</p>"));
expect(processed).toStrictEqual("<p>Hello world.</p>")
expect(processed).toStrictEqual("<p>Hello world.</p>");
});
it("processes plain text", () => {
const processed = cls.init(() => processContent([], note, "Hello world."));
expect(processed).toStrictEqual("<p>Hello world.</p>")
expect(processed).toStrictEqual("<p>Hello world.</p>");
});
it("replaces images", () => {

View File

@ -1,9 +1,10 @@
import { Application } from "express";
import { beforeAll, describe, expect, it, vi, beforeEach, afterEach } from "vitest";
import supertest from "supertest";
import config from "../../services/config.js";
import { refreshAuth } from "../../services/auth.js";
import { sleepFor } from "@triliumnext/commons";
import { Application } from "express";
import supertest from "supertest";
import { afterAll,afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { refreshAuth } from "../../services/auth.js";
import config from "../../services/config.js";
// Mock the CSRF protection middleware to allow tests to pass
vi.mock("../csrf_protection.js", () => ({
@ -841,7 +842,7 @@ describe("LLM API Tests", () => {
try {
await supertest(app)
.delete(`/api/llm/chat/${createdChatId}`)
;
;
} catch (error) {
// Ignore cleanup errors
}

View File

@ -1,4 +1,6 @@
import { trimIndentation } from "@triliumnext/commons";
import { describe, expect, it } from "vitest";
import { buildNote, buildNotes } from "../../test/becca_easy_mocking";
import note_map from "./note_map";

View File

@ -1,10 +1,11 @@
import { beforeAll, describe, expect, it } from "vitest";
import supertest, { type Response } from "supertest";
import type { Application } from "express";
import { dayjs } from "@triliumnext/commons";
import { type SQLiteSessionStore } from "./session_parser.js";
import type { Application } from "express";
import { SessionData } from "express-session";
import supertest, { type Response } from "supertest";
import { beforeAll, describe, expect, it, vi } from "vitest";
import cls from "../services/cls.js";
import { type SQLiteSessionStore } from "./session_parser.js";
let app: Application;
let sessionStore: SQLiteSessionStore;
@ -24,7 +25,7 @@ describe("Login Route test", () => {
// RegExp for login page specific string in HTML
const res = await supertest(app)
.get("/login")
.expect(200)
.expect(200);
expect(res.text).toMatch(/assets\/v[0-9.a-z]+\/src\/login\.js/);
@ -35,7 +36,7 @@ describe("Login Route test", () => {
await supertest(app)
.post("/login")
.send({ password: "fakePassword" })
.expect(401)
.expect(401);
});
@ -69,7 +70,7 @@ describe("Login Route test", () => {
// ignore the seconds in the comparison, just to avoid flakiness in tests,
// if for some reason execution is slow between calculation of expected and actual
expect(actualExpiresDate.slice(0,23)).toBe(expectedExpiresDate.slice(0,23))
expect(actualExpiresDate.slice(0,23)).toBe(expectedExpiresDate.slice(0,23));
});
it("sets the correct sesssion data", async () => {
@ -121,14 +122,14 @@ describe("Login Route test", () => {
res = await supertest(app)
.post("/login")
.send({ password: "demo1234" })
.expect(302)
.expect(302);
setCookieHeader = res.headers["set-cookie"][0];
});
it("does not set Expires", async () => {
// match for e.g. "Expires=Wed, 07 May 2025 07:02:59 GMT;"
expect(setCookieHeader).not.toMatch(/Expires=(?<date>[\w\s,:]+)/)
expect(setCookieHeader).not.toMatch(/Expires=(?<date>[\w\s,:]+)/);
});
it("stores the session in the database", async () => {

View File

@ -1,9 +1,11 @@
import supertest from "supertest";
import options from "./options";
import cls from "./cls";
import { Application } from "express";
import config from "./config";
import supertest from "supertest";
import { beforeAll, describe, expect, it } from "vitest";
import { refreshAuth } from "./auth";
import cls from "./cls";
import config from "./config";
import options from "./options";
let app: Application;
@ -39,7 +41,7 @@ describe("Auth", () => {
const response = await supertest(app)
.get("/")
.redirects(1)
.expect(200)
.expect(200);
expect(response.text).not.toContain(`id="totpToken"`);
});
});

View File

@ -1,11 +1,12 @@
import { describe, it, expect } from "vitest";
import { deferred, LOCALES } from "@triliumnext/commons";
import { beforeAll,describe, expect, it } from "vitest";
import becca from "../becca/becca.js";
import branches from "./branches.js";
import cls from "./cls.js";
import hiddenSubtreeService from "./hidden_subtree.js";
import sql_init from "./sql_init.js";
import branches from "./branches.js";
import becca from "../becca/becca.js";
import { deferred, LOCALES } from "@triliumnext/commons";
import { changeLanguage } from "./i18n.js";
import sql_init from "./sql_init.js";
describe("Hidden Subtree", () => {
beforeAll(async () => {

View File

@ -1,6 +1,7 @@
import { LOCALES } from "@triliumnext/commons";
import { readFileSync } from "fs";
import { join } from "path";
import { describe, expect, it } from "vitest";
describe("i18n", () => {
it("translations are valid JSON", () => {

View File

@ -1,3 +1,5 @@
import { describe, expect, it } from "vitest";
import { buildNote } from "../test/becca_easy_mocking";
import { determineBestFontAttachment, generateCss, generateIconRegistry, IconPackManifest, processIconPack } from "./icon_packs";

View File

@ -1,14 +1,16 @@
import { beforeEach } from "node:test";
import { trimIndentation } from "@triliumnext/commons";
import { describe, expect, it, vi } from "vitest";
import becca from "../becca/becca.js";
import BBranch from "../becca/entities/bbranch.js";
import BNote from "../becca/entities/bnote.js";
import { buildNote } from "../test/becca_easy_mocking.js";
import { note, NoteBuilder } from "../test/becca_mocking.js";
import { NoteBuilder } from "../test/becca_mocking.js";
import cls from "./cls.js";
import { buildJsx, executeBundle, getScriptBundle } from "./script.js";
describe("Script", () => {
let rootNote!: NoteBuilder;

View File

@ -1,5 +1,5 @@
import { trimIndentation } from "@triliumnext/commons";
import { describe, expect,it, vi } from "vitest";
import { beforeAll, describe, expect,it, vi } from "vitest";
import { buildShareNote, buildShareNotes } from "../test/shaca_mocking.js";
import { getContent, renderCode, type Result } from "./content_renderer.js";

View File

@ -1,6 +1,7 @@
import { beforeAll, beforeEach, describe, expect, it } from "vitest";
import type { Application, NextFunction,Request, Response } from "express";
import supertest from "supertest";
import type { Application, Request, Response, NextFunction } from "express";
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
import { safeExtractMessageAndStackFromError } from "../services/utils.js";
let app: Application;

View File

@ -6,7 +6,6 @@
"target": "ES2020",
"outDir": "./out-tsc/vitest",
"types": [
"vitest/globals",
"node",
"vitest"
]