concurrency

This commit is contained in:
Zimeng Xiong
2026-02-07 12:45:25 -08:00
parent dd0f381ed1
commit de254d46f2
12 changed files with 429 additions and 31 deletions
+32
View File
@@ -0,0 +1,32 @@
import { describe, expect, it } from "vitest";
import {
hasRenderableElements,
isSuspiciousEmptySnapshot,
} from "./shared";
describe("editor/shared scene guards", () => {
it("detects renderable elements", () => {
expect(hasRenderableElements([{ id: "a", isDeleted: false }])).toBe(true);
expect(
hasRenderableElements([
{ id: "a", isDeleted: true },
{ id: "b", isDeleted: true },
])
).toBe(false);
});
it("flags empty snapshot after a previously non-empty persisted scene", () => {
const previous = [{ id: "a", isDeleted: false }];
expect(isSuspiciousEmptySnapshot(previous, [])).toBe(true);
});
it("does not flag empty snapshot for already-empty drawings", () => {
expect(isSuspiciousEmptySnapshot([], [])).toBe(false);
});
it("does not flag non-empty snapshots", () => {
const previous = [{ id: "a", isDeleted: false }];
const next = [{ id: "a", isDeleted: true }];
expect(isSuspiciousEmptySnapshot(previous, next)).toBe(false);
});
});