superbot-cloud 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 86fa0ee22ce6e47a516e9f7fd783ac0d6a4fcd49b3639f7347c0d0b165b35a47
4
- data.tar.gz: 9007753775905fd31d4c4dbe9e82e64d9f85e85e6445c6171a8884f5a4f5a2e3
3
+ metadata.gz: 6474827e46f3fda75cd8ba484cb27b98716c9808328e407d9ea2537099aac09d
4
+ data.tar.gz: a0043c715428a6c261eaa58655cd2f281cd85705fea6775653f95a995ffa1b35
5
5
  SHA512:
6
- metadata.gz: 76b83eb1e626919c24494a059e98cec1d0cb2e448403d28e29b0a797d58fd71df4e70951ef387c1eb86e3dcfc66af6099345c27706d46ea2b9cfe35cc18c24f0
7
- data.tar.gz: 334b300119cf0ed6700a482cff750e86550e1b281f712c15825b0d895cacdcc4d685b58088176a62e92983ba37dcc8ed6967ee7e90a2495a481a5268813ab120
6
+ metadata.gz: a52936c87c8ea7bc3f684e89a03dcd91c5c953fe1ce0ef4b868fd370fed11355a686ad4e1436201405cfdb8936023157e2c8097ce0dd3084276e524e63c94eb0
7
+ data.tar.gz: 4a6b35802c08279bdd63bdbe2765b46a9c338314e0b3d86e55371daaaf66cf1db82b140f98256e41b5267f21e08f06de1246dd7eee60216619d99cccb7947e51
data/Gemfile.lock CHANGED
@@ -1,11 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- superbot-cloud (0.1.1)
4
+ superbot-cloud (0.1.2)
5
+ capybara (~> 3.6, >= 3.6.0)
5
6
  clamp (= 1.2.1)
6
7
  launchy (= 2.4.3)
7
8
  marcel (= 0.3.3)
8
9
  multipart-post (= 2.0.0)
10
+ selenium-webdriver (~> 3.14, >= 3.14.0)
9
11
  sinatra (= 2.0.3)
10
12
  sinatra-silent (= 0.0.1)
11
13
  superbot (~> 0.1.2)
@@ -17,8 +19,19 @@ GEM
17
19
  addressable (2.5.2)
18
20
  public_suffix (>= 2.0.2, < 4.0)
19
21
  ast (2.4.0)
22
+ capybara (3.10.0)
23
+ addressable
24
+ mini_mime (>= 0.1.3)
25
+ nokogiri (~> 1.8)
26
+ rack (>= 1.6.0)
27
+ rack-test (>= 0.6.3)
28
+ regexp_parser (~> 1.2)
29
+ xpath (~> 3.2)
30
+ childprocess (0.9.0)
31
+ ffi (~> 1.0, >= 1.0.11)
20
32
  clamp (1.2.1)
21
33
  diff-lcs (1.3)
34
+ ffi (1.9.25)
22
35
  jaro_winkler (1.5.1)
23
36
  kommando (0.1.2)
24
37
  launchy (2.4.3)
@@ -26,8 +39,12 @@ GEM
26
39
  marcel (0.3.3)
27
40
  mimemagic (~> 0.3.2)
28
41
  mimemagic (0.3.2)
42
+ mini_mime (1.0.1)
43
+ mini_portile2 (2.3.0)
29
44
  multipart-post (2.0.0)
30
45
  mustermann (1.0.3)
46
+ nokogiri (1.8.5)
47
+ mini_portile2 (~> 2.3.0)
31
48
  parallel (1.12.1)
32
49
  parser (2.5.1.2)
33
50
  ast (~> 2.4.0)
@@ -36,8 +53,11 @@ GEM
36
53
  rack (2.0.5)
37
54
  rack-protection (2.0.3)
38
55
  rack
56
+ rack-test (1.1.0)
57
+ rack (>= 1.0, < 3)
39
58
  rainbow (3.0.0)
40
59
  rake (10.5.0)
60
+ regexp_parser (1.2.0)
41
61
  rspec (3.8.0)
42
62
  rspec-core (~> 3.8.0)
43
63
  rspec-expectations (~> 3.8.0)
@@ -60,13 +80,17 @@ GEM
60
80
  ruby-progressbar (~> 1.7)
61
81
  unicode-display_width (~> 1.0, >= 1.0.1)
62
82
  ruby-progressbar (1.10.0)
83
+ rubyzip (1.2.2)
84
+ selenium-webdriver (3.14.1)
85
+ childprocess (~> 0.5)
86
+ rubyzip (~> 1.2, >= 1.2.2)
63
87
  sinatra (2.0.3)
64
88
  mustermann (~> 1.0)
65
89
  rack (~> 2.0)
66
90
  rack-protection (= 2.0.3)
67
91
  tilt (~> 2.0)
68
92
  sinatra-silent (0.0.1)
69
- superbot (0.1.2)
93
+ superbot (0.1.3)
70
94
  clamp (= 1.2.1)
71
95
  launchy (= 2.4.3)
72
96
  sinatra (= 2.0.3)
@@ -74,6 +98,8 @@ GEM
74
98
  zaru (= 0.2.0)
75
99
  tilt (2.0.8)
76
100
  unicode-display_width (1.4.0)
101
+ xpath (3.2.0)
102
+ nokogiri (~> 1.8)
77
103
  zaru (0.2.0)
78
104
 
79
105
  PLATFORMS
@@ -88,4 +114,4 @@ DEPENDENCIES
88
114
  superbot-cloud!
89
115
 
90
116
  BUNDLED WITH
91
- 1.16.4
117
+ 1.16.6
@@ -5,7 +5,7 @@ require 'net/http/post/multipart'
5
5
  module Superbot
6
6
  module Cloud
7
7
  module Api
8
- BASE_URI = "https://superapp-production.herokuapp.com/api/v1"
8
+ BASE_URI = "http://www.superbot.cloud/api/v1"
9
9
  ENDPOINT_MAP = {
10
10
  login: { method: :post, endpoint: 'sessions' },
11
11
  token: { method: :post, endpoint: 'token' },
@@ -0,0 +1,98 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "selenium/webdriver"
4
+ require "capybara"
5
+ require "capybara/dsl"
6
+
7
+ module Superbot
8
+ module CLI
9
+ module Cloud
10
+ class RunCommand < Clamp::Command
11
+ include Superbot::Validations
12
+
13
+ option ['--region'], 'REGION', 'Region for remote webdriver'
14
+
15
+ parameter "PATH", "the path to folder containing tests to upload" do |path|
16
+ validates_project_path path
17
+ end
18
+
19
+ def execute
20
+ register_remote_webdriver
21
+ open_screenshots_stream
22
+ run_test
23
+
24
+ puts 'Press ENTER to exit.'
25
+ $stdin.gets
26
+
27
+ close_screenshot_stream
28
+ end
29
+
30
+ private
31
+
32
+ def register_remote_webdriver
33
+ puts "Attaching to remote webdriver..."
34
+
35
+ ::Capybara.register_driver :chrome_remote do |app|
36
+ ::Capybara::Selenium::Driver.new(
37
+ app,
38
+ browser: :remote,
39
+ desired_capabilities: webdriver_capabilities,
40
+ http_client: webriver_http_client,
41
+ url: Superbot::Cloud.webdriver_url
42
+ )
43
+ end
44
+
45
+ ::Capybara.current_driver = :chrome_remote
46
+ end
47
+
48
+ def webdriver_capabilities
49
+ ::Selenium::WebDriver::Remote::Capabilities.chrome(
50
+ chromeOptions: {
51
+ 'args' => [
52
+ "--no-sandbox",
53
+ "--disable-infobars",
54
+ "--start-minimized",
55
+ "--app=about:blank"
56
+ ]
57
+ },
58
+ superOptions: region && { region: region } || {}
59
+ )
60
+ end
61
+
62
+ def webriver_http_client
63
+ ::Selenium::WebDriver::Remote::Http::Default.new.tap do |client|
64
+ client.read_timeout = 2000
65
+ client.open_timeout = 2000
66
+ end
67
+ end
68
+
69
+ def open_screenshots_stream
70
+ session_id = ::Capybara.current_session.driver.browser.send(:bridge).session_id
71
+ puts "Opening test stream..."
72
+ screenshots_url = Superbot::Cloud.screenshots_url(session_id)
73
+ options = ::Selenium::WebDriver::Chrome::Options.new
74
+ options.add_argument("app=#{screenshots_url}")
75
+ @screenshots_stream = ::Selenium::WebDriver.for(:chrome, options: options)
76
+ rescue ::Selenium::WebDriver::Error::ServerError => e
77
+ abort "Remote webdriver error: #{e.message}"
78
+ end
79
+
80
+ def close_screenshot_stream
81
+ @screenshots_stream&.quit
82
+ end
83
+
84
+ def run_test
85
+ puts "Running test..."
86
+ ::Capybara.send(:eval, test_script)
87
+ puts "Succeed!"
88
+ rescue ::Capybara::CapybaraError => e
89
+ puts "Test failed!", e.message
90
+ end
91
+
92
+ def test_script
93
+ @test_script ||= File.read(File.join(path, 'main.rb'))
94
+ end
95
+ end
96
+ end
97
+ end
98
+ end
@@ -5,14 +5,16 @@ require_relative 'cloud/login_command'
5
5
  require_relative 'cloud/version_command'
6
6
  require_relative 'cloud/organization_command'
7
7
  require_relative 'cloud/test_command'
8
+ require_relative 'cloud/run_command'
8
9
 
9
10
  module Superbot
10
11
  module CLI
11
12
  class CloudCommand < Clamp::Command
12
- subcommand ['version'], "Superbot cloud version", Cloud::VersionCommand
13
- subcommand ['login'], "Login to superbot cloud", Cloud::LoginCommand
14
- subcommand ['org'], "Manage your organizations", Cloud::OrganizationCommand
13
+ subcommand ['version'], 'Superbot cloud version', Cloud::VersionCommand
14
+ subcommand ['login'], 'Login to superbot cloud', Cloud::LoginCommand
15
+ subcommand ['org'], 'Manage your organizations', Cloud::OrganizationCommand
15
16
  subcommand ['test'], "Manage your tests", Cloud::TestCommand
17
+ subcommand ['run'], "Run your test in the cloud", Cloud::RunCommand
16
18
 
17
19
  def self.run
18
20
  super
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Superbot
4
4
  module Cloud
5
- VERSION = "0.1.1"
5
+ VERSION = "0.1.2"
6
6
  end
7
7
  end
@@ -2,9 +2,18 @@
2
2
 
3
3
  module Superbot
4
4
  module Cloud
5
- LOGIN_URI = 'https://superapp-production.herokuapp.com/login/cloud'
5
+ LOGIN_URI = 'http://www.superbot.cloud/login/cloud'
6
6
  CREDENTIALS_PATH = File.join(Dir.home, '.superbot')
7
7
  CREDENTIALS_FILE_PATH = File.join(CREDENTIALS_PATH, 'cloud_token.json')
8
+ SCREENSHOTS_BASE_URL = {
9
+ local: "http://localhost:3002/v1",
10
+ remote: "http://peek.superbot.cloud/v1"
11
+ }.freeze
12
+ WEBDRIVER_URL = {
13
+ local: "http://localhost:3000/webdriver/v1",
14
+ remote: "http://webdriver.superbot.cloud:3000/webdriver/v1"
15
+ }.freeze
16
+ WEBDRIVER_TYPE = :remote # use :local if you are running superbot webdriver cluster locally
8
17
 
9
18
  def self.credentials
10
19
  return unless File.exist?(CREDENTIALS_FILE_PATH)
@@ -20,6 +29,14 @@ module Superbot
20
29
  puts message
21
30
  end
22
31
  end
32
+
33
+ def self.webdriver_url
34
+ WEBDRIVER_URL[WEBDRIVER_TYPE]
35
+ end
36
+
37
+ def self.screenshots_url(session_id)
38
+ "#{SCREENSHOTS_BASE_URL[WEBDRIVER_TYPE]}/#{session_id}"
39
+ end
23
40
  end
24
41
  end
25
42
 
@@ -41,6 +41,8 @@ Gem::Specification.new do |spec|
41
41
  spec.add_runtime_dependency "launchy", "2.4.3"
42
42
  spec.add_runtime_dependency "sinatra-silent", "0.0.1"
43
43
  spec.add_runtime_dependency "marcel", "0.3.3"
44
+ spec.add_runtime_dependency 'selenium-webdriver', '~> 3.14', '>= 3.14.0'
45
+ spec.add_runtime_dependency 'capybara', '~> 3.6', '>= 3.6.0'
44
46
 
45
47
  spec.add_development_dependency "kommando", "~> 0.1"
46
48
  spec.add_development_dependency "bundler", "~> 1.16"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: superbot-cloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Superbots
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-10-15 00:00:00.000000000 Z
11
+ date: 2018-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multipart-post
@@ -122,6 +122,46 @@ dependencies:
122
122
  - - '='
123
123
  - !ruby/object:Gem::Version
124
124
  version: 0.3.3
125
+ - !ruby/object:Gem::Dependency
126
+ name: selenium-webdriver
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '3.14'
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: 3.14.0
135
+ type: :runtime
136
+ prerelease: false
137
+ version_requirements: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - "~>"
140
+ - !ruby/object:Gem::Version
141
+ version: '3.14'
142
+ - - ">="
143
+ - !ruby/object:Gem::Version
144
+ version: 3.14.0
145
+ - !ruby/object:Gem::Dependency
146
+ name: capybara
147
+ requirement: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - "~>"
150
+ - !ruby/object:Gem::Version
151
+ version: '3.6'
152
+ - - ">="
153
+ - !ruby/object:Gem::Version
154
+ version: 3.6.0
155
+ type: :runtime
156
+ prerelease: false
157
+ version_requirements: !ruby/object:Gem::Requirement
158
+ requirements:
159
+ - - "~>"
160
+ - !ruby/object:Gem::Version
161
+ version: '3.6'
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ version: 3.6.0
125
165
  - !ruby/object:Gem::Dependency
126
166
  name: kommando
127
167
  requirement: !ruby/object:Gem::Requirement
@@ -221,6 +261,7 @@ files:
221
261
  - lib/superbot/cloud/cli/cloud/login_command.rb
222
262
  - lib/superbot/cloud/cli/cloud/organization/list_command.rb
223
263
  - lib/superbot/cloud/cli/cloud/organization_command.rb
264
+ - lib/superbot/cloud/cli/cloud/run_command.rb
224
265
  - lib/superbot/cloud/cli/cloud/test/delete_command.rb
225
266
  - lib/superbot/cloud/cli/cloud/test/list_command.rb
226
267
  - lib/superbot/cloud/cli/cloud/test/upload_command.rb