heavens_door 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +26 -2
- data/app/assets/javascripts/heavens_door.js +15 -9
- data/lib/heavens_door/middleware.rb +1 -1
- data/lib/heavens_door/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30df81406901e49123b33b3ff4778b5f51230eaae01ed4b027e3fbdb6c3655ca
|
4
|
+
data.tar.gz: ea75d2ca2fd71f6dad111ce2ee00f3acc56aa294f18840ffe04d5991b2afd22c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da3b98161c4f61e71bf469712886ea9c1fe06c3382f28986b57783cf367ca59f331ba715fbe6384d5e92410a1a631543d634d8b6acdac34172463c08567d0189
|
7
|
+
data.tar.gz: 555562fcd242d389887274ec779b8339fd6f0cdb200bbae2f062156e73a65af191da3da111cacbb747df75b429654b4dc273dd6220fb4a24233838ff0536861e
|
data/README.md
CHANGED
@@ -8,7 +8,7 @@ A tiny Rails engine that generates capybara test scenario by recording browser o
|
|
8
8
|
Add this line to your Rails application's Gemfile (in most cases, for development group only):
|
9
9
|
|
10
10
|
```ruby
|
11
|
-
gem 'heavens_door'
|
11
|
+
gem 'heavens_door', group: :development
|
12
12
|
```
|
13
13
|
|
14
14
|
|
@@ -21,7 +21,7 @@ gem 'heavens_door'
|
|
21
21
|
Visit your development with your browser, then click the ⏺ button on the top right.
|
22
22
|
|
23
23
|
|
24
|
-
### Generate
|
24
|
+
### Generate Scenarios
|
25
25
|
Just manipulate the browser, like fill-in the forms and submit, or click the links.
|
26
26
|
Your operations will be recorded on the browser.
|
27
27
|
|
@@ -32,11 +32,35 @@ You can export the operation as a Capybara test scenario script by clicking the
|
|
32
32
|
To stop recording and clear the whole recorded scenario, click the ⏹ button.
|
33
33
|
|
34
34
|
|
35
|
+
## Requirements
|
36
|
+
- Rails
|
37
|
+
- Modern browsers
|
38
|
+
|
39
|
+
|
35
40
|
## Contributing
|
36
41
|
|
37
42
|
Pull requests are welcome on GitHub at https://github.com/amatsuda/heavens_door.
|
38
43
|
|
39
44
|
|
45
|
+
## TODO
|
46
|
+
|
47
|
+
- Insert assertions from the browser
|
48
|
+
|
49
|
+
- Some kinds of input (like time\_field, datetime\_field) might not be working properly
|
50
|
+
|
51
|
+
- Button click effect
|
52
|
+
|
53
|
+
- Hotkeys to hide/show the panel
|
54
|
+
|
55
|
+
- Better UI
|
56
|
+
|
57
|
+
- Cleaner JS code
|
58
|
+
|
59
|
+
- Tests (do we really need tests for this? Well, maybe...)
|
60
|
+
|
61
|
+
- etcetcetc.
|
62
|
+
|
63
|
+
|
40
64
|
## License
|
41
65
|
|
42
66
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
@@ -9,7 +9,7 @@
|
|
9
9
|
}
|
10
10
|
}
|
11
11
|
})(() => {
|
12
|
-
document.getElementById('heavens-door-start').addEventListener('click',
|
12
|
+
document.getElementById('heavens-door-start').addEventListener('click', () => {
|
13
13
|
document.getElementById('heavens-door-start').style.display = 'none';
|
14
14
|
document.getElementById('heavens-door-stop').style.display = 'inline';
|
15
15
|
document.getElementById('heavens-door-copy').style.display = 'inline';
|
@@ -20,14 +20,14 @@
|
|
20
20
|
}
|
21
21
|
});
|
22
22
|
|
23
|
-
document.getElementById('heavens-door-stop').addEventListener('click',
|
23
|
+
document.getElementById('heavens-door-stop').addEventListener('click', () => {
|
24
24
|
document.getElementById('heavens-door-start').style.display = 'inline';
|
25
25
|
document.getElementById('heavens-door-stop').style.display = 'none';
|
26
26
|
document.getElementById('heavens-door-copy').style.display = 'none';
|
27
27
|
sessionStorage.clear('heavensDoor');
|
28
28
|
});
|
29
29
|
|
30
|
-
document.getElementById('heavens-door-copy').addEventListener('click',
|
30
|
+
document.getElementById('heavens-door-copy').addEventListener('click', () => {
|
31
31
|
navigator.clipboard.writeText(sessionStorage.heavensDoor)
|
32
32
|
.catch(err => {
|
33
33
|
console.error('Could not copy text: ', err);
|
@@ -47,17 +47,23 @@
|
|
47
47
|
}
|
48
48
|
|
49
49
|
Array.from(document.getElementsByTagName('form')).forEach(form => {
|
50
|
-
form.addEventListener('submit',
|
50
|
+
form.addEventListener('submit', () => {
|
51
51
|
if (sessionStorage.heavensDoor) {
|
52
|
-
Array.from(form.querySelectorAll('input,textarea')).forEach(el => {
|
53
|
-
|
52
|
+
Array.from(form.querySelectorAll('input,textarea,select')).forEach(el => {
|
53
|
+
const target = labelIdForElement(el) || el.id;
|
54
54
|
|
55
|
-
if (
|
55
|
+
if (['text', 'textarea', 'search', 'number', 'email', 'url', 'password', 'tel'].includes(el.type)) {
|
56
56
|
if (el.value) {
|
57
57
|
sessionStorage.heavensDoor += ` fill_in '${target}', with: '${el.value}'\n`;
|
58
58
|
}
|
59
|
-
} else if (el.type == '
|
59
|
+
} else if (el.type == 'date') {
|
60
|
+
sessionStorage.heavensDoor += ` fill_in '${target}', with: Date.parse('${el.value}')\n`;
|
61
|
+
} else if (el.type == 'select-one') {
|
60
62
|
sessionStorage.heavensDoor += ` select '${el[el.selectedIndex].value}', from: '${target}'\n`;
|
63
|
+
} else if (el.type == 'select-multiple') {
|
64
|
+
Array.from(el.selectedOptions).forEach(o => {
|
65
|
+
sessionStorage.heavensDoor += ` select '${o.value}', from: '${target}'\n`;
|
66
|
+
})
|
61
67
|
} else if ((el.type == 'radio') && el.checked) {
|
62
68
|
sessionStorage.heavensDoor += ` choose '${el.value}'\n`;
|
63
69
|
} else if ((el.type == 'checkbox') && el.checked) {
|
@@ -71,7 +77,7 @@
|
|
71
77
|
})
|
72
78
|
|
73
79
|
Array.from(document.getElementsByTagName('a')).forEach(a => {
|
74
|
-
a.addEventListener('click',
|
80
|
+
a.addEventListener('click', () => {
|
75
81
|
if (sessionStorage.heavensDoor) {
|
76
82
|
sessionStorage.heavensDoor += ` click_link '${a.text}'\n\n`;
|
77
83
|
}
|
@@ -9,7 +9,7 @@ module HeavensDoor
|
|
9
9
|
def call(env)
|
10
10
|
status, headers, body = @app.call env
|
11
11
|
|
12
|
-
if headers && headers['Content-Type']&.include?('text/html') &&
|
12
|
+
if headers && headers['Content-Type']&.include?('text/html') &&
|
13
13
|
(!env['action_dispatch.content_security_policy']&.script_src('unsafe-inline') && !env['action_dispatch.content_security_policy']&.style_src('unsafe-inline')) # the Rails default top page has this
|
14
14
|
case body
|
15
15
|
when ActionDispatch::Response, ActionDispatch::Response::RackBody
|
data/lib/heavens_door/version.rb
CHANGED