From 16e5dc3ae6c18ea9f50c8245e1ded49ff9f88e55 Mon Sep 17 00:00:00 2001 From: Paul Hayes Date: Wed, 23 Aug 2017 09:33:50 +0100 Subject: [PATCH] Blacklist paths that aren't useful in visual regression Paths containing "path" in them break Wraith: https://github.com/BBC-News/wraith/issues/536 Search API incorrectly returns government-frontend as renderer for travel advice index, this will always give a difference between live and a review app. --- lib/helpers/wraith_config_helper.rb | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/helpers/wraith_config_helper.rb b/lib/helpers/wraith_config_helper.rb index 429d4bf5c..8fc999ee3 100644 --- a/lib/helpers/wraith_config_helper.rb +++ b/lib/helpers/wraith_config_helper.rb @@ -29,11 +29,13 @@ def build_paths if @paths.is_a? Hash @paths.keys.each do |key| @paths.fetch(key).each_with_index do |path, index| - config_paths[path_index(key, index + 1)] = path + config_paths[path_index(key, index + 1)] = path unless path_blacklisted?(path) end end else - @paths.each_with_index { |path, index| config_paths[path_index(name, index + 1)] = path } + @paths.each_with_index do |path, index| + config_paths[path_index(name, index + 1)] = path unless path_blacklisted?(path) + end end config_paths @@ -43,6 +45,19 @@ def path_index(prefix, index) "#{prefix}_#{index}" end + # Remove paths that aren't useful + # + # TODO: Remove when Wraith patched + # Paths containing "path" in them break Wraith: + # https://github.com/BBC-News/wraith/issues/536 + # + # TODO: Remove when Search API no longer returns + # Search API incorrectly returns government-frontend as + # renderer for travel advice index + def path_blacklisted?(path) + path.include?('path') || path == "/foreign-travel-advice" + end + def write_config(config) file_name = OUTPUT_PATH % { suffix: @name } File.open(file_name, 'w') { |f| f.write config.to_yaml }