feat: package Pi extensions as Bun workspaces
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
import { deriveRunLabel, deriveRunLabels } from "./run-label.ts";
|
||||
|
||||
test("run labels prefer feature names and normalize request fallbacks", () => {
|
||||
assert.equal(
|
||||
deriveRunLabel({
|
||||
runId: "12345678-aaaa",
|
||||
featureName: "search-page",
|
||||
request: "Ignored request",
|
||||
}),
|
||||
"search-page",
|
||||
);
|
||||
assert.equal(
|
||||
deriveRunLabel({
|
||||
runId: "12345678-bbbb",
|
||||
request: " Audit\n\tcache behavior ",
|
||||
}),
|
||||
"Audit cache behavior",
|
||||
);
|
||||
assert.equal(
|
||||
deriveRunLabel({ runId: "12345678-cccc", request: "x".repeat(48) }),
|
||||
"x".repeat(48),
|
||||
);
|
||||
});
|
||||
|
||||
test("request labels truncate at whole words and hard-cut overlong words", () => {
|
||||
assert.equal(
|
||||
deriveRunLabel({
|
||||
runId: "12345678-aaaa",
|
||||
request: "Build a searchable dashboard that clearly identifies every active workflow run",
|
||||
}),
|
||||
"Build a searchable dashboard that clearly…",
|
||||
);
|
||||
assert.equal(
|
||||
deriveRunLabel({
|
||||
runId: "12345678-bbbb",
|
||||
request: `${"one ".repeat(11)}two continued`,
|
||||
}),
|
||||
`${"one ".repeat(11)}two…`,
|
||||
);
|
||||
assert.equal(
|
||||
deriveRunLabel({ runId: "12345678-cccc", request: "x".repeat(60) }),
|
||||
`${"x".repeat(47)}…`,
|
||||
);
|
||||
});
|
||||
|
||||
test("run labels fall back to the canonical ID when requests are missing", () => {
|
||||
assert.equal(deriveRunLabel({ runId: "12345678-aaaa" }), "12345678-aaaa");
|
||||
assert.equal(
|
||||
deriveRunLabel({ runId: "12345678-bbbb", request: "" }),
|
||||
"12345678-bbbb",
|
||||
);
|
||||
});
|
||||
|
||||
test("run labels disambiguate collisions with extendable ID prefixes", () => {
|
||||
assert.deepEqual(
|
||||
deriveRunLabels([
|
||||
{ runId: "12345678-aaaa", featureName: "search-page" },
|
||||
{ runId: "12345678-bbbb", featureName: "search-page" },
|
||||
{ runId: "87654321-cccc", featureName: "other" },
|
||||
]),
|
||||
["search-page · 12345678-a", "search-page · 12345678-b", "other"],
|
||||
);
|
||||
assert.deepEqual(
|
||||
deriveRunLabels([
|
||||
{ runId: "aaaaaaaa-1111", request: "Audit cache" },
|
||||
{ runId: "bbbbbbbb-2222", request: "Audit cache" },
|
||||
]),
|
||||
["Audit cache · aaaaaaaa", "Audit cache · bbbbbbbb"],
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user