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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2652a65dec1c5c98ff34e5c08d53fee7f2d37491
4
- data.tar.gz: f6a4fcfef1372c84781e2af456e85f2c27e79cd1
3
+ metadata.gz: b4f6b85d8b3b3b443273ccd45b0d0ebc35ac1a49
4
+ data.tar.gz: 0e8ad79d21beace912bc8a6a656ca5a064045c83
5
5
  SHA512:
6
- metadata.gz: bfb04f669881c5e6c30f05a4015b93ecfd5f712a207ef02a67b880e297ea9fcf6a0044a4606fc2655d98f07734d84200ee97d640a93dc1c2af37f86fe19ad39a
7
- data.tar.gz: 066fe6d51d913d860d17b5140a2c43adc8f9275b48eebbb51c3ce387a3579f758213b2cf0208259c72a62acb36aa302277a1951cd66df066ecd332e609a0a8e2
6
+ metadata.gz: 09c300f922d5983a387d2e5c68566b0e33c9596661b33f89c3c5ff4150b6975ca70e7a25554be56ddc21b935e78d45a2e0c4c79b4c3b0cf7bff6b7381695d018
7
+ data.tar.gz: 9f315183d832157878c0456682275ea7f059f211463179abfad71e28e065e7cea9169e09836e0a2f2ecec370aa520b6637a21a5931b74dc6047d70cf735b7efc
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 1.0.1
2
+
3
+ - Fix 'make master' bug
4
+ - Style links a bit on new page for usability
5
+
1
6
  ## 1.0.0
2
7
 
3
8
  - Change configuration syntax
data/Gemfile CHANGED
@@ -12,4 +12,4 @@ gem 'mocha'
12
12
 
13
13
  gem 'selenium-webdriver', '2.44.0'
14
14
  gem 'capybara', '2.2.1'
15
- gem 'ae_page_objects', '1.0.0'
15
+ gem 'ae_page_objects', '1.3.0'
@@ -129,8 +129,7 @@ a.kr:active { text-decoration:none; color: #A3906D; }
129
129
  }
130
130
 
131
131
  .kr--artifacts td {
132
- padding-left: 7px;
133
- padding-right: 7px;
132
+ padding: 7px;
134
133
  }
135
134
 
136
135
  .kr--button {
@@ -34,8 +34,8 @@ class DomGlancyController < DomGlancyApplicationController
34
34
 
35
35
  def make_master
36
36
  test_root = params[:file]
37
- src = DomGlancy.configuration.current_filename(test_root)
38
- dst = DomGlancy.configuration.master_filename(test_root)
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.configuration.current_filename(test_root)
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>
@@ -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] #unless element1.close_enough?(element2)
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
@@ -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'] || 15
28
+ @similarity = h[:similarity] || h['similarity'] || 0
29
29
  end
30
30
 
31
31
  def same_element?(anOther)
@@ -1,3 +1,3 @@
1
1
  module DomGlancy
2
- VERSION = '1.0.0'.freeze
2
+ VERSION = '1.0.1'.freeze
3
3
  end
@@ -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
@@ -38,4 +38,6 @@ class DomGlancyTestCase < Minitest::Test
38
38
  def setup
39
39
  @dom_glancy = DomGlancy::DomGlancy.new
40
40
  end
41
+
42
+ DomGlancy.configure
41
43
  end
@@ -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({"left" => 72}))
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
- assert element1.close_enough?(element2), 'should be the same element, but with slight differences'
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({"similarity" => 2}))
23
- element2 = DomGlancy::DOMElement.new(single_element_hash.merge({"left" => 72}))
24
- element3 = DomGlancy::DOMElement.new(single_element_hash.merge({"left" => 74}))
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.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-09 00:00:00.000000000 Z
11
+ date: 2014-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler