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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8448977434656e698bafb098a6aa85f230649ae84058ec8aa4560a69858401d1
4
- data.tar.gz: 65a50c903320ff249d5dda7f7f243c509d56447a6ff0b6f3d8df9bc6d1257318
3
+ metadata.gz: 30df81406901e49123b33b3ff4778b5f51230eaae01ed4b027e3fbdb6c3655ca
4
+ data.tar.gz: ea75d2ca2fd71f6dad111ce2ee00f3acc56aa294f18840ffe04d5991b2afd22c
5
5
  SHA512:
6
- metadata.gz: 5128f158dd846da11066107ac03287ec2a59ec264a4bb6302fc48f0f1e2d0343adc63cbed7055ec6a1d41b902f28bd702b9ea1c8da5e551432d6895dd6218f2a
7
- data.tar.gz: 1e8f0eb2ef8a765952c3a62b55f1c81177c9e7dfc019e013cd7fd67e62a78eb8b601772c0496e6b699a2ad51a2f33cfb2e0b2fc7398d7b94dbbd5f9a7d33e841
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 Schenarios
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', e => {
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', e => {
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', e => {
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', e => {
50
+ form.addEventListener('submit', () => {
51
51
  if (sessionStorage.heavensDoor) {
52
- Array.from(form.querySelectorAll('input,textarea')).forEach(el => {
53
- let target = labelIdForElement(el) || el.id;
52
+ Array.from(form.querySelectorAll('input,textarea,select')).forEach(el => {
53
+ const target = labelIdForElement(el) || el.id;
54
54
 
55
- if ((el.type == 'text') || (el.type == 'textarea') || (el.type == 'search') || (el.type == 'number') || (el.type == 'email') || (el.type == 'url') || (el.type == 'password') || (el.type == 'tel') || (el.type == 'date')) {
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 == 'select') {
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', e => {
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') && (env['REQUEST_PATH'] !~ %r[^/*heavens_door/]) &&
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HeavensDoor
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heavens_door
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akira Matsuda