isomorfeus-puppetmaster 0.6.13 → 0.6.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +19 -1
- data/lib/isomorfeus/puppetmaster/dsl.rb +7 -7
- data/lib/isomorfeus/puppetmaster/server/executor_middleware.rb +3 -2
- data/lib/isomorfeus/puppetmaster/session.rb +30 -14
- data/lib/isomorfeus/puppetmaster/version.rb +1 -1
- data/lib/isomorfeus-puppetmaster.rb +3 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ce8e229f1fb4ff14d811d9fa84389bde564085254aa0b02334da5a801ee2ed0
|
4
|
+
data.tar.gz: 5d13b3f37c7285797066b9c285e60e2052d71132dba4e30251c165d4ccb898ee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90bf2423e99206780512cea1917452aada9f9125d5f995632f23d9620c0ae6670ebe3c19e85101a382a559fa955ecc5cf20efde76173d21776caa677064ed238
|
7
|
+
data.tar.gz: f0de78280ed0d1af7d60e91a0c857eb60c85a46bd8685bad9912df7622d8f10362904d68d336feb91647ec5173b3a46daba871c37016f916eebc2d3cc98c7e02
|
data/README.md
CHANGED
@@ -3,9 +3,10 @@
|
|
3
3
|
<br/>
|
4
4
|
Isomorfeus Puppetmaster<br/>
|
5
5
|
</h1>
|
6
|
+
|
6
7
|
A framework for acceptance tests or simply running tests in a headless browser.
|
7
8
|
Allows for writing javascript browser tests in pure ruby.
|
8
|
-
It is tailored for Isomorfeus and using [puppeteer-ruby](https://github.com/YusukeIwaki/puppeteer-ruby)
|
9
|
+
It is tailored for Isomorfeus and using [puppeteer-ruby](https://github.com/YusukeIwaki/puppeteer-ruby)
|
9
10
|
|
10
11
|
### Community and Support
|
11
12
|
At the [Isomorfeus Framework Project](https://isomorfeus.com)
|
@@ -52,6 +53,16 @@ A document consists of elements. Simply working with just pages, documents and e
|
|
52
53
|
1. Find something
|
53
54
|
2. Interact with it
|
54
55
|
|
56
|
+
## Sessions
|
57
|
+
Using `visit` will open a default session. However, additional browser sessions may be opened with:
|
58
|
+
```ruby
|
59
|
+
s = new_session() # additional args may be passed, like headless: false, devtools: true
|
60
|
+
# now the session can be interacted with:
|
61
|
+
s.visit('/')
|
62
|
+
t = new_session() # multiple sessions may be active at the same time
|
63
|
+
t.visit('/')
|
64
|
+
```
|
65
|
+
|
55
66
|
## Pages
|
56
67
|
A page is a Puppeteer::Page and provides its complete API plus some additional convenience methods.
|
57
68
|
The drivers opens a empty default page, to use that and go to the apps root page:
|
@@ -75,6 +86,13 @@ Both open pages can then be independently interacted with:
|
|
75
86
|
page.visit('/go')
|
76
87
|
page2.goto('/location')
|
77
88
|
```
|
89
|
+
|
90
|
+
For debugging:
|
91
|
+
```ruby
|
92
|
+
page = visit('/', headless: false, devtools: true)
|
93
|
+
```
|
94
|
+
This will close the current browser if the options for headless and devtools dont match, and open a new one with the supplied headless and devtools options.
|
95
|
+
|
78
96
|
### Pages and Ruby
|
79
97
|
|
80
98
|
Ruby can be executed within pages by simply providing a block or a string:
|
@@ -3,7 +3,7 @@ module Isomorfeus
|
|
3
3
|
module DSL
|
4
4
|
@@launch_options = nil
|
5
5
|
|
6
|
-
def set_launch_options(app: nil, args: nil, channel: nil, default_viewport: nil, devtools:
|
6
|
+
def set_launch_options(app: nil, args: nil, channel: nil, default_viewport: nil, devtools: false, dumpio: nil,
|
7
7
|
env: nil, executable_path: nil, handle_SIGINT: nil, handle_SIGTERM: nil, handle_SIGHUP: nil,
|
8
8
|
headless: true, ignore_default_args: nil, ignore_https_errors: nil, pipe: nil,
|
9
9
|
product: :chrome, slow_mo: nil, timeout: nil, user_data_dir: nil)
|
@@ -34,11 +34,11 @@ module Isomorfeus
|
|
34
34
|
session.default_page
|
35
35
|
end
|
36
36
|
|
37
|
-
def
|
38
|
-
session.
|
37
|
+
def visit(uri, referer: nil, timeout: nil, wait_until: 'networkidle0', headless: true, devtools: false)
|
38
|
+
session(headless: headless, devtools: devtools).visit(uri, referer: referer, timeout: timeout, wait_until: wait_until, headless: headless, devtools: devtools)
|
39
39
|
session.default_page
|
40
40
|
end
|
41
|
-
alias_method :
|
41
|
+
alias_method :goto, :visit
|
42
42
|
|
43
43
|
def isomorphic(ruby_source = '', &block)
|
44
44
|
ruby_source = Isomorfeus::Puppetmaster.block_source_code(&block) if block_given?
|
@@ -56,7 +56,7 @@ module Isomorfeus
|
|
56
56
|
Isomorfeus::Puppetmaster.served_app.on_server(ruby_source, &block)
|
57
57
|
end
|
58
58
|
|
59
|
-
def new_session(app: nil, args: nil, channel: nil, default_viewport: nil, devtools:
|
59
|
+
def new_session(app: nil, args: nil, channel: nil, default_viewport: nil, devtools: false, dumpio: nil,
|
60
60
|
env: nil, executable_path: nil, handle_SIGINT: nil, handle_SIGTERM: nil, handle_SIGHUP: nil,
|
61
61
|
headless: true, ignore_default_args: nil, ignore_https_errors: nil, pipe: nil,
|
62
62
|
product: :chrome, slow_mo: nil, timeout: nil, user_data_dir: nil)
|
@@ -109,8 +109,8 @@ module Isomorfeus
|
|
109
109
|
Isomorfeus::Puppetmaster.served_app.on_server(ruby_source)
|
110
110
|
end
|
111
111
|
|
112
|
-
def session
|
113
|
-
@@puppetmaster_session ||= new_session(app: Isomorfeus::Puppetmaster.served_app)
|
112
|
+
def session(headless: true, devtools: false)
|
113
|
+
@@puppetmaster_session ||= new_session(app: Isomorfeus::Puppetmaster.served_app, headless: headless, devtools: devtools)
|
114
114
|
end
|
115
115
|
end
|
116
116
|
end
|
@@ -28,11 +28,12 @@ module Isomorfeus
|
|
28
28
|
Isomorfeus.store.clear! if Isomorfeus.store.respond_to?(:clear!)
|
29
29
|
end
|
30
30
|
result = TOPLEVEL_BINDING.eval(request_hash['code']) if request_hash['code']
|
31
|
-
|
31
|
+
result = result.value if result.is_a?(Promise)
|
32
|
+
response = Rack::Response.new(Oj.dump({ 'result' => result }, circular: true),
|
32
33
|
200,
|
33
34
|
'Content-Type' => 'application/json')
|
34
35
|
rescue Exception => e
|
35
|
-
response = Rack::Response.new(Oj.dump({ 'error' => "#{e.class}: #{e.message}", 'backtrace' => e.backtrace
|
36
|
+
response = Rack::Response.new(Oj.dump({ 'error' => "#{e.class}: #{e.message}", 'backtrace' => e.backtrace&.join("\n") }),
|
36
37
|
200,
|
37
38
|
'Content-Type' => 'application/json')
|
38
39
|
end
|
@@ -4,23 +4,24 @@ module Isomorfeus
|
|
4
4
|
TIMEOUT = 30000 # milliseconds
|
5
5
|
|
6
6
|
attr_accessor :app, :browser, :default_page, :product, :response
|
7
|
+
attr_reader :headless, :devtools
|
7
8
|
|
8
|
-
def initialize(app:, args: nil, channel: nil, default_viewport: nil, devtools:
|
9
|
+
def initialize(app:, args: nil, channel: nil, default_viewport: nil, devtools: false, dumpio: nil,
|
9
10
|
env: nil, executable_path: nil, handle_SIGINT: nil, handle_SIGTERM: nil, handle_SIGHUP: nil,
|
10
11
|
headless: true, ignore_default_args: nil, ignore_https_errors: nil, pipe: nil,
|
11
12
|
product: :chrome, slow_mo: nil, timeout: nil, user_data_dir: nil)
|
12
|
-
@
|
13
|
+
@parameters = binding.local_variables.map { |v| [v, binding.local_variable_get(v)] }.to_h
|
14
|
+
@parameters[:channel] = @parameters[:channel].to_s if channel
|
15
|
+
@parameters[:timeout] = TIMEOUT unless timeout
|
16
|
+
@app = @parameters.delete(:app)
|
17
|
+
@headless = headless
|
18
|
+
@devtools = devtools
|
19
|
+
@channel = channel
|
20
|
+
default_viewport
|
13
21
|
product = product.to_s
|
14
|
-
@product = %w[chrome firefox].include?(product) ? product : 'chrome'
|
15
|
-
@
|
16
|
-
|
17
|
-
handle_SIGTERM: handle_SIGTERM, handle_SIGHUP: handle_SIGHUP, headless: headless,
|
18
|
-
ignore_default_args: ignore_default_args, ignore_https_errors: ignore_https_errors,
|
19
|
-
pipe: pipe, product: product, slow_mo: slow_mo, timeout: timeout ? timeout : TIMEOUT,
|
20
|
-
user_data_dir: user_data_dir)
|
21
|
-
@original_user_agent = @browser.user_agent
|
22
|
-
@default_page = @browser.new_page
|
23
|
-
@default_page.puppetmaster_session = self
|
22
|
+
@parameters[:product] = %w[chrome firefox].include?(product) ? product : 'chrome'
|
23
|
+
@product = @parameters[:product]
|
24
|
+
launch_browser
|
24
25
|
ObjectSpace.define_finalizer(self, self.class.close_browser(self))
|
25
26
|
end
|
26
27
|
|
@@ -40,12 +41,18 @@ module Isomorfeus
|
|
40
41
|
@browser.pages
|
41
42
|
end
|
42
43
|
|
43
|
-
def
|
44
|
+
def visit(uri, referer: nil, timeout: nil, wait_until: 'networkidle0', headless: true, devtools: false)
|
45
|
+
if @headless != headless || @devtools != devtools
|
46
|
+
@browser.close
|
47
|
+
@headless = headless
|
48
|
+
@devtools = devtools
|
49
|
+
launch_browser
|
50
|
+
end
|
44
51
|
parsed_uri = parse_uri(uri)
|
45
52
|
@response = @default_page.goto(parsed_uri.to_s, referer: referer, timeout: timeout, wait_until: wait_until)
|
46
53
|
@default_page
|
47
54
|
end
|
48
|
-
alias_method :
|
55
|
+
alias_method :goto, :visit
|
49
56
|
|
50
57
|
def network_conditions
|
51
58
|
::Puppeteer::NETWORK_CONDITIONS
|
@@ -144,6 +151,15 @@ module Isomorfeus
|
|
144
151
|
instance.browser.close if instance.browser
|
145
152
|
end
|
146
153
|
end
|
154
|
+
|
155
|
+
def launch_browser
|
156
|
+
@parameters[:headless] = @headless
|
157
|
+
@parameters[:devtools] = @devtools
|
158
|
+
@browser = ::Puppeteer.launch(**@parameters)
|
159
|
+
@original_user_agent = @browser.user_agent
|
160
|
+
@default_page = @browser.new_page
|
161
|
+
@default_page.puppetmaster_session = self
|
162
|
+
end
|
147
163
|
end
|
148
164
|
end
|
149
165
|
end
|
@@ -5,6 +5,9 @@ require 'uri'
|
|
5
5
|
require 'net/http'
|
6
6
|
require 'rack'
|
7
7
|
require 'opal'
|
8
|
+
opal_path = Gem::Specification.find_by_name('opal').full_gem_path
|
9
|
+
promise_path = File.join(opal_path, 'stdlib', 'promise.rb')
|
10
|
+
require promise_path
|
8
11
|
require 'parser'
|
9
12
|
|
10
13
|
# isomorfeus needs kwargs
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: isomorfeus-puppetmaster
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jan Biedermann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-08-
|
11
|
+
date: 2022-08-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -92,14 +92,14 @@ dependencies:
|
|
92
92
|
requirements:
|
93
93
|
- - "~>"
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version: 0.
|
95
|
+
version: 0.42.0
|
96
96
|
type: :runtime
|
97
97
|
prerelease: false
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
100
|
- - "~>"
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: 0.
|
102
|
+
version: 0.42.0
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: tty-which
|
105
105
|
requirement: !ruby/object:Gem::Requirement
|