mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-13 17:56:07 +00:00
Refactor the Control UI around route-owned page lifecycle and state while preserving existing behavior and design.
Prepared head SHA: bd51b6fa76
Co-authored-by: Shakker <165377636+shakkernerd@users.noreply.github.com>
Reviewed-by: @shakkernerd
41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
// Control UI tests cover cron schedule presentation.
|
|
import { describe, expect, it } from "vitest";
|
|
import { formatCronSchedule } from "./presenter.ts";
|
|
import type { CronJob } from "../api/types.ts";
|
|
|
|
function job(schedule: CronJob["schedule"]): CronJob {
|
|
return {
|
|
id: "job",
|
|
name: "Job",
|
|
enabled: true,
|
|
createdAtMs: 0,
|
|
updatedAtMs: 0,
|
|
schedule,
|
|
sessionTarget: "main",
|
|
wakeMode: "next-heartbeat",
|
|
payload: { kind: "systemEvent", text: "test" },
|
|
};
|
|
}
|
|
|
|
describe("formatCronSchedule", () => {
|
|
it("formats every schedules", () => {
|
|
expect(formatCronSchedule(job({ kind: "every", everyMs: 60_000 }))).toBe("Every 1m");
|
|
});
|
|
|
|
it("formats cron schedules", () => {
|
|
expect(formatCronSchedule(job({ kind: "cron", expr: "0 * * * *" }))).toBe("Cron 0 * * * *");
|
|
});
|
|
|
|
it("formats on-exit schedules with the watched command instead of falling through to cron", () => {
|
|
expect(formatCronSchedule(job({ kind: "on-exit", command: "make build" }))).toBe(
|
|
"On exit: make build",
|
|
);
|
|
});
|
|
|
|
it("includes the working directory for on-exit schedules when set", () => {
|
|
expect(formatCronSchedule(job({ kind: "on-exit", command: "./watch.sh", cwd: "/repo" }))).toBe(
|
|
"On exit: ./watch.sh (cwd: /repo)",
|
|
);
|
|
});
|
|
});
|