test: remove negative legacy cases

This commit is contained in:
2026-05-31 12:31:34 +00:00
parent 83191055bd
commit d7a0a5d076
2 changed files with 0 additions and 78 deletions
-31
View File
@@ -1,5 +1,4 @@
import { describe, expect, test } from "bun:test"; import { describe, expect, test } from "bun:test";
import { Database } from "bun:sqlite";
import { mkdtempSync, rmSync } from "node:fs"; import { mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os"; import { tmpdir } from "node:os";
import { join } from "node:path"; import { join } from "node:path";
@@ -60,36 +59,6 @@ describe("api", () => {
cleanup(); cleanup();
}); });
test("returns 500 when stored scene payload is invalid", () => {
const dir = mkdtempSync(join(tmpdir(), "excali-api-"));
const databasePath = join(dir, "test.sqlite");
const db = new Database(databasePath, { create: true, strict: true });
db.exec(`
CREATE TABLE drawings (
id TEXT PRIMARY KEY,
title TEXT NOT NULL,
data TEXT NOT NULL,
created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
revision INTEGER NOT NULL DEFAULT 0
);
INSERT INTO drawings (id, title, data, revision)
VALUES ('broken', 'Broken', '{"appState":{},"files":{}}', 0);
`);
db.close(false);
const store = createDrawingStore(databasePath);
const api = createApi(store);
const response = api.getDrawing(
Object.assign(new Request("http://local/api/drawings/broken"), { params: { id: "broken" } }),
);
expect(response.status).toBe(500);
store.close();
rmSync(dir, { recursive: true, force: true });
});
test("updates a drawing scene", async () => { test("updates a drawing scene", async () => {
const { api, cleanup } = withApi(); const { api, cleanup } = withApi();
const created = await api.createDrawing().json(); const created = await api.createDrawing().json();
-47
View File
@@ -1,5 +1,4 @@
import { afterEach, describe, expect, test } from "bun:test"; import { afterEach, describe, expect, test } from "bun:test";
import { Database } from "bun:sqlite";
import { mkdtempSync, rmSync } from "node:fs"; import { mkdtempSync, rmSync } from "node:fs";
import { tmpdir } from "node:os"; import { tmpdir } from "node:os";
import { join } from "node:path"; import { join } from "node:path";
@@ -83,50 +82,4 @@ describe("drawing store", () => {
expect(store.getDrawing(created.id)?.scene.elements).toEqual([{ id: "first" }]); expect(store.getDrawing(created.id)?.scene.elements).toEqual([{ id: "first" }]);
}); });
test("fails to open databases missing the revision column", () => {
const dir = mkdtempSync(join(tmpdir(), "excali-"));
cleanup.push(dir);
const databasePath = join(dir, "test.sqlite");
const db = new Database(databasePath, { create: true, strict: true });
db.exec(`
CREATE TABLE drawings (
id TEXT PRIMARY KEY,
title TEXT NOT NULL,
data TEXT NOT NULL,
created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP
);
INSERT INTO drawings (id, title, data)
VALUES ('legacy', 'Legacy', '{"elements":[],"appState":{},"files":{}}');
`);
db.close(false);
expect(() => createDrawingStore(databasePath)).toThrow(/revision/i);
});
test("throws when reading drawings with invalid stored scene payloads", () => {
const dir = mkdtempSync(join(tmpdir(), "excali-"));
cleanup.push(dir);
const databasePath = join(dir, "test.sqlite");
const db = new Database(databasePath, { create: true, strict: true });
db.exec(`
CREATE TABLE drawings (
id TEXT PRIMARY KEY,
title TEXT NOT NULL,
data TEXT NOT NULL,
created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
revision INTEGER NOT NULL DEFAULT 0
);
INSERT INTO drawings (id, title, data, revision)
VALUES ('broken', 'Broken', '{"appState":{},"files":{}}', 0);
`);
db.close(false);
const store = createDrawingStore(databasePath);
expect(() => store.getDrawing("broken")).toThrow(/Invalid stored scene/);
store.close();
});
}); });