test: tighten slack progress block assertions

This commit is contained in:
Peter Steinberger
2026-05-11 11:09:03 +01:00
parent f9016145c8
commit 37f1f5d4ab

View File

@@ -11,6 +11,16 @@ function progressLine(index: number) {
};
}
function expectProgressBlock(block: unknown, label: string, detail: string) {
expect(block).toEqual({
type: "section",
fields: [
{ type: "mrkdwn", text: `🛠️ *${label}*` },
{ type: "mrkdwn", text: detail },
],
});
}
describe("buildSlackProgressDraftBlocks", () => {
it("renders structured progress lines as compact Block Kit fields", () => {
expect(
@@ -70,26 +80,14 @@ describe("buildSlackProgressDraftBlocks", () => {
lines: Array.from({ length: 60 }, (_value, index) => progressLine(index)),
});
expect(blocksWithLabel).toHaveLength(50);
expect(blocksWithLabel?.[0]).toMatchObject({
type: "section",
fields: [{ text: "🛠️ *Exec 10*" }, { text: "run 10" }],
});
expect(blocksWithLabel?.at(-1)).toMatchObject({
type: "section",
fields: [{ text: "🛠️ *Exec 59*" }, { text: "run 59" }],
});
expectProgressBlock(blocksWithLabel?.[0], "Exec 10", "run 10");
expectProgressBlock(blocksWithLabel?.at(-1), "Exec 59", "run 59");
const blocksWithoutLabel = buildSlackProgressDraftBlocks({
lines: Array.from({ length: 60 }, (_value, index) => progressLine(index)),
});
expect(blocksWithoutLabel).toHaveLength(50);
expect(blocksWithoutLabel?.[0]).toMatchObject({
type: "section",
fields: [{ text: "🛠️ *Exec 10*" }, { text: "run 10" }],
});
expect(blocksWithoutLabel?.at(-1)).toMatchObject({
type: "section",
fields: [{ text: "🛠️ *Exec 59*" }, { text: "run 59" }],
});
expectProgressBlock(blocksWithoutLabel?.[0], "Exec 10", "run 10");
expectProgressBlock(blocksWithoutLabel?.at(-1), "Exec 59", "run 59");
});
});