diff_test 0.7.0 → 0.8.0

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: 0c9bb00a4ed3e786eeea894db16fc53b880e1cb86a9bc297df003e9697772151
4
- data.tar.gz: 4060332f4db48744bbe0ac76a6d812c26854dc232331508da5f0f98ce849c0a9
3
+ metadata.gz: 45e1c998d4518e8fa85ca6b032ea150f6583faae256ca6cd0a898db1b5f36b5a
4
+ data.tar.gz: b82d63f526687c9f15399b68500be58ef4a3b52bda449125f3a6efa8f0bc0895
5
5
  SHA512:
6
- metadata.gz: af7bce53595bdfbfb97c62959bdcb388638b5991d197852ab269e1e9afd61854d28dae7f0771307f497cdf4e1c45a7b8f04bb0a7200ced9f2c91e9bda78f2fcb
7
- data.tar.gz: 92fcc77616d2a327934f228560b8adfec15f6ff4421c63460d097763f4ad731d2f55617082ed61bf683cb13cb856ef7edcb09127e4cc4aa34ec7f53656dcc114
6
+ metadata.gz: c3e4317b88e81d8d98094c19169de1d75d0458b4fae14fa79ea0ef8b5cf7a00f71344c3e6631248177f58140c2efcd4e063ecdd04031b9ca05d1bb1187d26d22
7
+ data.tar.gz: 04b161c82a2e075484540abedfb0111c51c6bb8f8f7eb4ecd713f9075e921c09a0c201d0d0f21424239031c10308c8870d3239bcd7b0e3f54e439709df84c512
@@ -97,7 +97,7 @@ module DiffTest
97
97
  new_lines = lines.dup
98
98
  new_lines.insert(insert_index, text_to_insert)
99
99
 
100
- new_lines.join("\n") + "\n"
100
+ new_lines.join("\n")
101
101
  end
102
102
  end
103
103
  end
@@ -36,13 +36,26 @@ module DiffTest
36
36
  def script
37
37
  <<~HTML
38
38
  <script>
39
+ let timeout = null
39
40
  var owner = globalThis || window
40
41
  owner.diffTestTrackedJsFiles = owner.diffTestTrackedJsFiles || [];
41
42
  owner.diffTestTrackJsFile = function(file_path) {
43
+ owner.diffTestTrackedJsFiles.push(file_path);
44
+ if(!timeout) {
45
+ timeout = setTimeout(flushTrackedJsFiles, 0);
46
+ }
47
+ }
48
+
49
+ owner.diffTestTrackJsFileAuto = owner.diffTestTrackJsFile;
50
+
51
+ function flushTrackedJsFiles() {
52
+ timeout = null
53
+ const file_paths = owner.diffTestTrackedJsFiles;
54
+ owner.diffTestTrackedJsFiles = [];
55
+
42
56
  const path = "/__diff_test_js_beacon";
43
- const payload = JSON.stringify({ test_id: #{DiffTest::TestExecution.current.id.to_json}, file_path: file_path });
57
+ const payload = JSON.stringify({ test_id: #{DiffTest::TestExecution.current.id.to_json}, file_paths: file_paths });
44
58
 
45
- owner.diffTestTrackedJsFiles.push(file_path);
46
59
  if (owner.navigator && owner.navigator.sendBeacon) {
47
60
  // Use sendBeacon in capable browsers/environments
48
61
  window.navigator.sendBeacon(path, payload);
@@ -58,8 +71,6 @@ module DiffTest
58
71
  });
59
72
  }
60
73
  }
61
-
62
- owner.diffTestTrackJsFileAuto = owner.diffTestTrackJsFile;
63
74
  </script>
64
75
  HTML
65
76
  end
@@ -19,7 +19,9 @@ module DiffTest
19
19
  if path.include?('__diff_test_js_beacon')
20
20
  body = env['rack.input'].read
21
21
  json = JSON.parse(body)
22
- DiffTest::Trackers::JsFile.record_by_test_id(json['test_id'], json['file_path'])
22
+ json['file_paths'].each do |file_path|
23
+ DiffTest::Trackers::JsFile.record_by_test_id(json['test_id'], file_path)
24
+ end
23
25
  [204, {}, []]
24
26
  else
25
27
  env.delete('HTTP_IF_NONE_MATCH')
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DiffTest
4
- VERSION = "0.7.0"
4
+ VERSION = "0.8.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: diff_test
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Owais