mirror of
https://github.com/alkimake/paperclip.git
synced 2026-06-15 02:20:38 +09:00
fix: address greptile routine review
This commit is contained in:
parent
99eb317600
commit
9093cfbe4f
6 changed files with 157 additions and 19 deletions
71
ui/src/lib/routine-trigger-patch.test.ts
Normal file
71
ui/src/lib/routine-trigger-patch.test.ts
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
import { describe, expect, it } from "vitest";
|
||||
import type { RoutineTrigger } from "@paperclipai/shared";
|
||||
import { buildRoutineTriggerPatch } from "./routine-trigger-patch";
|
||||
|
||||
function makeScheduleTrigger(overrides: Partial<RoutineTrigger> = {}): RoutineTrigger {
|
||||
return {
|
||||
id: "trigger-1",
|
||||
companyId: "company-1",
|
||||
routineId: "routine-1",
|
||||
kind: "schedule",
|
||||
label: "Daily",
|
||||
enabled: true,
|
||||
cronExpression: "0 10 * * *",
|
||||
timezone: "UTC",
|
||||
nextRunAt: null,
|
||||
lastFiredAt: null,
|
||||
publicId: null,
|
||||
secretId: null,
|
||||
signingMode: null,
|
||||
replayWindowSec: null,
|
||||
lastRotatedAt: null,
|
||||
lastResult: null,
|
||||
createdByAgentId: null,
|
||||
createdByUserId: null,
|
||||
updatedByAgentId: null,
|
||||
updatedByUserId: null,
|
||||
createdAt: new Date("2026-03-20T00:00:00.000Z"),
|
||||
updatedAt: new Date("2026-03-20T00:00:00.000Z"),
|
||||
...overrides,
|
||||
};
|
||||
}
|
||||
|
||||
describe("buildRoutineTriggerPatch", () => {
|
||||
it("preserves an existing schedule trigger timezone when saving edits", () => {
|
||||
const patch = buildRoutineTriggerPatch(
|
||||
makeScheduleTrigger({ timezone: "UTC" }),
|
||||
{
|
||||
label: "Daily label edit",
|
||||
cronExpression: "0 10 * * *",
|
||||
signingMode: "bearer",
|
||||
replayWindowSec: "300",
|
||||
},
|
||||
"America/Chicago",
|
||||
);
|
||||
|
||||
expect(patch).toEqual({
|
||||
label: "Daily label edit",
|
||||
cronExpression: "0 10 * * *",
|
||||
timezone: "UTC",
|
||||
});
|
||||
});
|
||||
|
||||
it("falls back to the local timezone when a schedule trigger has none", () => {
|
||||
const patch = buildRoutineTriggerPatch(
|
||||
makeScheduleTrigger({ timezone: null }),
|
||||
{
|
||||
label: "",
|
||||
cronExpression: "15 9 * * 1-5",
|
||||
signingMode: "bearer",
|
||||
replayWindowSec: "300",
|
||||
},
|
||||
"America/Chicago",
|
||||
);
|
||||
|
||||
expect(patch).toEqual({
|
||||
label: null,
|
||||
cronExpression: "15 9 * * 1-5",
|
||||
timezone: "America/Chicago",
|
||||
});
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue