Added functionnal test for front office : home, register, login, cart
This commit is contained in:
14
.travis.yml
14
.travis.yml
@@ -19,6 +19,20 @@ before_script:
|
||||
- php setup/faker.php
|
||||
- php Thelia module:activate Colissimo
|
||||
- php Thelia module:activate Cheque
|
||||
- "export PHANTOMJS_EXECUTABLE='phantomjs --local-to-remote-url-access=yes --ignore-ssl-errors=yes'"
|
||||
- "export DISPLAY=:99.0"
|
||||
- "sh -e /etc/init.d/xvfb start"
|
||||
- sleep 3
|
||||
- php -S localhost:8000 -t web/ &
|
||||
- sleep 3
|
||||
- cd ..
|
||||
- git clone https://github.com/n1k0/casperjs.git
|
||||
- cd casperjs
|
||||
- git checkout tags/1.0.4
|
||||
|
||||
script:
|
||||
- "DISPLAY=:99.0 ./bin/casperjs test ../test/tests/functionnal/casperjs/exe/front/ --pre=../test/tests/functionnal/casperjs/conf/local.js --verbose --thelia2_base_url='http://localhost:8000/index.php/'"
|
||||
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
|
||||
@@ -1,25 +1,43 @@
|
||||
#!/bin/bash
|
||||
# @author Guillaume MOREL
|
||||
|
||||
echo -e "\n\033[01;34m[INFO] Clearing caches\033[00m\n"
|
||||
php Thelia cache:clear
|
||||
|
||||
echo -e "\n\033[01;34m[INFO] Self-updating Composer\033[00m\n"
|
||||
composer self-update
|
||||
|
||||
echo -e "\n\033[01;34m[INFO] Downloading vendors\033[00m\n"
|
||||
composer install --prefer-dist --optimize-autoloader
|
||||
|
||||
echo "Force dropping database. All data will be lost."
|
||||
|
||||
cd local/config/
|
||||
|
||||
echo -e "\n\e[01;34m[INFO] Building Models file\e[00m\n"
|
||||
../../bin/propel build -v --output-dir=../../core/lib/
|
||||
echo -e "\n\033[01;34m[INFO] Building Models file\033[00m\n"
|
||||
../../bin/propel build -v --output-dir=../../core/lib/ --enable-identifier-quoting
|
||||
|
||||
echo -e "\n\e[01;34m[INFO] Building SQL CREATE file\e[00m\n"
|
||||
echo -e "\n\033[01;34m[INFO] Building SQL CREATE file\033[00m\n"
|
||||
../../bin/propel sql:build -v --output-dir=../../setup/
|
||||
|
||||
echo -e "\n\e[01;34m[INFO] Reloaded Thelia2 database\e[00m\n"
|
||||
echo -e "\n\033[01;34m[INFO] Reloading Thelia2 database\033[00m\n"
|
||||
cd ../..
|
||||
rm install/sqldb.map
|
||||
rm setup/sqldb.map
|
||||
php Thelia thelia:dev:reloadDB
|
||||
|
||||
echo -e "\n\e[01;34m[INFO] Installing fixtures\e[00m\n"
|
||||
echo -e "\n\033[01;34m[INFO] Installing fixtures\033[00m\n"
|
||||
php setup/faker.php
|
||||
|
||||
echo -e "\n\e[01;34m[INFO] Adding admin\e[00m\n"
|
||||
php Thelia thelia:create-admin --login_name thelia2 --password thelia2 --last_name thelia2 --first_name thelia2
|
||||
php Thelia admin:create --login_name thelia2 --password thelia2 --last_name thelia2 --first_name thelia2
|
||||
|
||||
echo -e "\n\033[01;34m[INFO] Clearing caches\033[00m\n"
|
||||
php Thelia cache:clear
|
||||
|
||||
echo -e "\n\033[01;34m[INFO] Activating Delivery Module(s)\033[00m\n"
|
||||
php Thelia module:activate Colissimo
|
||||
|
||||
echo -e "\n\033[01;34m[INFO] Activating Payment Module(s)\033[00m\n"
|
||||
php Thelia module:activate Cheque
|
||||
|
||||
casperjs test ./tests/functionnal/casperjs/exe --pre=./tests/functionnal/casperjs/conf/local.js --direct
|
||||
|
||||
@@ -1,3 +1,107 @@
|
||||
//LOCAL = ton pc
|
||||
var thelia2_base_url = 'http://www.thelia2.dev/index_dev.php/';
|
||||
casper.test.done(0);
|
||||
// LOCAL = ton pc
|
||||
|
||||
var system = require('system');
|
||||
|
||||
var thelia2_base_url = '';
|
||||
|
||||
|
||||
if (casper.cli.has('thelia2_base_url')){
|
||||
thelia2_base_url = casper.cli.get('thelia2_base_url');
|
||||
casper.test.comment('CasperJS will use Thelia on : '+ thelia2_base_url);
|
||||
} else if (system.env.thelia2_base_url){
|
||||
thelia2_base_url = system.env.thelia2_base_url;
|
||||
casper.test.comment('CasperJS will use Thelia (ENV) on : '+ thelia2_base_url);
|
||||
} else {
|
||||
thelia2_base_url = 'http://dev.thelia.net/index_dev.php/';
|
||||
casper.test.comment('CasperJS will use fallback URL for tests : '+ thelia2_base_url);
|
||||
casper.test.comment('If you want to use custom URL just set the environment variable `thelia2_base_url`');
|
||||
}
|
||||
|
||||
var screenshot_dir = 'tests/functionnal/casperjs/screenshot/';
|
||||
|
||||
|
||||
casper.options.viewportSize = {width: 1024, height: 768};
|
||||
|
||||
var viewports = [
|
||||
{
|
||||
'name': 'samsung-galaxy_y-portrait',
|
||||
'viewport': {width: 240, height: 320}
|
||||
},
|
||||
{
|
||||
'name': 'samsung-galaxy_y-landscape',
|
||||
'viewport': {width: 320, height: 240}
|
||||
},
|
||||
{
|
||||
'name': 'iphone5-portrait',
|
||||
'viewport': {width: 320, height: 568}
|
||||
},
|
||||
{
|
||||
'name': 'iphone5-landscape',
|
||||
'viewport': {width: 568, height: 320}
|
||||
},
|
||||
{
|
||||
'name': 'htc-one-portrait',
|
||||
'viewport': {width: 360, height: 640}
|
||||
},
|
||||
{
|
||||
'name': 'htc-one-landscape',
|
||||
'viewport': {width: 640, height: 360}
|
||||
},
|
||||
{
|
||||
'name': 'nokia-lumia-920-portrait',
|
||||
'viewport': {width: 240, height: 320}
|
||||
},
|
||||
{
|
||||
'name': 'nokia-lumia-920-landscape',
|
||||
'viewport': {width: 320, height: 240}
|
||||
},
|
||||
{
|
||||
'name': 'google-nexus-7-portrait',
|
||||
'viewport': {width: 603, height: 966}
|
||||
},
|
||||
{
|
||||
'name': 'google-nexus-7-landscape',
|
||||
'viewport': {width: 966, height: 603}
|
||||
},
|
||||
{
|
||||
'name': 'ipad-portrait',
|
||||
'viewport': {width: 768, height: 1024}
|
||||
},
|
||||
{
|
||||
'name': 'ipad-landscape',
|
||||
'viewport': {width: 1024, height: 768}
|
||||
},
|
||||
{
|
||||
'name': 'desktop-standard-vga',
|
||||
'viewport': {width: 640, height: 480}
|
||||
},
|
||||
{
|
||||
'name': 'desktop-standard-svga',
|
||||
'viewport': {width: 800, height: 600}
|
||||
},
|
||||
{
|
||||
'name': 'desktop-standard-hd',
|
||||
'viewport': {width: 1280, height: 720}
|
||||
},
|
||||
{
|
||||
'name': 'desktop-standard-sxga',
|
||||
'viewport': {width: 1280, height: 1024}
|
||||
},
|
||||
{
|
||||
'name': 'desktop-standard-sxga-plus',
|
||||
'viewport': {width: 1400, height: 1050}
|
||||
},
|
||||
{
|
||||
'name': 'desktop-standard-uxga',
|
||||
'viewport': {width: 1600, height: 1200}
|
||||
},
|
||||
{
|
||||
'name': 'desktop-standard-wuxga',
|
||||
'viewport': {width: 1920, height: 1200}
|
||||
},
|
||||
|
||||
];
|
||||
|
||||
;
|
||||
|
||||
casper.test.done();
|
||||
|
||||
@@ -17,4 +17,4 @@ var thelia2_content_image_list_url = thelia2_base_url + 'admin/content/update/1'
|
||||
|
||||
casper.test.comment('Variables are set');
|
||||
|
||||
casper.test.done(0);
|
||||
casper.test.done();
|
||||
|
||||
15
tests/functionnal/casperjs/exe/front/10_home.js
Normal file
15
tests/functionnal/casperjs/exe/front/10_home.js
Normal file
@@ -0,0 +1,15 @@
|
||||
casper.test.comment('== Front Homepage ==');
|
||||
|
||||
casper.test.begin('Front Homepage', 2, function suite(test) {
|
||||
|
||||
casper.start(thelia2_base_url, function() {
|
||||
test.assertTitle("", "Thelia 2 homepage title is the one expected");
|
||||
test.assertExists('form#form-search', "main search form is found");
|
||||
this.capture(screenshot_dir + 'front/10_home.png');
|
||||
});
|
||||
|
||||
casper.run(function() {
|
||||
test.done();
|
||||
});
|
||||
|
||||
});
|
||||
111
tests/functionnal/casperjs/exe/front/20_register.js
Normal file
111
tests/functionnal/casperjs/exe/front/20_register.js
Normal file
@@ -0,0 +1,111 @@
|
||||
casper.test.comment('== Register ==');
|
||||
|
||||
casper.test.begin('Register', 15, function suite(test) {
|
||||
|
||||
var newEmail = '';
|
||||
|
||||
casper.start(thelia2_base_url + "register", function() {
|
||||
test.assertTitle("Register - Thelia V2", "title is the one expected");
|
||||
test.assertExists('form#form-register', "register form is found");
|
||||
this.capture(screenshot_dir + 'front/20_register.png');
|
||||
|
||||
casper.test.comment('== Register blank account');
|
||||
|
||||
this.fill('form#form-register', {
|
||||
'thelia_customer_create[title]': '',
|
||||
'thelia_customer_create[firstname]': '',
|
||||
'thelia_customer_create[lastname]': '',
|
||||
'thelia_customer_create[email]': '',
|
||||
'thelia_customer_create[phone]': '',
|
||||
'thelia_customer_create[cellphone]': '',
|
||||
'thelia_customer_create[company]': '',
|
||||
'thelia_customer_create[address1]': '',
|
||||
'thelia_customer_create[address2]': '',
|
||||
'thelia_customer_create[zipcode]': '',
|
||||
'thelia_customer_create[city]': '',
|
||||
'thelia_customer_create[country]': '',
|
||||
'thelia_customer_create[password]': '',
|
||||
'thelia_customer_create[password_confirm]': '',
|
||||
'thelia_customer_create[newsletter]': ''
|
||||
}, true);
|
||||
|
||||
});
|
||||
|
||||
|
||||
casper.then(function() {
|
||||
|
||||
casper.test.comment('== Register thelia account');
|
||||
|
||||
this.capture(screenshot_dir + 'front/20_register-ko.png');
|
||||
|
||||
test.assertExists('.group-title.has-error', 'title can not be empty');
|
||||
test.assertExists('.group-firstname.has-error', 'firstname can not be empty');
|
||||
test.assertExists('.group-lastname.has-error', 'lastname can not be empty');
|
||||
test.assertExists('.group-email.has-error', 'email can not be empty');
|
||||
test.assertExists('.group-address1.has-error', 'address1 can not be empty');
|
||||
test.assertExists('.group-zip.has-error', 'zipcode can not be empty');
|
||||
test.assertExists('.group-city.has-error', 'city can not be empty');
|
||||
test.assertExists('.group-password.has-error', 'password can not be empty');
|
||||
test.assertExists('.group-password_confirm.has-error', 'password confirm can not be empty');
|
||||
|
||||
newEmail = Math.random().toString(36).substr(2,7) + '@thelia.net';
|
||||
|
||||
this.fill('form#form-register', {
|
||||
'thelia_customer_create[title]': 1,
|
||||
'thelia_customer_create[firstname]': 'thelia',
|
||||
'thelia_customer_create[lastname]': 'thelia',
|
||||
'thelia_customer_create[email]': 'test@thelia.net',
|
||||
'thelia_customer_create[phone]': '',
|
||||
'thelia_customer_create[cellphone]': '',
|
||||
'thelia_customer_create[company]': 'OpenStudio',
|
||||
'thelia_customer_create[address1]': '4 rue Rochon',
|
||||
'thelia_customer_create[address2]': '',
|
||||
'thelia_customer_create[zipcode]': '63000',
|
||||
'thelia_customer_create[city]': 'Clermont-Ferrand',
|
||||
'thelia_customer_create[country]': 64,
|
||||
'thelia_customer_create[password]': 'thelia',
|
||||
'thelia_customer_create[password_confirm]': 'thelia',
|
||||
'thelia_customer_create[newsletter]': ''
|
||||
}, false);
|
||||
|
||||
this.click('form#form-register button[type="submit"]');
|
||||
|
||||
});
|
||||
|
||||
casper.wait(1000, function(){
|
||||
|
||||
test.assertSelectorHasText('.group-email .help-block', 'This email already exists.');
|
||||
|
||||
this.fill('form#form-register', {
|
||||
'thelia_customer_create[email]': newEmail,
|
||||
'thelia_customer_create[password]': 'thelia',
|
||||
'thelia_customer_create[password_confirm]': 'thelia'
|
||||
}, false);
|
||||
|
||||
this.click('form#form-register button[type="submit"]');
|
||||
|
||||
});
|
||||
|
||||
casper.wait(2000, function() {
|
||||
|
||||
this.capture(screenshot_dir + 'front/20_register-ok.png');
|
||||
test.assertSelectorHasText('h1#main-label', 'My Account');
|
||||
test.assertExists('a.logout', 'Logout button exists');
|
||||
|
||||
casper.test.comment('== Logout');
|
||||
|
||||
this.click('a.logout');
|
||||
});
|
||||
|
||||
casper.wait(2000, function() {
|
||||
|
||||
test.assertExists('a.login', 'Login button exists');
|
||||
|
||||
});
|
||||
|
||||
|
||||
casper.run(function() {
|
||||
test.done();
|
||||
});
|
||||
|
||||
});
|
||||
71
tests/functionnal/casperjs/exe/front/30_login.js
Normal file
71
tests/functionnal/casperjs/exe/front/30_login.js
Normal file
@@ -0,0 +1,71 @@
|
||||
casper.test.comment('== Login ==');
|
||||
|
||||
casper.test.begin('Login', 5, function suite(test) {
|
||||
|
||||
casper.start(thelia2_base_url + "login", function() {
|
||||
test.assertTitle("Login - Thelia V2", "title is the one expected");
|
||||
test.assertExists('form#form-login', "login form is found");
|
||||
this.capture(screenshot_dir + 'front/30_login.png');
|
||||
|
||||
casper.test.comment('== Login with a bad account');
|
||||
|
||||
this.fill('form#form-login', {
|
||||
'thelia_customer_login[account]': "1"
|
||||
}, false);
|
||||
|
||||
});
|
||||
|
||||
casper.then(function(){
|
||||
|
||||
casper.evaluate(function(username, password) {
|
||||
document.querySelector('#email').value = username;
|
||||
document.querySelector('#password').disabled = false;
|
||||
document.querySelector('#password').value = password;
|
||||
}, 'chuck-norris@thelia.net', 'thelia');
|
||||
|
||||
this.capture(screenshot_dir + 'front/30_login-ko-0.png');
|
||||
|
||||
this.click('form#form-login button[type="submit"]');
|
||||
|
||||
});
|
||||
|
||||
casper.wait(2000, function(){
|
||||
|
||||
this.capture(screenshot_dir + 'front/30_login-ko.png');
|
||||
|
||||
test.assertSelectorHasText('form#form-login .alert-danger', 'Wrong email or password. Please try again');
|
||||
|
||||
casper.test.comment('== Login with a good account');
|
||||
|
||||
casper.evaluate(function(username, password) {
|
||||
document.querySelector('#email').value = username;
|
||||
document.querySelector('#password').disabled = false;
|
||||
document.querySelector('#password').value = password;
|
||||
}, 'test@thelia.net', 'azerty');
|
||||
|
||||
this.click('form#form-login button[type="submit"]');
|
||||
});
|
||||
|
||||
|
||||
casper.wait(2000, function(){
|
||||
|
||||
this.capture(screenshot_dir + 'front/30_login-ok.png');
|
||||
test.assertExists('a.logout', 'Logout button exists');
|
||||
|
||||
casper.test.comment('== Logout');
|
||||
|
||||
this.click('a.logout');
|
||||
});
|
||||
|
||||
casper.wait(2000, function(){
|
||||
|
||||
test.assertExists('a.login', 'Login button exists');
|
||||
|
||||
});
|
||||
|
||||
|
||||
casper.run(function() {
|
||||
test.done();
|
||||
});
|
||||
|
||||
});
|
||||
51
tests/functionnal/casperjs/exe/front/40_cart.js
Normal file
51
tests/functionnal/casperjs/exe/front/40_cart.js
Normal file
@@ -0,0 +1,51 @@
|
||||
casper.test.comment('== Cart ==');
|
||||
|
||||
casper.test.begin('Cart', 4, function suite(test) {
|
||||
|
||||
var productUrl = '';
|
||||
|
||||
casper.start(thelia2_base_url, function() {
|
||||
|
||||
casper.viewport(1280, 1024)
|
||||
|
||||
productUrl = this.getElementAttribute('a.product-info', 'href');
|
||||
|
||||
this.echo("product : " + productUrl);
|
||||
|
||||
casper.thenOpen(productUrl, function() {
|
||||
this.echo(this.getTitle());
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
casper.wait(2000, function(){
|
||||
this.capture(screenshot_dir + 'front/40_product.png');
|
||||
this.click("#pse-submit");
|
||||
});
|
||||
|
||||
casper.wait(2000, function() {
|
||||
this.captureSelector(screenshot_dir + 'front/40_added-to-cart.png', '.bootbox');
|
||||
test.assertSelectorHasText('.bootbox h3', 'The product has been added to your cart');
|
||||
});
|
||||
|
||||
|
||||
casper.then(function(){
|
||||
|
||||
this.thenOpen(thelia2_base_url + "cart", function() {
|
||||
this.echo(this.getTitle());
|
||||
test.assertExists("#cart .table-cart", "Cart table exists");
|
||||
test.assertElementCount("#cart .table-cart tbody tr", 2, "Cart contains 1 product")
|
||||
var link = this.getElementInfo('#cart .table-cart tbody tr a.thumbnail');
|
||||
//require('utils').dump(link);
|
||||
test.assertTruthy( link.attributes.href == productUrl, "This is the right product in cart");
|
||||
this.capture(screenshot_dir + 'front/40_cart.png');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
casper.run(function() {
|
||||
test.done();
|
||||
});
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user