feat(FN-2442): improve workflow step fallback labeling
- Resolve workflow step names by preferring lookup entries, then workflow result names, then raw step IDs - Shorten task card workflow phase badges to concise pre-merge/post-merge labels while preserving tooltip context - Expand TaskCard coverage for phase badge rendering and workflow name fallback behavior when lookup values are blank or missing
This commit is contained in:
@@ -128,7 +128,7 @@ describe("TaskCard", () => {
|
||||
expect(screen.queryByText("1 steps")).toBeNull();
|
||||
});
|
||||
|
||||
it("renders workflow checks after normal steps with mapped statuses", () => {
|
||||
it("renders workflow checks after normal steps with mapped statuses and phase badges", () => {
|
||||
const { container } = render(
|
||||
<TaskCard
|
||||
task={makeTask({
|
||||
@@ -147,6 +147,7 @@ describe("TaskCard", () => {
|
||||
workflowStepId: "WS-002",
|
||||
workflowStepName: "Frontend UX Design",
|
||||
status: "failed",
|
||||
phase: "post-merge",
|
||||
},
|
||||
],
|
||||
})}
|
||||
@@ -172,27 +173,33 @@ describe("TaskCard", () => {
|
||||
|
||||
const workflowBadges = Array.from(container.querySelectorAll(".card-step-workflow-badge")).map((el) => el.textContent);
|
||||
expect(workflowBadges).toEqual([
|
||||
"Workflow · Pre-merge",
|
||||
"Workflow · Pre-merge",
|
||||
"Workflow · Pre-merge",
|
||||
"Pre-merge",
|
||||
"Post-merge",
|
||||
"Pre-merge",
|
||||
]);
|
||||
});
|
||||
|
||||
it("falls back to raw workflow step ID when lookup is unavailable", () => {
|
||||
it("falls back to workflow result name, then raw ID when lookup names are unavailable", () => {
|
||||
const { container } = render(
|
||||
<TaskCard
|
||||
task={makeTask({
|
||||
enabledWorkflowSteps: ["WS-003"],
|
||||
workflowStepResults: [],
|
||||
enabledWorkflowSteps: ["WS-002", "WS-003"],
|
||||
workflowStepResults: [
|
||||
{
|
||||
workflowStepId: "WS-002",
|
||||
workflowStepName: "Fallback from result",
|
||||
status: "passed",
|
||||
},
|
||||
],
|
||||
})}
|
||||
workflowStepNameLookup={new Map()}
|
||||
workflowStepNameLookup={new Map([["WS-002", " "]])}
|
||||
onOpenDetail={noop}
|
||||
addToast={noop}
|
||||
/>,
|
||||
);
|
||||
|
||||
const stepNames = Array.from(container.querySelectorAll(".card-step-name")).map((el) => el.textContent);
|
||||
expect(stepNames).toEqual(["WS-003"]);
|
||||
expect(stepNames).toEqual(["Fallback from result", "WS-003"]);
|
||||
});
|
||||
|
||||
it("shows drop indicator on file dragover and removes on dragleave", () => {
|
||||
|
||||
@@ -1060,7 +1060,7 @@ function TaskCardComponent({
|
||||
className={`card-step-workflow-badge card-step-workflow-badge--${step.phase}`}
|
||||
title={step.phase === "post-merge" ? "Post-merge workflow check" : "Pre-merge workflow check"}
|
||||
>
|
||||
{step.phase === "post-merge" ? "Workflow · Post-merge" : "Workflow · Pre-merge"}
|
||||
{step.phase === "post-merge" ? "Post-merge" : "Pre-merge"}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -34,6 +34,24 @@ function isCompleted(status: UnifiedTaskProgressStatus): boolean {
|
||||
return status === "done" || status === "skipped";
|
||||
}
|
||||
|
||||
function resolveWorkflowStepName(
|
||||
workflowStepId: string,
|
||||
result: WorkflowStepResult | undefined,
|
||||
workflowStepNameLookup?: ReadonlyMap<string, string>,
|
||||
): string {
|
||||
const lookupName = workflowStepNameLookup?.get(workflowStepId)?.trim();
|
||||
if (lookupName) {
|
||||
return lookupName;
|
||||
}
|
||||
|
||||
const resultName = result?.workflowStepName?.trim();
|
||||
if (resultName) {
|
||||
return resultName;
|
||||
}
|
||||
|
||||
return workflowStepId;
|
||||
}
|
||||
|
||||
export function getUnifiedTaskProgress(
|
||||
task: Pick<Task, "steps" | "enabledWorkflowSteps" | "workflowStepResults">,
|
||||
workflowStepNameLookup?: ReadonlyMap<string, string>,
|
||||
@@ -52,10 +70,9 @@ export function getUnifiedTaskProgress(
|
||||
|
||||
const workflowItems: UnifiedTaskProgressItem[] = (task.enabledWorkflowSteps ?? []).map((workflowStepId) => {
|
||||
const result = workflowResultsById.get(workflowStepId);
|
||||
const lookupName = workflowStepNameLookup?.get(workflowStepId);
|
||||
return {
|
||||
id: `workflow-${workflowStepId}`,
|
||||
name: lookupName ?? result?.workflowStepName ?? workflowStepId,
|
||||
name: resolveWorkflowStepName(workflowStepId, result, workflowStepNameLookup),
|
||||
status: result ? mapWorkflowStatus(result.status) : "pending",
|
||||
source: "workflow",
|
||||
phase: result?.phase ?? "pre-merge",
|
||||
|
||||
Reference in New Issue
Block a user