WIP : Coupon functional tests
This commit is contained in:
@@ -7,11 +7,6 @@ var thelia2_login_coupon_create_url = thelia2_base_url + 'admin/coupon/create/';
|
|||||||
var thelia2_login_coupon_read_url = thelia2_base_url + 'admin/coupon/read/1';
|
var thelia2_login_coupon_read_url = thelia2_base_url + 'admin/coupon/read/1';
|
||||||
var thelia2_login_coupon_update_url = thelia2_base_url + 'admin/coupon/update/1';
|
var thelia2_login_coupon_update_url = thelia2_base_url + 'admin/coupon/update/1';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//var findMyId = /([0-9]+)$/;
|
|
||||||
//var currentId;
|
|
||||||
|
|
||||||
casper.test.comment('Variables are set');
|
casper.test.comment('Variables are set');
|
||||||
|
|
||||||
casper.test.done(0);
|
casper.test.done(0);
|
||||||
|
|||||||
@@ -1,312 +1,312 @@
|
|||||||
////
|
|
||||||
////var casper = require('casper').create({
|
|
||||||
//// viewportSize:{
|
|
||||||
//// width:1024, height:768
|
|
||||||
//// },
|
|
||||||
//// pageSettings:{
|
|
||||||
//// userAgent:'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.79 Safari/535.11'
|
|
||||||
//// },
|
|
||||||
//// verbose:true
|
|
||||||
////});
|
|
||||||
//
|
//
|
||||||
//casper.test.comment('Testing coupons rules');
|
//var casper = require('casper').create({
|
||||||
//
|
// viewportSize:{
|
||||||
////UPDATE COUPON RULE
|
// width:1024, height:768
|
||||||
//casper.start(thelia2_login_coupon_update_url, function() {
|
// },
|
||||||
// this.test.assertHttpStatus(200);
|
// pageSettings:{
|
||||||
// this.test.comment('Now on : ' + this.getCurrentUrl());
|
// userAgent:'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.79 Safari/535.11'
|
||||||
// this.capture('tests/functionnal/casperjs/screenshot/coupons/init.png');
|
// },
|
||||||
// this.test.comment('COUPON RULE - EDIT');
|
// verbose:true
|
||||||
// this.test.assertTitle('Update coupon - Thelia Back Office', 'Web page title OK');
|
|
||||||
// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','1) 1st default rule found');
|
|
||||||
// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','1) 2nd default rule found');
|
|
||||||
//
|
|
||||||
// // Create rule
|
|
||||||
// this.evaluate(function() {
|
|
||||||
// $('#category-rule').val('thelia.constraint.rule.available_for_x_articles').change();
|
|
||||||
// return true;
|
|
||||||
//});
|
//});
|
||||||
// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-selected.png');
|
|
||||||
|
casper.test.comment('Testing coupons rules');
|
||||||
|
|
||||||
|
//UPDATE COUPON RULE
|
||||||
|
casper.start(thelia2_login_coupon_update_url, function() {
|
||||||
|
this.test.assertHttpStatus(200);
|
||||||
|
this.test.comment('Now on : ' + this.getCurrentUrl());
|
||||||
|
this.capture('tests/functionnal/casperjs/screenshot/coupons/init.png');
|
||||||
|
this.test.comment('COUPON RULE - EDIT');
|
||||||
|
this.test.assertTitle('Update coupon - Thelia Back Office', 'Web page title OK');
|
||||||
|
this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','1) 1st default rule found');
|
||||||
|
this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','1) 2nd default rule found');
|
||||||
|
|
||||||
|
// Create rule
|
||||||
|
this.evaluate(function() {
|
||||||
|
$('#category-rule').val('thelia.constraint.rule.available_for_x_articles').change();
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-selected.png');
|
||||||
|
});
|
||||||
|
|
||||||
|
casper.wait(1000, function() {
|
||||||
|
this.echo("\nWaiting....");
|
||||||
|
});
|
||||||
|
|
||||||
|
// Test Rule updating
|
||||||
|
casper.then(function(){
|
||||||
|
this.evaluate(function() {
|
||||||
|
$('#quantity-operator').val('>=').change();
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
this.sendKeys('input#quantity-value', '4');
|
||||||
|
this.click('#constraint-save-btn');
|
||||||
|
});
|
||||||
|
|
||||||
|
casper.wait(1000, function() {
|
||||||
|
this.echo("\nWaiting....");
|
||||||
|
});
|
||||||
|
|
||||||
|
casper.then(function(){
|
||||||
|
this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-added.png');
|
||||||
|
this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','2) 1st default rule found');
|
||||||
|
this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','2) 2nd default rule found');
|
||||||
|
this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(3)', ' If cart products quantity is superior or equal to 4','2) 3rd rule found');
|
||||||
|
|
||||||
|
// Click on Edit button
|
||||||
|
this.click('tbody#constraint-list tr:nth-child(3) .constraint-update-btn');
|
||||||
|
});
|
||||||
|
|
||||||
|
casper.wait(2000, function() {
|
||||||
|
this.echo("\nWaiting....");
|
||||||
|
});
|
||||||
|
|
||||||
|
casper.then(function(){
|
||||||
|
this.evaluate(function() {
|
||||||
|
$('#quantity-operator').val('==').change();
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Removing old value
|
||||||
|
// casper.evaluate(function triggerKeyDownEvent() {
|
||||||
|
// var e = $.Event("keydown");
|
||||||
|
// e.which = 8;
|
||||||
|
// e.keyCode = 8;
|
||||||
|
// $("#quantity-value").trigger(e);
|
||||||
// });
|
// });
|
||||||
//
|
this.evaluate(function() {
|
||||||
//casper.wait(1000, function() {
|
$("#quantity-value").val('').change();
|
||||||
// this.echo("\nWaiting....");
|
return true;
|
||||||
//});
|
});
|
||||||
//
|
|
||||||
//// Test Rule updating
|
// Adding new value
|
||||||
//casper.then(function(){
|
this.sendKeys('#quantity-value', '5');
|
||||||
// this.evaluate(function() {
|
this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-being-edited.png');
|
||||||
// $('#quantity-operator').val('>=').change();
|
this.click('#constraint-save-btn');
|
||||||
// return true;
|
});
|
||||||
// });
|
|
||||||
// this.sendKeys('input#quantity-value', '4');
|
casper.wait(2000, function() {
|
||||||
// this.click('#constraint-save-btn');
|
this.echo("\nWaiting....");
|
||||||
//});
|
});
|
||||||
//
|
// Check if updated rule has been saved and list refreshed
|
||||||
//casper.wait(1000, function() {
|
casper.then(function(){
|
||||||
// this.echo("\nWaiting....");
|
this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-edited.png');
|
||||||
//});
|
this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','3) 1st default rule found');
|
||||||
//
|
this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','3) 2nd default rule found');
|
||||||
//casper.then(function(){
|
this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(3)', 'If cart products quantity is equal to 5','3) 3rd rule updated found');
|
||||||
// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-added.png');
|
});
|
||||||
// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','2) 1st default rule found');
|
|
||||||
// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','2) 2nd default rule found');
|
// Check if updated rule has been well saved
|
||||||
// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(3)', ' If cart products quantity is superior or equal to 4','2) 3rd rule found');
|
casper.thenOpen(thelia2_login_coupon_update_url, function() {
|
||||||
//
|
this.test.assertHttpStatus(200);
|
||||||
// // Click on Edit button
|
this.test.comment('Now on : ' + this.getCurrentUrl());
|
||||||
// this.click('tbody#constraint-list tr:nth-child(3) .constraint-update-btn');
|
this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-edited-refreshed.png');
|
||||||
//});
|
this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','4) 1st default rule found');
|
||||||
//
|
this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','4) 2nd default rule found');
|
||||||
//casper.wait(2000, function() {
|
this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(3)', 'If cart products quantity is equal to 5','4) 3rd rule updated found');
|
||||||
// this.echo("\nWaiting....");
|
|
||||||
//});
|
// Click on Delete button
|
||||||
//
|
this.click('tbody#constraint-list tr:nth-child(2) .constraint-delete-btn');
|
||||||
//casper.then(function(){
|
});
|
||||||
// this.evaluate(function() {
|
|
||||||
// $('#quantity-operator').val('==').change();
|
casper.wait(2000, function() {
|
||||||
// return true;
|
this.echo("\nWaiting....");
|
||||||
// });
|
});
|
||||||
//
|
|
||||||
// // Removing old value
|
casper.then(function(){
|
||||||
//// casper.evaluate(function triggerKeyDownEvent() {
|
this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','5) 1st default rule found');
|
||||||
//// var e = $.Event("keydown");
|
this.test.assertSelectorDoesntHaveText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','5) 2nd default rule found');
|
||||||
//// e.which = 8;
|
this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart products quantity is equal to 5','5) 3rd rule updated found');
|
||||||
//// e.keyCode = 8;
|
});
|
||||||
//// $("#quantity-value").trigger(e);
|
|
||||||
//// });
|
// Check if updated rule has been well saved
|
||||||
// this.evaluate(function() {
|
casper.thenOpen(thelia2_login_coupon_update_url, function() {
|
||||||
// $("#quantity-value").val('').change();
|
this.test.assertHttpStatus(200);
|
||||||
// return true;
|
this.test.comment('Now on : ' + this.getCurrentUrl());
|
||||||
// });
|
this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-deleted-refreshed.png');
|
||||||
//
|
this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','6) 1st default rule found');
|
||||||
// // Adding new value
|
this.test.assertSelectorDoesntHaveText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','6) 2nd default rule found');
|
||||||
// this.sendKeys('#quantity-value', '5');
|
this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart products quantity is equal to 5','6) 3rd rule updated found');
|
||||||
// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-being-edited.png');
|
});
|
||||||
// this.click('#constraint-save-btn');
|
|
||||||
//});
|
// Test creating rule that won't be edited
|
||||||
//
|
casper.then(function(){
|
||||||
//casper.wait(2000, function() {
|
// Create rule
|
||||||
// this.echo("\nWaiting....");
|
this.evaluate(function() {
|
||||||
//});
|
$('#category-rule').val('thelia.constraint.rule.available_for_total_amount').change();
|
||||||
//// Check if updated rule has been saved and list refreshed
|
return true;
|
||||||
//casper.then(function(){
|
});
|
||||||
// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-edited.png');
|
this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-selected2.png');
|
||||||
// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','3) 1st default rule found');
|
});
|
||||||
// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','3) 2nd default rule found');
|
|
||||||
// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(3)', 'If cart products quantity is equal to 5','3) 3rd rule updated found');
|
casper.wait(2000, function() {
|
||||||
//});
|
this.echo("\nWaiting....");
|
||||||
//
|
});
|
||||||
//// Check if updated rule has been well saved
|
|
||||||
//casper.thenOpen(thelia2_login_coupon_update_url, function() {
|
// Test Rule creation
|
||||||
// this.test.assertHttpStatus(200);
|
casper.then(function(){
|
||||||
// this.test.comment('Now on : ' + this.getCurrentUrl());
|
this.evaluate(function() {
|
||||||
// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-edited-refreshed.png');
|
$('#price-operator').val('<=').change();
|
||||||
// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','4) 1st default rule found');
|
return true;
|
||||||
// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','4) 2nd default rule found');
|
});
|
||||||
// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(3)', 'If cart products quantity is equal to 5','4) 3rd rule updated found');
|
// Removing old value
|
||||||
//
|
// casper.evaluate(function triggerKeyDownEvent() {
|
||||||
// // Click on Delete button
|
// var e = $.Event("keydown");
|
||||||
// this.click('tbody#constraint-list tr:nth-child(2) .constraint-delete-btn');
|
// e.which = 8;
|
||||||
//});
|
// e.keyCode = 8;
|
||||||
//
|
// $("input#price-value").trigger(e);
|
||||||
//casper.wait(2000, function() {
|
|
||||||
// this.echo("\nWaiting....");
|
|
||||||
//});
|
|
||||||
//
|
|
||||||
//casper.then(function(){
|
|
||||||
// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','5) 1st default rule found');
|
|
||||||
// this.test.assertSelectorDoesntHaveText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','5) 2nd default rule found');
|
|
||||||
// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart products quantity is equal to 5','5) 3rd rule updated found');
|
|
||||||
//});
|
|
||||||
//
|
|
||||||
//// Check if updated rule has been well saved
|
|
||||||
//casper.thenOpen(thelia2_login_coupon_update_url, function() {
|
|
||||||
// this.test.assertHttpStatus(200);
|
|
||||||
// this.test.comment('Now on : ' + this.getCurrentUrl());
|
|
||||||
// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-deleted-refreshed.png');
|
|
||||||
// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','6) 1st default rule found');
|
|
||||||
// this.test.assertSelectorDoesntHaveText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','6) 2nd default rule found');
|
|
||||||
// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart products quantity is equal to 5','6) 3rd rule updated found');
|
|
||||||
//});
|
|
||||||
//
|
|
||||||
//// Test creating rule that won't be edited
|
|
||||||
//casper.then(function(){
|
|
||||||
//// Create rule
|
|
||||||
// this.evaluate(function() {
|
|
||||||
// $('#category-rule').val('thelia.constraint.rule.available_for_total_amount').change();
|
|
||||||
// return true;
|
|
||||||
// });
|
|
||||||
// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-selected2.png');
|
|
||||||
//});
|
|
||||||
//
|
|
||||||
//casper.wait(2000, function() {
|
|
||||||
// this.echo("\nWaiting....");
|
|
||||||
//});
|
|
||||||
//
|
|
||||||
//// Test Rule creation
|
|
||||||
//casper.then(function(){
|
|
||||||
// this.evaluate(function() {
|
|
||||||
// $('#price-operator').val('<=').change();
|
|
||||||
// return true;
|
|
||||||
// });
|
|
||||||
// // Removing old value
|
|
||||||
//// casper.evaluate(function triggerKeyDownEvent() {
|
|
||||||
//// var e = $.Event("keydown");
|
|
||||||
//// e.which = 8;
|
|
||||||
//// e.keyCode = 8;
|
|
||||||
//// $("input#price-value").trigger(e);
|
|
||||||
//// });
|
|
||||||
// this.evaluate(function() {
|
|
||||||
// $("input#price-value").val('').change();
|
|
||||||
// return true;
|
|
||||||
// });
|
|
||||||
//
|
|
||||||
// // Changing 400 to 401
|
|
||||||
// this.sendKeys('input#price-value', '401');
|
|
||||||
// this.evaluate(function() {
|
|
||||||
// $('#currency-value').val('GBP').change();
|
|
||||||
// return true;
|
|
||||||
// });
|
|
||||||
// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-saved-edited-before-click-save.png');
|
|
||||||
// this.click('#constraint-save-btn');
|
|
||||||
//});
|
|
||||||
//
|
|
||||||
//casper.wait(2000, function() {
|
|
||||||
// this.echo("\nWaiting....");
|
|
||||||
//});
|
|
||||||
//
|
|
||||||
//casper.then(function(){
|
|
||||||
// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','7) 1st default rule found');
|
|
||||||
// this.test.assertSelectorDoesntHaveText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','7) 2nd default rule found');
|
|
||||||
// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart products quantity is equal to 5','7) 3rd rule updated found');
|
|
||||||
// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(3)', 'If cart total amount is inferior or equal to 401 GBP','7) 4rd rule created found');
|
|
||||||
//});
|
|
||||||
//
|
|
||||||
//// Check if created rule has been well saved
|
|
||||||
//casper.thenOpen(thelia2_login_coupon_update_url, function() {
|
|
||||||
// this.test.assertHttpStatus(200);
|
|
||||||
// this.test.comment('Now on : ' + this.getCurrentUrl());
|
|
||||||
// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-added-refreshed.png');
|
|
||||||
// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','8) 1st default rule found');
|
|
||||||
// this.test.assertSelectorDoesntHaveText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','8) 2nd default rule found');
|
|
||||||
// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart products quantity is equal to 5','8) 3rd rule updated found');
|
|
||||||
// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(3)', 'If cart total amount is inferior or equal to 401 GBP','8) 4rd rule created found');
|
|
||||||
//});
|
|
||||||
//
|
|
||||||
//// Testing deleting all rules
|
|
||||||
//casper.then(function(){
|
|
||||||
//// Click on Delete button
|
|
||||||
// this.click('tbody#constraint-list tr:nth-child(1) .constraint-delete-btn');
|
|
||||||
//});
|
|
||||||
//casper.wait(1000, function() {
|
|
||||||
// this.echo("\nWaiting....");
|
|
||||||
//});
|
|
||||||
//casper.then(function(){
|
|
||||||
//// Click on Delete button
|
|
||||||
// this.click('tbody#constraint-list tr:nth-child(1) .constraint-delete-btn');
|
|
||||||
//});
|
|
||||||
//casper.wait(1000, function() {
|
|
||||||
// this.echo("\nWaiting....");
|
|
||||||
//});
|
|
||||||
//casper.then(function(){
|
|
||||||
//// Click on Delete button
|
|
||||||
// this.click('tbody#constraint-list tr:nth-child(1) .constraint-delete-btn');
|
|
||||||
//});
|
|
||||||
//casper.wait(1000, function() {
|
|
||||||
// this.echo("\nWaiting....");
|
|
||||||
//});
|
|
||||||
//casper.then(function(){
|
|
||||||
// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-all-deleted.png');
|
|
||||||
// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'No conditions','9) 1st default rule found');
|
|
||||||
// test.assertDoesntExist('tbody#constraint-list tr:nth-child(2)');
|
|
||||||
//});
|
|
||||||
//
|
|
||||||
//// Check if created rule has been well saved
|
|
||||||
//casper.thenOpen(thelia2_login_coupon_update_url, function() {
|
|
||||||
// this.test.assertHttpStatus(200);
|
|
||||||
// this.test.comment('Now on : ' + this.getCurrentUrl());
|
|
||||||
// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-all-deleted-refreshed.png');
|
|
||||||
// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'No conditions','10) 1st default rule found');
|
|
||||||
// test.assertDoesntExist('tbody#constraint-list tr:nth-child(2)');
|
|
||||||
//});
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//// Test add no condition rule
|
|
||||||
//casper.then(function(){
|
|
||||||
// this.evaluate(function() {
|
|
||||||
// $('#category-rule').val('thelia.constraint.rule.available_for_x_articles').change();
|
|
||||||
// return true;
|
|
||||||
// });
|
|
||||||
//});
|
|
||||||
//
|
|
||||||
//casper.wait(1000, function() {
|
|
||||||
// this.echo("\nWaiting....");
|
|
||||||
//});
|
|
||||||
//
|
|
||||||
//// Test Rule updating
|
|
||||||
//casper.then(function(){
|
|
||||||
// this.evaluate(function() {
|
|
||||||
// $('#quantity-operator').val('>').change();
|
|
||||||
// return true;
|
|
||||||
// });
|
|
||||||
// this.sendKeys('input#quantity-value', '4');
|
|
||||||
// this.click('#constraint-save-btn');
|
|
||||||
//});
|
|
||||||
//
|
|
||||||
//casper.wait(1000, function() {
|
|
||||||
// this.echo("\nWaiting....");
|
|
||||||
//});
|
|
||||||
//
|
|
||||||
//casper.then(function(){
|
|
||||||
// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-all-deleted.png');
|
|
||||||
// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart products quantity is superior to 4', '11) 1st default rule found');
|
|
||||||
// test.assertDoesntExist('tbody#constraint-list tr:nth-child(2)');
|
|
||||||
//});
|
|
||||||
//
|
|
||||||
//// Check if created rule has been well saved
|
|
||||||
//casper.thenOpen(thelia2_login_coupon_update_url, function() {
|
|
||||||
// this.test.assertHttpStatus(200);
|
|
||||||
// this.test.comment('Now on : ' + this.getCurrentUrl());
|
|
||||||
// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-all-deleted-refreshed.png');
|
|
||||||
// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart products quantity is superior to 4','12) 1st default rule found');
|
|
||||||
// test.assertDoesntExist('tbody#constraint-list tr:nth-child(2)');
|
|
||||||
//});
|
|
||||||
//
|
|
||||||
//casper.then(function(){
|
|
||||||
// this.evaluate(function() {
|
|
||||||
// $('#category-rule').val('thelia.constraint.rule.available_for_everyone').change();
|
|
||||||
// return true;
|
|
||||||
// });
|
|
||||||
//});
|
|
||||||
//
|
|
||||||
//casper.wait(1000, function() {
|
|
||||||
// this.echo("\nWaiting....");
|
|
||||||
//});
|
|
||||||
//
|
|
||||||
//// Test Rule updating
|
|
||||||
//casper.then(function(){
|
|
||||||
// this.click('#constraint-save-btn');
|
|
||||||
//});
|
|
||||||
//
|
|
||||||
//casper.wait(1000, function() {
|
|
||||||
// this.echo("\nWaiting....");
|
|
||||||
//});
|
|
||||||
//casper.then(function(){
|
|
||||||
// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-all-deleted.png');
|
|
||||||
// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'No conditions','13) 1st default rule found');
|
|
||||||
// test.assertDoesntExist('tbody#constraint-list tr:nth-child(2)');
|
|
||||||
//});
|
|
||||||
//
|
|
||||||
//// Check if created rule has been well saved
|
|
||||||
//casper.thenOpen(thelia2_login_coupon_update_url, function() {
|
|
||||||
// this.test.assertHttpStatus(200);
|
|
||||||
// this.test.comment('Now on : ' + this.getCurrentUrl());
|
|
||||||
// this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-all-deleted-refreshed.png');
|
|
||||||
// this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'No conditions','14) 1st default rule found');
|
|
||||||
// test.assertDoesntExist('tbody#constraint-list tr:nth-child(2)');
|
|
||||||
//});
|
|
||||||
//
|
|
||||||
////RUN
|
|
||||||
//casper.run(function() {
|
|
||||||
// this.test.done();
|
|
||||||
// });
|
// });
|
||||||
|
this.evaluate(function() {
|
||||||
|
$("input#price-value").val('').change();
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Changing 400 to 401
|
||||||
|
this.sendKeys('input#price-value', '401');
|
||||||
|
this.evaluate(function() {
|
||||||
|
$('#currency-value').val('GBP').change();
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-saved-edited-before-click-save.png');
|
||||||
|
this.click('#constraint-save-btn');
|
||||||
|
});
|
||||||
|
|
||||||
|
casper.wait(2000, function() {
|
||||||
|
this.echo("\nWaiting....");
|
||||||
|
});
|
||||||
|
|
||||||
|
casper.then(function(){
|
||||||
|
this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','7) 1st default rule found');
|
||||||
|
this.test.assertSelectorDoesntHaveText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','7) 2nd default rule found');
|
||||||
|
this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart products quantity is equal to 5','7) 3rd rule updated found');
|
||||||
|
this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(3)', 'If cart total amount is inferior or equal to 401 GBP','7) 4rd rule created found');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Check if created rule has been well saved
|
||||||
|
casper.thenOpen(thelia2_login_coupon_update_url, function() {
|
||||||
|
this.test.assertHttpStatus(200);
|
||||||
|
this.test.comment('Now on : ' + this.getCurrentUrl());
|
||||||
|
this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-added-refreshed.png');
|
||||||
|
this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','8) 1st default rule found');
|
||||||
|
this.test.assertSelectorDoesntHaveText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','8) 2nd default rule found');
|
||||||
|
this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(2)', 'If cart products quantity is equal to 5','8) 3rd rule updated found');
|
||||||
|
this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(3)', 'If cart total amount is inferior or equal to 401 GBP','8) 4rd rule created found');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Testing deleting all rules
|
||||||
|
casper.then(function(){
|
||||||
|
// Click on Delete button
|
||||||
|
this.click('tbody#constraint-list tr:nth-child(1) .constraint-delete-btn');
|
||||||
|
});
|
||||||
|
casper.wait(1000, function() {
|
||||||
|
this.echo("\nWaiting....");
|
||||||
|
});
|
||||||
|
casper.then(function(){
|
||||||
|
// Click on Delete button
|
||||||
|
this.click('tbody#constraint-list tr:nth-child(1) .constraint-delete-btn');
|
||||||
|
});
|
||||||
|
casper.wait(1000, function() {
|
||||||
|
this.echo("\nWaiting....");
|
||||||
|
});
|
||||||
|
casper.then(function(){
|
||||||
|
// Click on Delete button
|
||||||
|
this.click('tbody#constraint-list tr:nth-child(1) .constraint-delete-btn');
|
||||||
|
});
|
||||||
|
casper.wait(1000, function() {
|
||||||
|
this.echo("\nWaiting....");
|
||||||
|
});
|
||||||
|
casper.then(function(){
|
||||||
|
this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-all-deleted.png');
|
||||||
|
this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'No conditions','9) 1st default rule found');
|
||||||
|
test.assertDoesntExist('tbody#constraint-list tr:nth-child(2)');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Check if created rule has been well saved
|
||||||
|
casper.thenOpen(thelia2_login_coupon_update_url, function() {
|
||||||
|
this.test.assertHttpStatus(200);
|
||||||
|
this.test.comment('Now on : ' + this.getCurrentUrl());
|
||||||
|
this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-all-deleted-refreshed.png');
|
||||||
|
this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'No conditions','10) 1st default rule found');
|
||||||
|
test.assertDoesntExist('tbody#constraint-list tr:nth-child(2)');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// Test add no condition rule
|
||||||
|
casper.then(function(){
|
||||||
|
this.evaluate(function() {
|
||||||
|
$('#category-rule').val('thelia.constraint.rule.available_for_x_articles').change();
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
casper.wait(1000, function() {
|
||||||
|
this.echo("\nWaiting....");
|
||||||
|
});
|
||||||
|
|
||||||
|
// Test Rule updating
|
||||||
|
casper.then(function(){
|
||||||
|
this.evaluate(function() {
|
||||||
|
$('#quantity-operator').val('>').change();
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
this.sendKeys('input#quantity-value', '4');
|
||||||
|
this.click('#constraint-save-btn');
|
||||||
|
});
|
||||||
|
|
||||||
|
casper.wait(1000, function() {
|
||||||
|
this.echo("\nWaiting....");
|
||||||
|
});
|
||||||
|
|
||||||
|
casper.then(function(){
|
||||||
|
this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-all-deleted.png');
|
||||||
|
this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart products quantity is superior to 4', '11) 1st default rule found');
|
||||||
|
test.assertDoesntExist('tbody#constraint-list tr:nth-child(2)');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Check if created rule has been well saved
|
||||||
|
casper.thenOpen(thelia2_login_coupon_update_url, function() {
|
||||||
|
this.test.assertHttpStatus(200);
|
||||||
|
this.test.comment('Now on : ' + this.getCurrentUrl());
|
||||||
|
this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-all-deleted-refreshed.png');
|
||||||
|
this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart products quantity is superior to 4','12) 1st default rule found');
|
||||||
|
test.assertDoesntExist('tbody#constraint-list tr:nth-child(2)');
|
||||||
|
});
|
||||||
|
|
||||||
|
casper.then(function(){
|
||||||
|
this.evaluate(function() {
|
||||||
|
$('#category-rule').val('thelia.constraint.rule.available_for_everyone').change();
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
casper.wait(1000, function() {
|
||||||
|
this.echo("\nWaiting....");
|
||||||
|
});
|
||||||
|
|
||||||
|
// Test Rule updating
|
||||||
|
casper.then(function(){
|
||||||
|
this.click('#constraint-save-btn');
|
||||||
|
});
|
||||||
|
|
||||||
|
casper.wait(1000, function() {
|
||||||
|
this.echo("\nWaiting....");
|
||||||
|
});
|
||||||
|
casper.then(function(){
|
||||||
|
this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-all-deleted.png');
|
||||||
|
this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'No conditions','13) 1st default rule found');
|
||||||
|
test.assertDoesntExist('tbody#constraint-list tr:nth-child(2)');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Check if created rule has been well saved
|
||||||
|
casper.thenOpen(thelia2_login_coupon_update_url, function() {
|
||||||
|
this.test.assertHttpStatus(200);
|
||||||
|
this.test.comment('Now on : ' + this.getCurrentUrl());
|
||||||
|
this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-all-deleted-refreshed.png');
|
||||||
|
this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'No conditions','14) 1st default rule found');
|
||||||
|
test.assertDoesntExist('tbody#constraint-list tr:nth-child(2)');
|
||||||
|
});
|
||||||
|
|
||||||
|
//RUN
|
||||||
|
casper.run(function() {
|
||||||
|
this.test.done();
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user