Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(autopilots): label the webhook event-filter add/remove controls (MUL-6451) (#7304)
Bohan Jiangfc15a297ee1d
diff --git a/packages/views/autopilots/components/webhook-event-filter-section.test.tsx b/packages/views/autopilots/components/webhook-event-filter-section.test.tsxnew file mode 100644index 0000000000..ee26c0b8d2--- /dev/null+++ b/packages/views/autopilots/components/webhook-event-filter-section.test.tsx@@ -0,0 +1,77 @@+import { describe, it, expect, vi } from "vitest";+import { screen, fireEvent } from "@testing-library/react";+import { renderWithI18n } from "../../test/i18n";+import { WebhookEventFilterSection } from "./webhook-event-filter-section";++// The two icon-only controls in this section used to render with no+// accessible name at all, so a screen reader announced a bare "button" and+// sighted users had nothing telling them the row still had to be committed.+// getByRole(..., { name }) is the assertion that keeps them named.++describe("WebhookEventFilterSection", () => {+ it("names the add control instead of shipping a bare + icon", () => {+ renderWithI18n(<WebhookEventFilterSection filters={[]} onChange={vi.fn()} />);+ expect(screen.getByRole("button", { name: "Add" })).toBeInTheDocument();+ });++ it("names the remove control on a committed row", () => {+ renderWithI18n(+ <WebhookEventFilterSection+ filters={[{ event: "workflow_run", actions: ["completed"] }]}+ onChange={vi.fn()}+ />,+ );+ expect(+ screen.getByRole("button", { name: "Remove filter" }),+ ).toBeInTheDocument();+ });++ it("keeps add disabled until an event is typed", () => {+ renderWithI18n(<WebhookEventFilterSection filters={[]} onChange={vi.fn()} />);+ const add = screen.getByRole("button", { name: "Add" });+ expect(add).toBeDisabled();++ fireEvent.change(screen.getByPlaceholderText("e.g. workflow_run"), {+ target: { value: "workflow_run" },+ });+ expect(add).toBeEnabled();+ });++ it("stays disabled for whitespace-only input", () => {+ renderWithI18n(<WebhookEventFilterSection filters={[]} onChange={vi.fn()} />);+ fireEvent.change(screen.getByPlaceholderText("e.g. workflow_run"), {+ target: { value: " " },+ });+ expect(screen.getByRole("button", { name: "Add" })).toBeDisabled();+ });++ it("commits the row through onChange when add is clicked", () => {+ const onChange = vi.fn();+ renderWithI18n(<WebhookEventFilterSection filters={[]} onChange={onChange} />);+ fireEvent.change(screen.getByPlaceholderText("e.g. workflow_run"), {+ target: { value: "workflow_run" },+ });+ fireEvent.change(screen.getByPlaceholderText("completed, failed"), {+ target: { value: "completed, failed" },+ });+ fireEvent.click(screen.getByRole("button", { name: "Add" }));++ expect(onChange).toHaveBeenCalledWith([+ { event: "workflow_run", actions: ["completed", "failed"] },+ ]);+ });++ it("drops the row from the list when remove is clicked", () => {+ const onChange = vi.fn();+ renderWithI18n(+ <WebhookEventFilterSection+ filters={[{ event: "issues" }, { event: "workflow_run" }]}+ onChange={onChange}+ />,+ );+ fireEvent.click(+ screen.getAllByRole("button", { name: "Remove filter" })[1]!,+ );+ expect(onChange).toHaveBeenCalledWith([{ event: "issues" }]);+ });+});diff --git a/packages/views/autopilots/components/webhook-event-filter-section.tsx b/packages/views/autopilots/components/webhook-event-filter-section.tsxindex 26d3b88668..6a97023c10 100644--- a/packages/views/autopilots/components/webhook-event-filter-section.tsx+++ b/packages/views/autopilots/components/webhook-event-filter-section.tsx@@ -75,6 +75,8 @@ export function WebhookEventFilterSection({<buttontype="button"onClick={() => removeFilter(idx)}+ aria-label={t(($) => $.dialog.event_filter_remove_label)}+ title={t(($) => $.dialog.event_filter_remove_label)}className="ml-auto rounded p-0.5 text-muted-foreground hover:text-foreground hover:bg-muted transition-colors"><X className="size-3" />@@ -116,13 +118,14 @@ export function WebhookEventFilterSection({onClick={addFilter}disabled={!newEvent.trim()}className={cn(- "inline-flex items-center justify-center rounded-md border px-2.5 py-1.5 text-caption font-medium transition-colors",+ "inline-flex shrink-0 items-center justify-center gap-1 rounded-md border px-2.5 py-1.5 text-caption font-medium transition-colors",newEvent.trim()- ? "bg-background text-foreground hover:bg-accent/40 cursor-pointer"+ ? "border-primary bg-primary text-primary-foreground hover:bg-primary/90 cursor-pointer": "bg-muted text-muted-foreground cursor-not-allowed",)}><Plus className="size-3.5" />+ {t(($) => $.dialog.event_filter_add)}</button></div><p className="text-micro text-muted-foreground">diff --git a/packages/views/locales/en/autopilots.json b/packages/views/locales/en/autopilots.jsonindex 1c2877ebfe..247e782da0 100644--- a/packages/views/locales/en/autopilots.json+++ b/packages/views/locales/en/autopilots.json@@ -309,6 +309,8 @@"event_filter_docs_link_label": "Learn how event filters work","event_filter_event_placeholder": "e.g. workflow_run","event_filter_actions_placeholder": "completed, failed",+ "event_filter_add": "Add",+ "event_filter_remove_label": "Remove filter","event_filter_hint": "Only process webhooks matching these events. Leave empty to accept all.","schedule_disabled_reason": "This autopilot has multiple schedules — edit them in the detail page.","schedule_empty": "No schedule — this autopilot only runs when triggered manually.",diff --git a/packages/views/locales/ja/autopilots.json b/packages/views/locales/ja/autopilots.jsonindex a514225fd3..6cf49b0047 100644--- a/packages/views/locales/ja/autopilots.json+++ b/packages/views/locales/ja/autopilots.json@@ -309,6 +309,8 @@"event_filter_docs_link_label": "イベントフィルターの仕組みを学ぶ","event_filter_event_placeholder": "例: workflow_run","event_filter_actions_placeholder": "completed, failed",+ "event_filter_add": "追加",+ "event_filter_remove_label": "フィルターを削除","event_filter_hint": "これらのイベントに一致する Webhook のみを処理します。空にするとすべて許可します。","schedule_disabled_reason": "このオートパイロットには複数のスケジュールがあります。詳細ページで編集してください。","schedule_empty": "スケジュールはありません。このオートパイロットは手動で実行したときだけ動きます。",diff --git a/packages/views/locales/ko/autopilots.json b/packages/views/locales/ko/autopilots.jsonindex 501edfce5a..60f1fe9dde 100644--- a/packages/views/locales/ko/autopilots.json+++ b/packages/views/locales/ko/autopilots.json@@ -309,6 +309,8 @@"event_filter_docs_link_label": "이벤트 필터 작동 방식 알아보기","event_filter_event_placeholder": "예: workflow_run","event_filter_actions_placeholder": "completed, failed",+ "event_filter_add": "추가",+ "event_filter_remove_label": "필터 제거","event_filter_hint": "이 이벤트와 일치하는 Webhook만 처리합니다. 비워 두면 모두 허용합니다.","schedule_disabled_reason": "이 오토파일럿에는 여러 일정이 있습니다. 상세 페이지에서 수정하세요.","schedule_empty": "일정이 없습니다. 이 오토파일럿은 수동으로 실행할 때만 동작합니다.",diff --git a/packages/views/locales/zh-Hans/autopilots.json b/packages/views/locales/zh-Hans/autopilots.jsonindex 247d9180fe..9e0b9a8a18 100644--- a/packages/views/locales/zh-Hans/autopilots.json+++ b/packages/views/locales/zh-Hans/autopilots.json@@ -309,6 +309,8 @@"event_filter_docs_link_label": "了解事件过滤的工作方式","event_filter_event_placeholder": "例如 workflow_run","event_filter_actions_placeholder": "completed, failed",+ "event_filter_add": "添加",+ "event_filter_remove_label": "移除过滤条件","event_filter_hint": "只处理匹配这些事件的 webhook。留空则接受所有事件。","schedule_disabled_reason": "该自动化有多个时间表——请到详情页编辑。","schedule_empty": "还没有时间表——这个自动化只在手动触发时运行。",