diff --git a/desktop/src/features/workflows/ui/WorkflowConditionBuilder.tsx b/desktop/src/features/workflows/ui/WorkflowConditionBuilder.tsx index ce5aaf1bb..92c1e4f6a 100644 --- a/desktop/src/features/workflows/ui/WorkflowConditionBuilder.tsx +++ b/desktop/src/features/workflows/ui/WorkflowConditionBuilder.tsx @@ -35,6 +35,19 @@ const OPERATOR_LABELS: Record = { is_empty: "is empty", }; +function operatorLabel( + field: string, + operator: ConditionOperator, + usesExactMatchOperators: boolean, +): string { + if (usesExactMatchOperators && operator === "equals") return "is"; + if (field === "trigger_text") { + if (operator === "is_not_empty") return "has text"; + if (operator === "is_empty") return "has no text"; + } + return OPERATOR_LABELS[operator]; +} + type ConditionEditorState = { custom: boolean; editors: ParsedConditionExpression[]; @@ -141,9 +154,7 @@ function ConditionEditorControls({ > {operatorOptions.map((operator) => ( ))} diff --git a/desktop/src/features/workflows/ui/workflowTriggerDescription.test.mjs b/desktop/src/features/workflows/ui/workflowTriggerDescription.test.mjs index 6edf828d2..7bbcd1849 100644 --- a/desktop/src/features/workflows/ui/workflowTriggerDescription.test.mjs +++ b/desktop/src/features/workflows/ui/workflowTriggerDescription.test.mjs @@ -23,6 +23,22 @@ test("describes selected trigger conditions on the workflow canvas", () => { "Message posted containing “deploy”", ); + assert.equal( + workflowTriggerDescription({ + on: "message_posted", + filter: "str_len(trigger_text) == 0", + }), + "Message posted without text", + ); + + assert.equal( + workflowTriggerDescription({ + on: "message_posted", + filter: "str_len(trigger_text) > 0", + }), + "Text message posted", + ); + assert.equal( workflowTriggerDescription({ on: "reaction_added", diff --git a/desktop/src/features/workflows/ui/workflowTriggerDescription.ts b/desktop/src/features/workflows/ui/workflowTriggerDescription.ts index df81c4885..7f932119c 100644 --- a/desktop/src/features/workflows/ui/workflowTriggerDescription.ts +++ b/desktop/src/features/workflows/ui/workflowTriggerDescription.ts @@ -49,9 +49,11 @@ function textConditionDescription( case "not_equals": return `${eventPhrase} not matching ${value}`; case "is_not_empty": - return `Non-empty ${eventPhrase.toLowerCase()}`; + return eventPhrase === "Message posted" + ? "Text message posted" + : `${eventPhrase} containing text`; case "is_empty": - return `Empty ${eventPhrase.toLowerCase()}`; + return `${eventPhrase} without text`; } } diff --git a/desktop/tests/e2e/workflows.spec.ts b/desktop/tests/e2e/workflows.spec.ts index 796e0e5f7..f64be22a0 100644 --- a/desktop/tests/e2e/workflows.spec.ts +++ b/desktop/tests/e2e/workflows.spec.ts @@ -297,6 +297,13 @@ test("builds a valid trigger condition from plain-language choices", async ({ await conditionFields.getByRole("button", { name: "Message text" }).click(); await expect(allMessages).toHaveAttribute("aria-pressed", "false"); + const matchSelect = inspector.getByLabel("Match"); + await expect(matchSelect.locator('option[value="is_not_empty"]')).toHaveText( + "has text", + ); + await expect(matchSelect.locator('option[value="is_empty"]')).toHaveText( + "has no text", + ); await inspector.getByLabel("Text to match").fill('deploy "buzz"'); await dialog.getByRole("tab", { name: "YAML" }).click(); await expect(dialog.getByLabel("Workflow YAML")).toHaveValue(