dom_glancy 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile +1 -1
- data/app/assets/stylesheets/dom_glancy.css +1 -2
- data/app/controllers/dom_glancy_controller.rb +3 -3
- data/app/views/dom_glancy/new.html.erb +4 -4
- data/app/views/shared/_dom_glancy_nav.html.erb +1 -1
- data/lib/dom_glancy/analysis.rb +9 -4
- data/lib/dom_glancy/configuration.rb +3 -1
- data/lib/dom_glancy/element.rb +1 -1
- data/lib/dom_glancy/version.rb +1 -1
- data/test/page_objects/dom_glancy/new_page.rb +14 -0
- data/test/selenium/mapping_test.rb +18 -0
- data/test/selenium/viewer_test.rb +27 -0
- data/test/selenium_test_helper.rb +10 -0
- data/test/test_app/config/initializers/dom_glancy_initializer.rb +1 -0
- data/test/test_helper.rb +2 -0
- data/test/unit/element_test.rb +8 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4f6b85d8b3b3b443273ccd45b0d0ebc35ac1a49
|
4
|
+
data.tar.gz: 0e8ad79d21beace912bc8a6a656ca5a064045c83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 09c300f922d5983a387d2e5c68566b0e33c9596661b33f89c3c5ff4150b6975ca70e7a25554be56ddc21b935e78d45a2e0c4c79b4c3b0cf7bff6b7381695d018
|
7
|
+
data.tar.gz: 9f315183d832157878c0456682275ea7f059f211463179abfad71e28e065e7cea9169e09836e0a2f2ecec370aa520b6637a21a5931b74dc6047d70cf735b7efc
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
@@ -34,8 +34,8 @@ class DomGlancyController < DomGlancyApplicationController
|
|
34
34
|
|
35
35
|
def make_master
|
36
36
|
test_root = params[:file]
|
37
|
-
src = DomGlancy.
|
38
|
-
dst = DomGlancy.
|
37
|
+
src = DomGlancy::DomGlancy.current_filename(test_root)
|
38
|
+
dst = DomGlancy::DomGlancy.master_filename(test_root)
|
39
39
|
FileUtils.cp src, dst
|
40
40
|
|
41
41
|
redirect_to '/dom_glancy/new'
|
@@ -43,7 +43,7 @@ class DomGlancyController < DomGlancyApplicationController
|
|
43
43
|
|
44
44
|
def delete_current
|
45
45
|
test_root = params[:file]
|
46
|
-
src = DomGlancy.
|
46
|
+
src = DomGlancy::DomGlancy.current_filename(test_root)
|
47
47
|
FileUtils.rm_rf src
|
48
48
|
|
49
49
|
redirect_to '/dom_glancy/new'
|
@@ -3,12 +3,12 @@
|
|
3
3
|
</div>
|
4
4
|
|
5
5
|
<div class="row">
|
6
|
-
<table class='kr kr--artifacts'>
|
6
|
+
<table class='kr kr--artifacts' id='js--files'>
|
7
7
|
<% @extra_files.each do |f| %>
|
8
|
-
<tr>
|
8
|
+
<tr class='js--new_files'>
|
9
9
|
<td><%= f %></td>
|
10
|
-
<td><%= link_to 'make master', "make_master/#{f}", :class => 'kr' %></td>
|
11
|
-
<td><%= link_to 'delete', "delete_current/#{f}", :class => 'kr' %></td>
|
10
|
+
<td><%= link_to 'make master', "make_master/#{f}", :class => 'kr kr--button kr--button-small' %></td>
|
11
|
+
<td><%= link_to 'delete', "delete_current/#{f}", :class => 'kr kr--button kr--button-small' %></td>
|
12
12
|
</tr>
|
13
13
|
<% end %>
|
14
14
|
</table>
|
@@ -4,5 +4,5 @@
|
|
4
4
|
<!--<a href="/dom_glancy/artifacts" class="kr"><div class="slot-2 kr--nav">artifacts</div></a>-->
|
5
5
|
<a href="/dom_glancy/config" class="kr"><div class="slot-3 kr--nav">config</div></a>
|
6
6
|
<a href="/dom_glancy/clear" class="kr"><div class="slot-4 kr--nav">clear</div></a>
|
7
|
-
<a href="/dom_glancy/about" class="kr"><div class="slot-5 kr--nav">about</div></a>
|
7
|
+
<a href="/dom_glancy/about" class="kr"><div class="slot-5 kr--nav" id="js--about">about</div></a>
|
8
8
|
</div>
|
data/lib/dom_glancy/analysis.rb
CHANGED
@@ -30,7 +30,7 @@ module DomGlancy
|
|
30
30
|
set_master_not_current.delete(item2)
|
31
31
|
end
|
32
32
|
|
33
|
-
changed_element_pairs.select!{ |pair| !DOMElement.new(pair[0]).close_enough?(DOMElement.new(pair[1])) }
|
33
|
+
changed_element_pairs.select!{ |pair| !DOMElement.new(add_similarity(pair[0])).close_enough?(DOMElement.new(add_similarity(pair[1]))) }
|
34
34
|
changed_element_pairs.each do |pair|
|
35
35
|
set_changed_master.add(pair.first)
|
36
36
|
end
|
@@ -95,7 +95,7 @@ module DomGlancy
|
|
95
95
|
set2.each do |item2|
|
96
96
|
element2 = DOMElement.new(item2)
|
97
97
|
if element1.same_element?(element2)
|
98
|
-
same_but_different_pairs << [item1, item2]
|
98
|
+
same_but_different_pairs << [item1, item2]
|
99
99
|
end
|
100
100
|
end
|
101
101
|
end
|
@@ -105,9 +105,9 @@ module DomGlancy
|
|
105
105
|
def pairs_that_are_close_enough(set1, set2)
|
106
106
|
ok_pairs = []
|
107
107
|
set1.each do |item1|
|
108
|
-
element1 = DOMElement.new(item1)
|
108
|
+
element1 = DOMElement.new(add_similarity(item1))
|
109
109
|
set2.each do |item2|
|
110
|
-
element2 = DOMElement.new(item2)
|
110
|
+
element2 = DOMElement.new(add_similarity(item2))
|
111
111
|
if element1.same_element?(element2) && element1.close_enough?(element2)
|
112
112
|
ok_pairs << [item1, item2]
|
113
113
|
end
|
@@ -134,6 +134,11 @@ module DomGlancy
|
|
134
134
|
msg.join("\n")
|
135
135
|
end
|
136
136
|
|
137
|
+
def add_similarity(element)
|
138
|
+
element.merge(:similarity => ::DomGlancy.configuration.similarity)
|
139
|
+
end
|
140
|
+
|
141
|
+
|
137
142
|
def blessing_copy_string(test_root)
|
138
143
|
"cp #{DomGlancy.current_filename(test_root)} #{DomGlancy.master_filename(test_root)}"
|
139
144
|
end
|
@@ -5,18 +5,20 @@ module DomGlancy
|
|
5
5
|
|
6
6
|
def self.configure
|
7
7
|
self.configuration ||= Configuration.new
|
8
|
-
yield(configuration)
|
8
|
+
yield(configuration) if block_given?
|
9
9
|
end
|
10
10
|
|
11
11
|
class Configuration
|
12
12
|
attr_accessor :master_file_location
|
13
13
|
attr_accessor :diff_file_location
|
14
14
|
attr_accessor :current_file_location
|
15
|
+
attr_accessor :similarity
|
15
16
|
|
16
17
|
def initialize
|
17
18
|
@master_file_location = nil
|
18
19
|
@diff_file_location = nil
|
19
20
|
@current_file_location = nil
|
21
|
+
@similarity = 15
|
20
22
|
end
|
21
23
|
end
|
22
24
|
end
|
data/lib/dom_glancy/element.rb
CHANGED
@@ -25,7 +25,7 @@ module DomGlancy
|
|
25
25
|
@id = h[:id] || h['id']
|
26
26
|
@style = h[:style] || h['style']
|
27
27
|
@visible = h[:visible] || h['visible']
|
28
|
-
@similarity = h[:similarity] || h['similarity'] ||
|
28
|
+
@similarity = h[:similarity] || h['similarity'] || 0
|
29
29
|
end
|
30
30
|
|
31
31
|
def same_element?(anOther)
|
data/lib/dom_glancy/version.rb
CHANGED
@@ -1,7 +1,21 @@
|
|
1
1
|
module PageObjects
|
2
2
|
module DomGlancy
|
3
|
+
class NewFile < AePageObjects::Element
|
4
|
+
element :name, :locator => 'td:nth-child(1)'
|
5
|
+
def make_master
|
6
|
+
node.click_link_or_button('make master')
|
7
|
+
window.change_to(NewPage)
|
8
|
+
end
|
9
|
+
def delete
|
10
|
+
node.click_link_or_button('delete')
|
11
|
+
window.change_to(NewPage)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
3
15
|
class NewPage < ViewerPage
|
4
16
|
path '/dom_glancy/new'
|
17
|
+
|
18
|
+
collection :files, :locator => '#js--files', :item_locator => '.js--new_files', :contains => NewFile
|
5
19
|
end
|
6
20
|
end
|
7
21
|
end
|
@@ -78,6 +78,24 @@ class MappingTest < SeleniumTestCase
|
|
78
78
|
assert_equal 0, index_page.files.count, 'number of difference files'
|
79
79
|
end
|
80
80
|
|
81
|
+
def test_mapping__similarity
|
82
|
+
visit_index
|
83
|
+
|
84
|
+
map_current_page_and_save_as_master('dom_glancy_index')
|
85
|
+
|
86
|
+
assert_equal 15, DomGlancy.configuration.similarity, 'Dom Glancy similarity value'
|
87
|
+
|
88
|
+
resize_about_element(15) # increase the size of the about element by the similarity amount and it should be same
|
89
|
+
|
90
|
+
same, msg = @dom_glancy.page_map_same?('dom_glancy_index')
|
91
|
+
assert same, msg
|
92
|
+
|
93
|
+
resize_about_element(1) # increase the size of the about element by 1 more pixel and it should be NOT same
|
94
|
+
|
95
|
+
same, msg = @dom_glancy.page_map_same?('dom_glancy_index')
|
96
|
+
refute same, msg
|
97
|
+
end
|
98
|
+
|
81
99
|
def test_non_dom_glancy_page__pass
|
82
100
|
local_page = PageObjects::DomGlancy::LocalIndexPage.visit
|
83
101
|
|
@@ -18,4 +18,31 @@ class ViewerTest < SeleniumTestCase
|
|
18
18
|
|
19
19
|
index_page = about_page.navigation.home!
|
20
20
|
end
|
21
|
+
|
22
|
+
def test_make_master
|
23
|
+
names = %w(steven_gerrard jordan_henderson adam_lallana)
|
24
|
+
names.each { |name| File.open(DomGlancy::DomGlancy.current_filename(name), 'w') { |f| f.write '' } }
|
25
|
+
|
26
|
+
index_page = visit_index
|
27
|
+
new_tests_page = index_page.navigation.new_page!
|
28
|
+
|
29
|
+
assert_equal names.count, new_tests_page.files.count
|
30
|
+
|
31
|
+
new_tests_page.files.each do |file|
|
32
|
+
assert_includes names, file.name.text, 'filename displayed'
|
33
|
+
end
|
34
|
+
|
35
|
+
assert_equal names.count, Dir[File.join(DomGlancy.configuration.current_file_location, '*.yaml')].count
|
36
|
+
assert_equal 0, Dir[File.join(DomGlancy.configuration.master_file_location, '*.yaml')].count
|
37
|
+
|
38
|
+
new_tests_page = new_tests_page.files.first.make_master
|
39
|
+
assert_equal names.count - 1, new_tests_page.files.count
|
40
|
+
assert_equal names.count, Dir[File.join(DomGlancy.configuration.current_file_location, '*.yaml')].count
|
41
|
+
assert_equal 1, Dir[File.join(DomGlancy.configuration.master_file_location, '*.yaml')].count
|
42
|
+
|
43
|
+
new_tests_page = new_tests_page.files.first.delete
|
44
|
+
assert_equal names.count - 2, new_tests_page.files.count
|
45
|
+
assert_equal names.count - 1, Dir[File.join(DomGlancy.configuration.current_file_location, '*.yaml')].count
|
46
|
+
assert_equal 1, Dir[File.join(DomGlancy.configuration.master_file_location, '*.yaml')].count
|
47
|
+
end
|
21
48
|
end
|
@@ -80,6 +80,16 @@ class SeleniumTestCase < Minitest::Test
|
|
80
80
|
page.driver.browser.execute_script(js)
|
81
81
|
end
|
82
82
|
|
83
|
+
def resize_about_element(add_to_width)
|
84
|
+
js = <<-JS
|
85
|
+
var element = document.getElementById('js--about');
|
86
|
+
var width = element.clientWidth + #{add_to_width};
|
87
|
+
element.style.width = width + 'px';
|
88
|
+
JS
|
89
|
+
|
90
|
+
page.driver.browser.execute_script(js)
|
91
|
+
end
|
92
|
+
|
83
93
|
def add_centered_element(text_content)
|
84
94
|
js = <<-JS
|
85
95
|
var centeredElement = document.createElement('div');
|
@@ -2,6 +2,7 @@ DomGlancy.configure do |c|
|
|
2
2
|
c.master_file_location = Rails.root.join('tmp', 'data', 'map', 'masters')
|
3
3
|
c.current_file_location = Rails.root.join('tmp', 'data', 'map', 'current')
|
4
4
|
c.diff_file_location = Rails.root.join('tmp', 'data', 'map', 'diff')
|
5
|
+
c.similarity = 15
|
5
6
|
end
|
6
7
|
|
7
8
|
FileUtils.mkdir_p(DomGlancy.configuration.master_file_location)
|
data/test/test_helper.rb
CHANGED
data/test/unit/element_test.rb
CHANGED
@@ -4,11 +4,14 @@ class ElementTest < DomGlancyTestCase
|
|
4
4
|
|
5
5
|
def test_sameness
|
6
6
|
element1 = DomGlancy::DOMElement.new(single_element_hash)
|
7
|
-
element2 = DomGlancy::DOMElement.new(single_element_hash.merge({
|
7
|
+
element2 = DomGlancy::DOMElement.new(single_element_hash.merge({'left' => 72}))
|
8
8
|
|
9
9
|
assert element1.same_element?(element2), 'should be the same element'
|
10
10
|
refute element1.all_same?(element2), 'should not be all same'
|
11
|
-
|
11
|
+
refute element1.close_enough?(element2), 'default similarity is 0 so not similar yet.'
|
12
|
+
|
13
|
+
element1.similarity = 15
|
14
|
+
assert element1.close_enough?(element2), 'default similarity is 15 now, so it is similar.'
|
12
15
|
|
13
16
|
element1.left = 72
|
14
17
|
assert element1.all_same?(element2), 'should be the same now'
|
@@ -19,9 +22,9 @@ class ElementTest < DomGlancyTestCase
|
|
19
22
|
end
|
20
23
|
|
21
24
|
def test_similarity
|
22
|
-
element1 = DomGlancy::DOMElement.new(single_element_hash.merge({
|
23
|
-
element2 = DomGlancy::DOMElement.new(single_element_hash.merge({
|
24
|
-
element3 = DomGlancy::DOMElement.new(single_element_hash.merge({
|
25
|
+
element1 = DomGlancy::DOMElement.new(single_element_hash.merge({'similarity' => 2}))
|
26
|
+
element2 = DomGlancy::DOMElement.new(single_element_hash.merge({'left' => 72}))
|
27
|
+
element3 = DomGlancy::DOMElement.new(single_element_hash.merge({'left' => 74}))
|
25
28
|
|
26
29
|
assert element1.same_element?(element2), 'should be the same element'
|
27
30
|
assert element1.same_element?(element3), 'should be the same element'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dom_glancy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- geordie
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|