integration-tests-rails 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 84c4035ac9b688b71a79030ebcd59a4d2bef7a8593a83c3ebf2f5c03fb9ee60a
4
- data.tar.gz: b454d46902e74f75b0d9c3679742c2698e1df3876fd17a7b364517b97f558044
3
+ metadata.gz: 07f7241b5d554a5e0409bf4d955b5bcb859126f394e7eed5513ba6f92a9b3318
4
+ data.tar.gz: 72e0af62570e42a128cbd906b8874e30e69c0e419e898cacc96b936b0f4f3d56
5
5
  SHA512:
6
- metadata.gz: c09e828485249c348941d7985873e1b943a0a153a47a52686550a50cdea0c02619aa0a2a74fc4b771705b769a7595df2e67de1523968043a89f0ee401b5b4c09
7
- data.tar.gz: fd35f0e92786ba0a15b5b811a10e5a64b15ab5ff4d908b68f8987243d39057017c925369881f12174060cbc6f2ac5a51e1fda3eb8e6aa84e42e2bfbb3bee5895
6
+ metadata.gz: 9bb1e5c7734164e053e45ab9a0fc17d7134d9a0b525351cafda5812110a26594fac0a363a8d1d415db849394f6d3bc591193fda4a6dba1b8c3d89d253f70909a
7
+ data.tar.gz: 23b0f92a2ecd62af9882abdfb48ca3cf751fd891ff0d6b28e2e39793e259a4b63e8069f0f85a35f65d7ad4c866ade47c1b6b18b888917e2b2b4b40a783ac3f2a
data/README.md CHANGED
@@ -90,8 +90,6 @@ DEFAULT_HTML_CONTENT = <<~HTML.squish
90
90
  <meta name="turbo-visit-control" content="reload">
91
91
  <%= csrf_meta_tags %>
92
92
  <%= csp_meta_tag %>
93
- <%= stylesheet_link_tag :app, "data-turbo-track": "reload" %>
94
- <%= stylesheet_link_tag 'custom', "data-turbo-track": "reload" %>
95
93
  <%= javascript_importmap_tags %>
96
94
  </head>
97
95
  <body>
@@ -100,7 +98,11 @@ DEFAULT_HTML_CONTENT = <<~HTML.squish
100
98
  HTML
101
99
  ```
102
100
 
103
- Since vendored JavaScript are not included by default, additional tags may be required to load them. For example, if there exists a `custom_code.js` file in `app/javascript` and `vendor.min.js` file in `app/assets/javascripts/plugins`:
101
+ Since vendored JavaScript are not included by default, additional tags may be required to load them. Stylesheets can also be loaded if needed. For example, files can be included as follows:
102
+ - `custom_code.js` file in `app/javascript`
103
+ - `vendor.min.js` file in `app/assets/javascripts/plugins`
104
+ - `app.css` file in `app/assets/stylesheets`
105
+ - `custom.css` file in `app/assets/stylesheets`
104
106
 
105
107
  ```ruby
106
108
  <<~HTML.squish
@@ -112,8 +114,10 @@ Since vendored JavaScript are not included by default, additional tags may be re
112
114
  <meta name="turbo-visit-control" content="reload">
113
115
  <%= csrf_meta_tags %>
114
116
  <%= csp_meta_tag %>
117
+
115
118
  <%= stylesheet_link_tag :app, "data-turbo-track": "reload" %>
116
119
  <%= stylesheet_link_tag 'custom', "data-turbo-track": "reload" %>
120
+
117
121
  <%= javascript_importmap_tags %>
118
122
 
119
123
  <script type="module">
@@ -198,6 +202,47 @@ Refer to [Cuprite](https://github.com/rubycdp/cuprite) and [Capybara](https://gi
198
202
 
199
203
  After the tests (successful, failed or cancelled), coverage reports will be generated in `coverage/javascript` by default.
200
204
 
205
+ ## Example Setups
206
+
207
+ ### Using Docker Desktop
208
+
209
+ If you want to use the [Alpine Chrome](https://hub.docker.com/r/zenika/alpine-chrome) image, this is definitely possible.
210
+
211
+ Open Docker Desktop, Settings, Resources then Network. Check the Enable host networking option then Apply.
212
+
213
+ Your docker compose file may contain this entry:
214
+
215
+ ```yaml
216
+ # compose.yml
217
+
218
+ services:
219
+ chrome:
220
+ image: zenika/alpine-chrome:latest
221
+ network_mode: host
222
+ command: >
223
+ --no-sandbox
224
+ --disable-dev-shm-usage
225
+ --disable-gpu
226
+ --disable-web-security
227
+ --remote-debugging-address=0.0.0.0
228
+ --remote-debugging-port=9222
229
+ --headless
230
+ shm_size: 2gb
231
+ ```
232
+
233
+ Setting up the gem:
234
+
235
+ ```ruby
236
+ # capybara_helper.rb
237
+
238
+ IntegrationTestsRails.setup do |config|
239
+ config.chrome_url = 'ws://localhost:9222'
240
+ config.remote = true
241
+ config.server_host = '0.0.0.0'
242
+ config.server_port = 9888
243
+ end
244
+ ```
245
+
201
246
  ## Contributing
202
247
 
203
248
  1. Fork the repository.
@@ -12,9 +12,13 @@ module IntegrationTestsRails
12
12
  <meta name="turbo-visit-control" content="reload">
13
13
  <%= csrf_meta_tags %>
14
14
  <%= csp_meta_tag %>
15
- <%= stylesheet_link_tag :app, "data-turbo-track": "reload" %>
16
- <%= stylesheet_link_tag 'custom', "data-turbo-track": "reload" %>
15
+
16
+ <!-- If there are stylesheets to include, include them here for testing. -->
17
+ <!-- E.g. The line below loads a stylesheet file located in app/assets/stylesheets/app.css -->
18
+ <%#= stylesheet_link_tag :app, "data-turbo-track": "reload" %>
19
+
17
20
  <%= javascript_importmap_tags %>
21
+
18
22
  <!-- If there are JavaScript libraries not globally available, include them here for testing.-->
19
23
  <!-- E.g. The block below shows how to import a JavaScript module and attach it to the window object. -->
20
24
  <!-- The file is located in app/javascripts/libs/my_library.js -->
@@ -126,11 +126,13 @@ module IntegrationTestsRails
126
126
  }
127
127
 
128
128
  const instrumentedDir = '#{config.output_path}';
129
+ const backupDir = '#{config.backup_path}';
130
+ const sourceDir = '#{config.source_path}';
129
131
  const instrumentedFiles = findJsFiles(instrumentedDir);
130
132
 
131
133
  instrumentedFiles.forEach(instrumentedFile => {
132
134
  const relativePath = path.relative(instrumentedDir, instrumentedFile);
133
- const originalFile = path.join('#{config.source_path}', relativePath);
135
+ const originalFile = path.join(sourceDir, relativePath);
134
136
 
135
137
  if (coverageMap.data[originalFile]) return;
136
138
 
@@ -140,6 +142,7 @@ module IntegrationTestsRails
140
142
 
141
143
  if (match && match[1]) {
142
144
  const coverageData = eval('(' + match[1] + ')');
145
+ // Keep original path for display
143
146
  coverageData.path = originalFile;
144
147
  coverageMap.addFileCoverage(coverageData);
145
148
  }
@@ -150,7 +153,21 @@ module IntegrationTestsRails
150
153
 
151
154
  const context = libReport.createContext({
152
155
  dir: 'coverage/javascript',
153
- coverageMap: coverageMap
156
+ coverageMap: coverageMap,
157
+ sourceFinder: function(filePath) {
158
+ const relativePath = path.relative(sourceDir, filePath);
159
+ const backupFile = path.join(backupDir, relativePath);
160
+
161
+ try {
162
+ // Read content from backup (original source)
163
+ if (fs.existsSync(backupFile)) {
164
+ return fs.readFileSync(backupFile, 'utf8');
165
+ }
166
+ } catch(e) {
167
+ console.error('Could not read backup file:', backupFile, e.message);
168
+ }
169
+ return null;
170
+ }
154
171
  });
155
172
 
156
173
  ['html', 'lcov', 'cobertura'].forEach(reportType => {
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IntegrationTestsRails
4
- VERSION = '1.0.1'
4
+ VERSION = '1.0.3'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: integration-tests-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tien