Skip to content

Commit cd170ea

Browse files
committed
Add test case and fix for Jobs indicator
1 parent d229670 commit cd170ea

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

lib/lightning_web/live/workflow_live/edit.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3078,7 +3078,7 @@ defmodule LightningWeb.WorkflowLive.Edit do
30783078
jobs
30793079
|> Enum.map(& &1["id"])
30803080
|> Jobs.filter_with_chat_user(current_user)
3081-
|> MapSet.new()
3081+
|> MapSet.new(& &1.id)
30823082

30833083
Map.update(workflow_params, "jobs", [], fn jobs ->
30843084
Enum.map(jobs, fn job ->

test/lightning_web/live/workflow_live/edit_test.exs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2352,6 +2352,31 @@ defmodule LightningWeb.WorkflowLive.EditTest do
23522352
# manual run form body is cleared
23532353
refute view |> element("#manual_run_form") |> render() =~ body_part
23542354
end
2355+
2356+
test "Indicates a job has AI chat", %{
2357+
conn: conn,
2358+
project: project,
2359+
workflow: workflow,
2360+
user: user
2361+
} do
2362+
[job1 | _jobs] = workflow.jobs
2363+
2364+
insert(:chat_session,
2365+
user: user,
2366+
job: dbg(job1),
2367+
messages: [%{role: :user, content: "what?", user: user}]
2368+
)
2369+
2370+
{:ok, view, _html} =
2371+
live(conn, ~p"/projects/#{project.id}/w/#{workflow.id}")
2372+
2373+
render_hook(view, "get-current-state", %{})
2374+
2375+
assert_reply(view, %{workflow_params: %{"jobs" => reply_jobs}})
2376+
2377+
assert Enum.find(reply_jobs, & &1["id"] == job1.id and &1["has_ai_chat"])
2378+
refute Enum.find(reply_jobs, & &1["id"] != job1.id and &1["has_ai_chat"])
2379+
end
23552380
end
23562381

23572382
describe "Tracking Workflow editor metrics" do

0 commit comments

Comments
 (0)