























@@ -2,7 +2,7 @@ import { describe, expect, it } from "vitest";
22import {
33createEmbeddedRunStageTracker,
44formatEmbeddedRunStageSummary,
5-shouldEmitEmbeddedRunStageSummary,
5+shouldWarnEmbeddedRunStageSummary,
66} from "./attempt-stage-timing.js";
7788describe("embedded run stage timing", () => {
@@ -25,30 +25,28 @@ describe("embedded run stage timing", () => {
2525});
2626});
272728-it("emits only slow stage summaries", () => {
28+it("warns only for very slow stage summaries by default", () => {
2929expect(
30-shouldEmitEmbeddedRunStageSummary(
31-{
32-totalMs: 1_999,
33-stages: [{ name: "auth", durationMs: 999, elapsedMs: 999 }],
34-},
35-{ totalThresholdMs: 2_000, stageThresholdMs: 1_000 },
36-),
30+shouldWarnEmbeddedRunStageSummary({
31+totalMs: 9_999,
32+stages: [{ name: "auth", durationMs: 4_999, elapsedMs: 4_999 }],
33+}),
3734).toBe(false);
35+expect(shouldWarnEmbeddedRunStageSummary({ totalMs: 10_000, stages: [] })).toBe(true);
3836expect(
39-shouldEmitEmbeddedRunStageSummary(
40-{
41-totalMs: 2_000,
42-stages: [{ name: "auth", durationMs: 10, elapsedMs: 10 }],
43-},
44-{ totalThresholdMs: 2_000, stageThresholdMs: 1_000 },
45-),
37+shouldWarnEmbeddedRunStageSummary({
38+totalMs: 10,
39+stages: [{ name: "auth", durationMs: 5_000, elapsedMs: 5_000 }],
40+}),
4641).toBe(true);
42+});
43+44+it("supports custom warning thresholds", () => {
4745expect(
48-shouldEmitEmbeddedRunStageSummary(
46+shouldWarnEmbeddedRunStageSummary(
4947{
50-totalMs: 10,
51-stages: [{ name: "auth", durationMs: 1_000, elapsedMs: 1_000 }],
48+totalMs: 2_000,
49+stages: [{ name: "auth", durationMs: 10, elapsedMs: 10 }],
5250},
5351{ totalThresholdMs: 2_000, stageThresholdMs: 1_000 },
5452),
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。