videogen/apps/web/app/calendar/board.test.ts
caelum0x d56639a594
Some checks failed
build-images / web (push) Has been cancelled
vision2026-ci / Python SDK resource tests (push) Has been cancelled
build-images / api (push) Has been cancelled
build-images / worker-gpu (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Has been cancelled
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Has been cancelled
codeql / Analyze (javascript-typescript) (push) Has been cancelled
codeql / Analyze (python) (push) Has been cancelled
perf / API hot-path micro-smoke (budgeted) (push) Has been cancelled
perf / Desktop engine crates (release build check) (push) Has been cancelled
vision2026-ci / API phase modules (ruff + pytest) (push) Has been cancelled
vision2026-ci / Alembic upgrade + drift check (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Has been cancelled
Menivor — open source release (MIT), free to use and fork
Paid, hosted product at menivor.com, now retired as a company project.
Fresh squashed history of the cleaned working tree (secret-scanned,
no .env, no customer data, no outreach logs). Built on
MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
2026-12-04 02:10:26 +03:00

52 lines
2.1 KiB
TypeScript

import { describe, expect, it } from "vitest";
import {
ApiError,
conflictCheckOf,
normalizeEntry,
problemsOf,
} from "@/components/calendar/board-api";
import { bucketEntriesByDay } from "@/components/calendar/calendar-month";
import { sameTimeOnDay } from "@/components/calendar/use-calendar-board";
describe("calendar board api", () => {
it("normalizes entries and drops malformed rows", () => {
expect(normalizeEntry({ id: "a" })).toBeNull();
expect(normalizeEntry(null)).toBeNull();
const entry = normalizeEntry({
source: "post",
id: "p1",
platforms: ["telegram", 3],
scheduled_at: "2030-01-01T10:00:00+00:00",
status: "scheduled",
can_move: true,
});
expect(entry?.platforms).toEqual(["telegram"]);
expect(entry?.can_move).toBe(true);
expect(entry?.channel_label).toBe("");
});
it("reads the slot check from a refused move", () => {
const err = new ApiError("x: TikTok posts need at least 3 hours", 409, {
data: { check: { allow: false, reason: "gap", suggested_at: "2030-01-01T16:00:00+00:00", platforms: [] } },
});
expect(conflictCheckOf(err)?.suggested_at).toBe("2030-01-01T16:00:00+00:00");
expect(conflictCheckOf(new ApiError("nope", 400, {}))).toBeNull();
const problems = new ApiError("x", 409, { data: { problems: [{ channel_id: "c1", message: "reconnect" }] } });
expect(problemsOf(problems)).toEqual([{ channel_id: "c1", message: "reconnect" }]);
});
it("keeps the local time of day when dropped on another day", () => {
const original = new Date(2030, 0, 5, 14, 30).toISOString();
const moved = sameTimeOnDay(original, new Date(2030, 0, 9));
expect(moved.getDate()).toBe(9);
expect(moved.getHours()).toBe(14);
expect(moved.getMinutes()).toBe(30);
});
it("buckets any entry shape by local day", () => {
const at = new Date(2030, 0, 5, 9).toISOString();
const buckets = bucketEntriesByDay([{ scheduled_at: at, id: "x" }, { scheduled_at: null, id: "y" }]);
expect([...buckets.values()].flat().map((e) => e.id)).toEqual(["x"]);
});
});