@@ -3580,6 +3580,82 @@ defmodule LightningWeb.WorkflowLive.EditTest do
3580
3580
end
3581
3581
end
3582
3582
3583
+ describe "keyboard shortcuts" do
3584
+ setup % { project: project } do
3585
+ workflow =
3586
+ insert ( :simple_workflow , project: project )
3587
+ |> with_snapshot ( )
3588
+ { :ok , workflow: workflow }
3589
+ end
3590
+
3591
+ test "OpenRunPanelViaCtrlEnter hook is attached to workflow editor" , % {
3592
+ conn: conn ,
3593
+ project: project ,
3594
+ workflow: workflow
3595
+ } do
3596
+ { :ok , view , _html } =
3597
+ live (
3598
+ conn ,
3599
+ ~p" /projects/#{ project . id } /w/#{ workflow . id } " ,
3600
+ on_error: :raise
3601
+ )
3602
+
3603
+ # Check that the OpenRunPanelViaCtrlEnter hook is present on the workflow container
3604
+ workflow_container = view |> element ( "#workflow-edit-#{ workflow . id } " )
3605
+ assert has_element? ( workflow_container )
3606
+ assert render ( workflow_container ) =~ "phx-hook=\" OpenRunPanelViaCtrlEnter\" "
3607
+ assert render ( workflow_container ) =~ "data-keybinding-scope=\" workflow-editor\" "
3608
+ end
3609
+
3610
+ test "OpenRunPanelViaCtrlEnter hook is present with job selected" , % {
3611
+ conn: conn ,
3612
+ project: project ,
3613
+ workflow: workflow
3614
+ } do
3615
+ # Use the first job from the workflow that was created with snapshot
3616
+ job = workflow . jobs |> List . first ( )
3617
+
3618
+ { :ok , view , _html } =
3619
+ live (
3620
+ conn ,
3621
+ ~p" /projects/#{ project . id } /w/#{ workflow . id } ?s=#{ job . id } " ,
3622
+ on_error: :raise
3623
+ )
3624
+
3625
+ # Hook should still be present when a job is selected
3626
+ workflow_container = view |> element ( "#workflow-edit-#{ workflow . id } " )
3627
+ assert has_element? ( workflow_container )
3628
+ assert render ( workflow_container ) =~ "phx-hook=\" OpenRunPanelViaCtrlEnter\" "
3629
+ assert render ( workflow_container ) =~ "data-keybinding-scope=\" workflow-editor\" "
3630
+
3631
+ # Run button should be present for step-aware behavior
3632
+ run_button = view |> element ( "#run-from-step-#{ job . id } " )
3633
+ assert has_element? ( run_button )
3634
+ end
3635
+
3636
+ test "OpenRunPanelViaCtrlEnter hook is present in expand mode" , % {
3637
+ conn: conn ,
3638
+ project: project ,
3639
+ workflow: workflow
3640
+ } do
3641
+ # Use the first job from the workflow that was created with snapshot
3642
+ job = workflow . jobs |> List . first ( )
3643
+
3644
+ { :ok , view , _html } =
3645
+ live (
3646
+ conn ,
3647
+ ~p" /projects/#{ project . id } /w/#{ workflow . id } ?s=#{ job . id } &m=expand" ,
3648
+ on_error: :raise
3649
+ )
3650
+
3651
+ # Hook should be present even in expand mode
3652
+ workflow_container = view |> element ( "#workflow-edit-#{ workflow . id } " )
3653
+ assert has_element? ( workflow_container )
3654
+ assert render ( workflow_container ) =~ "phx-hook=\" OpenRunPanelViaCtrlEnter\" "
3655
+ assert render ( workflow_container ) =~ "data-keybinding-scope=\" workflow-editor\" "
3656
+ end
3657
+ end
3658
+
3583
3659
defp log_viewer_selected_level ( log_viewer ) do
3584
3660
log_viewer
3585
3661
|> render ( )
0 commit comments