@@ -183,6 +183,52 @@ class WorkflowsTest < ActiveSupport::TestCase
183183 assert_equal ( { 'bc_num_hours' => '1' , 'auto_queues' => 'batch' , 'afterok' => [ '1234' ] , 'ood_workflow_sync_key' => 'abc123TOKEN' } , with_key )
184184 end
185185
186+ class PositionalHashSubmitAdapter
187+ def submit ( _script , _opts = { } ) ; end
188+ end
189+
190+ class KeywordSubmitAdapter
191+ def submit ( _script , after : [ ] , afterok : [ ] , afternotok : [ ] , afterany : [ ] ) ; end
192+ end
193+
194+ class KeyrestSubmitAdapter
195+ def submit ( _script , **_kwargs ) ; end
196+ end
197+
198+ test 'supported? returns false when no job clusters exist' do
199+ Configuration . stubs ( :job_clusters ) . returns ( [ ] )
200+ assert_equal false , Workflow . supported?
201+ end
202+
203+ test 'supported? returns false when submit does not accept dependency keywords' do
204+ Configuration . stubs ( :job_clusters ) . returns ( [ OpenStruct . new ( job_adapter : PositionalHashSubmitAdapter . new ) ] )
205+ assert_equal false , Workflow . supported?
206+ end
207+
208+ test 'supported? returns true when submit accepts dependency keywords' do
209+ Configuration . stubs ( :job_clusters ) . returns ( [ OpenStruct . new ( job_adapter : KeywordSubmitAdapter . new ) ] )
210+ assert_equal true , Workflow . supported?
211+ end
212+
213+ test 'supported? returns true when submit accepts arbitrary keywords' do
214+ Configuration . stubs ( :job_clusters ) . returns ( [ OpenStruct . new ( job_adapter : KeyrestSubmitAdapter . new ) ] )
215+ assert_equal true , Workflow . supported?
216+ end
217+
218+ test 'supported? honors OOD_DASHBOARD_WORKFLOWS_ENABLED=false override' do
219+ Configuration . stubs ( :job_clusters ) . returns ( [ OpenStruct . new ( job_adapter : KeywordSubmitAdapter . new ) ] )
220+ with_modified_env ( OOD_DASHBOARD_WORKFLOWS_ENABLED : 'false' ) do
221+ assert_equal false , Workflow . supported?
222+ end
223+ end
224+
225+ test 'supported? honors OOD_DASHBOARD_WORKFLOWS_ENABLED=true override' do
226+ Configuration . stubs ( :job_clusters ) . returns ( [ ] )
227+ with_modified_env ( OOD_DASHBOARD_WORKFLOWS_ENABLED : 'true' ) do
228+ assert_equal true , Workflow . supported?
229+ end
230+ end
231+
186232 def create_workflow ( id : nil , name : 'test-workflow' , description : 'description' , project_dir : nil , launcher_ids : [ ] , sync_key_enabled : '0' )
187233 attrs = { name : name , id : id , description : description , project_dir : project_dir , launcher_ids : launcher_ids , sync_key_enabled : sync_key_enabled }
188234 workflow = Workflow . new ( attrs )
0 commit comments