Skip to content
This repository has been archived by the owner on Dec 20, 2022. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #1559 from locaweb/wraith
Wraith - Teste de Regressão
  • Loading branch information
deividmarques committed Aug 6, 2015
2 parents d59a765 + 0890b0d commit f77e9dd
Show file tree
Hide file tree
Showing 56 changed files with 175 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -4,6 +4,9 @@
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile ~/.gitignore_global

# Ignore folder where the screenshots diff stays
test_shots/

# Ignore bundler config
/.bundle

Expand Down
1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -21,3 +21,4 @@ gem 'oj' # faster JS compiles
gem "pry"

gem 'rack-cors', require: false
gem 'wraith' #css test diff image compare
6 changes: 5 additions & 1 deletion scripts/tasks/tests.rake
Expand Up @@ -3,9 +3,13 @@
namespace :tests do
desc "Run all Locastyle tests"
task :run do
puts "Running Jasmine tests..."
puts "\n\n############################# \n Starting Jasmine tests... \n#############################"
Rake::Task["jasmine:ci"].invoke

puts "\n\n############################# \n Starting JSHint tests... \n#############################"
Rake::Task["jshint"].invoke

#puts "\n\n############################# \n Starting Wraith tests... \n#############################"
#sh %{wraith latest spec/wraith/configs/config.yaml} # Running regression test of CSS diff image
end
end
4 changes: 2 additions & 2 deletions source/documentacao/exemplos/painel2/config-email.html.erb
Expand Up @@ -102,14 +102,14 @@ title_product: SMTP Locaweb
<tbody>
<%- 2.times do %>
<tr>
<td><%= lorem.email %></td>
<td>georgesiegel@me.com</td>
<td>Configurado</td>
<td class="ls-txt-right ls-regroup">
<a href="#" class="ls-btn-danger ls-btn-xs">Excluir</a>
</td>
</tr>
<tr>
<td><%= lorem.email %></td>
<td>sienna_jones@fastmail.com</td>
<td><span>Não Configurado</span></td>
<td class="ls-txt-right ls-regroup">
<a href="#" class="ls-btn ls-btn-xs">Reenviar e-mail</a>
Expand Down
2 changes: 1 addition & 1 deletion source/index.html.erb
Expand Up @@ -67,7 +67,7 @@ keywords: documentação, locastyle
</a>
</div>
<div class="col-md-4">
<a href="<%= base_url+"/documentacao/exemplos/painel1/client/" %>" class="doc-portfolio-thumb">
<a href="<%= base_url+"/documentacao/exemplos/painel1/client.html" %>" class="doc-portfolio-thumb">
<img src="<%= base_url %>/assets/images/docs/intro-2.png" alt="Print da página de exemplo de clientes">
<h3>Página de Cliente</h3>
<p>Exemplo da página de Cliente.</p>
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions spec/wraith/configs/config.yaml
@@ -0,0 +1,53 @@
#Headless browser option
browser:
phantomjs: "phantomjs"
# slimerjs: "slimerjs"

#If you want to have multiple snapping files, set the file name here
snap_file: "spec/wraith/javascript/snap.js"

# Type the name of the directory that shots will be stored in
directory: 'spec/wraith/test_shots'
history_dir: 'spec/wraith/baseline_shots'

# Add only 2 domains, key will act as a label
domains:
local: "http://localhost:4567"

#Type screen widths below, here are a couple of examples
screen_widths:
- 320
- 768
- 1024
- 1280

#Type page URL paths below, here are a couple of examples
paths:
revenda_prepanel: /documentacao/exemplos/painel1/pre-painel
revenda_home: /documentacao/exemplos/painel1/home
revenda_clients: /documentacao/exemplos/painel1/clients
revenda_client: /documentacao/exemplos/painel1/client
smtp_prepanel: /documentacao/exemplos/painel2/pre-painel
smtp_home: /documentacao/exemplos/painel2/home
smtp_report: /documentacao/exemplos/painel2/stats
smtp_config: /documentacao/exemplos/painel2/config-server
smtp_config_email: /documentacao/exemplos/painel2/config-email
login: /documentacao/exemplos/login-screen
error_404: /documentacao/exemplos/erro-404
# all_elements: /documentacao/cartilha-de-elementos/
boilerplate: /documentacao/exemplos/boilerplate

#Amount of fuzz ImageMagick will use
fuzz: '15%'

#Set the number of days to keep the site spider file
spider_days:
- 10

#Choose how results are displayed, by default alphanumeric. Different screen widths are always grouped.
#alphanumeric - all paths (with, and without, a difference) are shown, sorted by path
#diffs_first - all paths (with, and without, a difference) are shown, sorted by difference size (largest first)
#diffs_only - only paths with a difference are shown, sorted by difference size (largest first)
mode: diffs_first

threshold: 0.5
25 changes: 25 additions & 0 deletions spec/wraith/javascript/casper.js
@@ -0,0 +1,25 @@
var system = require('system');
var page = require('webpage').create();
var fs = require('fs');
var casper = require("casper").create();

var url = casper.cli.get(0);
var view_port_width = casper.cli.get(1);
var image_name = casper.cli.get(2);
var selector = casper.cli.get(3);

casper.start(url, function() {
this.viewport(view_port_width, 1500).then(function(){
this.wait(2000, function() {
if (selector == undefined) {
this.capture(image_name);
}
else {
this.captureSelector(image_name, selector);
}
console.log('Snapping ' + url + ' at width ' + view_port_width);
});
});
});

casper.run();
85 changes: 85 additions & 0 deletions spec/wraith/javascript/snap.js
@@ -0,0 +1,85 @@
var system = require('system');
var page = require('webpage').create();
var fs = require('fs');

if (system.args.length === 3) {
console.log('Usage: snap.js <some URL> <view port width> <target image name>');
phantom.exit();
}

var url = system.args[1];
var image_name = system.args[3];
var view_port_width = system.args[2];
var current_requests = 0;
var last_request_timeout;
var final_timeout;


page.viewportSize = { width: view_port_width, height: 1500};
page.settings = { loadImages: true, javascriptEnabled: true };

// If you want to use additional phantomjs commands, place them here
page.settings.userAgent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/28.0.1500.95 Safari/537.17';

// You can place custom headers here, example below.
// page.customHeaders = {

// 'X-Candy-OVERRIDE': 'https://api.live.bbc.co.uk/'

// };

// If you want to set a cookie, just add your details below in the following way.

// phantom.addCookie({
// 'name': 'ckns_policy',
// 'value': '111',
// 'domain': '.bbc.co.uk'
// });
// phantom.addCookie({
// 'name': 'locserv',
// 'value': '1#l1#i=6691484:n=Oxford+Circus:h=e@w1#i=8:p=London@d1#1=l:2=e:3=e:4=2@n1#r=40',
// 'domain': '.bbc.co.uk'
// });

page.onResourceRequested = function(req) {
current_requests += 1;
};

page.onResourceReceived = function(res) {
if (res.stage === 'end') {
current_requests -= 1;
debounced_render();
}
};

page.open(url, function(status) {
if (status !== 'success') {
console.log('Error with page ' + url);
phantom.exit();
}
});


function debounced_render() {
clearTimeout(last_request_timeout);
clearTimeout(final_timeout);

// If there's no more ongoing resource requests, wait for 1 second before
// rendering, just in case the page kicks off another request
if (current_requests < 1) {
clearTimeout(final_timeout);
last_request_timeout = setTimeout(function() {
console.log('Snapping ' + url + ' at width ' + view_port_width);
page.render(image_name);
phantom.exit();
}, 1000);
}

// Sometimes, straggling requests never make it back, in which
// case, timeout after 5 seconds and render the page anyway
final_timeout = setTimeout(function() {
console.log('Snapping ' + url + ' at width ' + view_port_width);
page.render(image_name);
phantom.exit();
}, 5000);
}

0 comments on commit f77e9dd

Please sign in to comment.