Merge branch '9857-cwl-acceptlist-re' refs #9857
[arvados.git] / apps / workbench / test / helpers / fake_websocket_helper.rb
1 module FakeWebsocketHelper
2   def use_fake_websocket_driver
3     Capybara.current_driver = :poltergeist_with_fake_websocket
4   end
5
6   def fake_websocket_event(logdata)
7     stamp = Time.now.utc.in_time_zone.as_json
8     defaults = {
9       owner_uuid: api_fixture('users')['system_user']['uuid'],
10       event_at: stamp,
11       created_at: stamp,
12       updated_at: stamp,
13     }
14     event = {data: Oj.dump(defaults.merge(logdata), mode: :compat)}
15     script = '$(window).data("arv-websocket").onmessage('+Oj.dump(event, mode: :compat)+');'
16     page.evaluate_script(script)
17   end
18 end