diff --git a/extensions/whatsapp/src/auto-reply.web-auto-reply.connection-and-logging.e2e.test.ts b/extensions/whatsapp/src/auto-reply.web-auto-reply.connection-and-logging.e2e.test.ts index 76a54a20d015..27923c93a5ca 100644 --- a/extensions/whatsapp/src/auto-reply.web-auto-reply.connection-and-logging.e2e.test.ts +++ b/extensions/whatsapp/src/auto-reply.web-auto-reply.connection-and-logging.e2e.test.ts @@ -141,7 +141,7 @@ describe("web auto-reply connection", () => { it("handles helper envelope timestamps with trimmed timezones (regression)", () => { const d = new Date("2025-01-01T00:00:00.000Z"); - expect(formatEnvelopeTimestamp(d, " America/Los_Angeles ")).toBe("Tue 2024-12-31 16:00 PST"); + expect(formatEnvelopeTimestamp(d, " America/Los_Angeles ")).toBe("Tue 2024-12-31 16:00:00 PST"); }); it("handles reconnect progress and max-attempt stop behavior", async () => { diff --git a/src/auto-reply/envelope.test.ts b/src/auto-reply/envelope.test.ts index d2c55a5fbba3..31ae8be2a232 100644 --- a/src/auto-reply/envelope.test.ts +++ b/src/auto-reply/envelope.test.ts @@ -10,7 +10,7 @@ import { describe("formatAgentEnvelope", () => { it("includes channel, from, ip, host, and timestamp", () => { withEnv({ TZ: "UTC" }, () => { - const ts = Date.UTC(2025, 0, 2, 3, 4); // 2025-01-02T03:04:00Z + const ts = Date.UTC(2025, 0, 2, 3, 4, 5); // 2025-01-02T03:04:05Z const body = formatAgentEnvelope({ channel: "WebChat", from: "user1", @@ -21,7 +21,7 @@ describe("formatAgentEnvelope", () => { body: "hello", }); - expect(body).toBe("[WebChat user1 mac-mini 10.0.0.5 Thu 2025-01-02T03:04Z] hello"); + expect(body).toBe("[WebChat user1 mac-mini 10.0.0.5 Thu 2025-01-02T03:04:05Z] hello"); }); }); @@ -39,7 +39,7 @@ describe("formatAgentEnvelope", () => { it("formats timestamps in UTC when configured", () => { withEnv({ TZ: "America/Los_Angeles" }, () => { - const ts = Date.UTC(2025, 0, 2, 3, 4); // 2025-01-02T03:04:00Z (19:04 PST) + const ts = Date.UTC(2025, 0, 2, 3, 4, 5); // 2025-01-02T03:04:05Z (19:04:05 PST) const body = formatAgentEnvelope({ channel: "WebChat", timestamp: ts, @@ -47,12 +47,12 @@ describe("formatAgentEnvelope", () => { body: "hello", }); - expect(body).toBe("[WebChat Thu 2025-01-02T03:04Z] hello"); + expect(body).toBe("[WebChat Thu 2025-01-02T03:04:05Z] hello"); }); }); it("formats timestamps in user timezone when configured", () => { - const ts = Date.UTC(2025, 0, 2, 3, 4); // 2025-01-02T03:04:00Z (04:04 CET) + const ts = Date.UTC(2025, 0, 2, 3, 4, 5); // 2025-01-02T03:04:05Z (04:04:05 CET) const body = formatAgentEnvelope({ channel: "WebChat", timestamp: ts, @@ -60,7 +60,7 @@ describe("formatAgentEnvelope", () => { body: "hello", }); - expect(body).toMatch(/\[WebChat Thu 2025-01-02 04:04 [^\]]+\] hello/); + expect(body).toMatch(/\[WebChat Thu 2025-01-02 04:04:05 [^\]]+\] hello/); }); it("omits timestamps when configured", () => { diff --git a/src/auto-reply/envelope.ts b/src/auto-reply/envelope.ts index dc1d688eddfe..fbac44885a5e 100644 --- a/src/auto-reply/envelope.ts +++ b/src/auto-reply/envelope.ts @@ -142,10 +142,10 @@ export function formatEnvelopeTimestamp( const formatted = zone.mode === "utc" - ? formatUtcTimestamp(date) + ? formatUtcTimestamp(date, { displaySeconds: true }) : zone.mode === "local" - ? formatZonedTimestamp(date) - : formatZonedTimestamp(date, { timeZone: zone.timeZone }); + ? formatZonedTimestamp(date, { displaySeconds: true }) + : formatZonedTimestamp(date, { timeZone: zone.timeZone, displaySeconds: true }); if (!formatted) { return undefined; diff --git a/src/plugin-sdk/test-helpers/envelope-timestamp.ts b/src/plugin-sdk/test-helpers/envelope-timestamp.ts index bdbcf8a9e272..1c2add763d7e 100644 --- a/src/plugin-sdk/test-helpers/envelope-timestamp.ts +++ b/src/plugin-sdk/test-helpers/envelope-timestamp.ts @@ -27,14 +27,18 @@ export function formatEnvelopeTimestamp(date: Date, zone: EnvelopeTimestampZone })(); if (normalized === "utc" || normalized === "gmt") { - const ts = formatUtcTimestamp(date); + const ts = formatUtcTimestamp(date, { displaySeconds: true }); return weekday ? `${weekday} ${ts}` : ts; } if (normalized === "local" || normalized === "host") { - const ts = formatZonedTimestamp(date) ?? formatUtcTimestamp(date); + const ts = + formatZonedTimestamp(date, { displaySeconds: true }) ?? + formatUtcTimestamp(date, { displaySeconds: true }); return weekday ? `${weekday} ${ts}` : ts; } - const ts = formatZonedTimestamp(date, { timeZone: trimmedZone }) ?? formatUtcTimestamp(date); + const ts = + formatZonedTimestamp(date, { timeZone: trimmedZone, displaySeconds: true }) ?? + formatUtcTimestamp(date, { displaySeconds: true }); return weekday ? `${weekday} ${ts}` : ts; }