




















@@ -10,7 +10,7 @@ import {
1010describe("formatAgentEnvelope", () => {
1111it("includes channel, from, ip, host, and timestamp", () => {
1212withEnv({ TZ: "UTC" }, () => {
13-const ts = Date.UTC(2025, 0, 2, 3, 4); // 2025-01-02T03:04:00Z
13+const ts = Date.UTC(2025, 0, 2, 3, 4, 5); // 2025-01-02T03:04:05Z
1414const body = formatAgentEnvelope({
1515channel: "WebChat",
1616from: "user1",
@@ -21,7 +21,7 @@ describe("formatAgentEnvelope", () => {
2121body: "hello",
2222});
232324-expect(body).toBe("[WebChat user1 mac-mini 10.0.0.5 Thu 2025-01-02T03:04Z] hello");
24+expect(body).toBe("[WebChat user1 mac-mini 10.0.0.5 Thu 2025-01-02T03:04:05Z] hello");
2525});
2626});
2727@@ -39,28 +39,28 @@ describe("formatAgentEnvelope", () => {
39394040it("formats timestamps in UTC when configured", () => {
4141withEnv({ TZ: "America/Los_Angeles" }, () => {
42-const ts = Date.UTC(2025, 0, 2, 3, 4); // 2025-01-02T03:04:00Z (19:04 PST)
42+const ts = Date.UTC(2025, 0, 2, 3, 4, 5); // 2025-01-02T03:04:05Z (19:04:05 PST)
4343const body = formatAgentEnvelope({
4444channel: "WebChat",
4545timestamp: ts,
4646envelope: { timezone: "utc" },
4747body: "hello",
4848});
494950-expect(body).toBe("[WebChat Thu 2025-01-02T03:04Z] hello");
50+expect(body).toBe("[WebChat Thu 2025-01-02T03:04:05Z] hello");
5151});
5252});
53535454it("formats timestamps in user timezone when configured", () => {
55-const ts = Date.UTC(2025, 0, 2, 3, 4); // 2025-01-02T03:04:00Z (04:04 CET)
55+const ts = Date.UTC(2025, 0, 2, 3, 4, 5); // 2025-01-02T03:04:05Z (04:04:05 CET)
5656const body = formatAgentEnvelope({
5757channel: "WebChat",
5858timestamp: ts,
5959envelope: { timezone: "user", userTimezone: "Europe/Vienna" },
6060body: "hello",
6161});
626263-expect(body).toMatch(/\[WebChat Thu 2025-01-02 04:04 [^\]]+\] hello/);
63+expect(body).toMatch(/\[WebChat Thu 2025-01-02 04:04:05 [^\]]+\] hello/);
6464});
65656666it("omits timestamps when configured", () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。