- Coupon Add/Edit/Delete rule AJAX
This commit is contained in:
gmorel
2013-09-12 14:10:36 +02:00
parent 936d0dbe37
commit 8668bf93bd
5 changed files with 148 additions and 72 deletions

View File

@@ -133,21 +133,21 @@ abstract class Operators
break; break;
case self::INFERIOR_OR_EQUAL: case self::INFERIOR_OR_EQUAL:
$ret = $translator->trans( $ret = $translator->trans(
'inferior or equals to', 'inferior or equal to',
array(), array(),
'constraint' 'constraint'
); );
break; break;
case self::EQUAL: case self::EQUAL:
$ret = $translator->trans( $ret = $translator->trans(
'equals to', 'equal to',
array(), array(),
'constraint' 'constraint'
); );
break; break;
case self::SUPERIOR_OR_EQUAL: case self::SUPERIOR_OR_EQUAL:
$ret = $translator->trans( $ret = $translator->trans(
'superior or equals to', 'superior or equal to',
array(), array(),
'constraint' 'constraint'
); );

View File

@@ -22,17 +22,20 @@ $(function($){
}; };
// Add 1 Rule / or update the temporary Rules array then Save Rules via AJAX // Add 1 Rule / or update the temporary Rules array then Save Rules via AJAX
couponManager.addRuleAjax = function(id) { couponManager.createOrUpdateRuleAjax = function() {
console.log('addRuleAjax '+ id); var id = couponManager.ruleToUpdateId;
console.log('createOrUpdateRuleAjax '+ id);
// If create // If create
if(!id) { if(!id) {
console.log('pushing'); console.log('pushing');
console.log(couponManager.ruleToSave);
couponManager.rulesToSave.push(couponManager.ruleToSave); couponManager.rulesToSave.push(couponManager.ruleToSave);
} else { // else update } else { // else update
console.log('editing ' + id); console.log('editing ' + id);
console.log(couponManager.ruleToSave);
couponManager.rulesToSave[id] = couponManager.ruleToSave; couponManager.rulesToSave[id] = couponManager.ruleToSave;
// reset edit mode to off // reset edit mode to off
couponManager.ruleIdToUpdate = false; couponManager.ruleToUpdateId = false;
} }
// Save // Save
@@ -40,21 +43,21 @@ $(function($){
}; };
// Set rule inputs to allow editing // Set rule inputs to allow editing
couponManager.updateRuleAjax = function(id) { couponManager.updateRuleSelectAjax = function(id) {
couponManager.ruleToUpdate = couponManager.rulesToSave[id]; couponManager.ruleToUpdateId = id;
couponManager.ruleToSave = couponManager.rulesToSave[id];
console.log('Set id to edit to ' + id); console.log('Set id to edit to ' + id);
couponManager.ruleIdToUpdate = id;
// Deleting this rule, we will reset it // // Deleting this rule, we will reset it
delete couponManager.rulesToSave[id]; // delete couponManager.rulesToSave[id];
// Set the rule selector // Set the rule selector
$("#category-rule option").filter(function() { $("#category-rule option").filter(function() {
return $(this).val() == couponManager.ruleToUpdate.serviceId; return $(this).val() == couponManager.ruleToSave.serviceId;
}).prop('selected', true); }).prop('selected', true);
// Force rule input refresh // Force rule input refresh
couponManager.loadRuleInputs(couponManager.ruleToUpdate.serviceId, function() { couponManager.loadRuleInputs(couponManager.ruleToSave.serviceId, function() {
couponManager.fillInRuleInputs(); couponManager.fillInRuleInputs();
}); });
}; };
@@ -62,39 +65,40 @@ $(function($){
// Fill in rule inputs // Fill in rule inputs
couponManager.fillInRuleInputs = function() { couponManager.fillInRuleInputs = function() {
console.log('fillInRuleInputs with'); console.log('fillInRuleInputs with');
console.log(couponManager.ruleToUpdate); console.log(couponManager.ruleToSave);
var operatorId = null; var operatorId = null;
var valueId = null; var valueId = null;
var idName = null; var idName = null;
var id = couponManager.ruleToUpdateId;
if(id) { if(id) {
couponManager.ruleToUpdate = couponManager.ruleToSave; couponManager.ruleToSave = couponManager.rulesToSave[id];
} }
for (idName in couponManager.ruleToUpdate.operators) { for (idName in couponManager.ruleToSave.operators) {
// Setting idName operator select // Setting idName operator select
operatorId = idName + '-operator'; operatorId = idName + '-operator';
$('#' + operatorId).val(couponManager.ruleToUpdate.operators[idName]); $('#' + operatorId).val(couponManager.ruleToSave.operators[idName]);
valueId = idName + '-value';
// Setting idName value input // Setting idName value input
$('#' + valueId).val(couponManager.ruleToUpdate.values[idName]); valueId = idName + '-value';
$('#' + valueId).val(couponManager.ruleToSave.values[idName]);
} }
couponManager.ruleToSave = couponManager.ruleToUpdate; // couponManager.ruleToSave = couponManager.ruleToUpdate;
var id = couponManager.ruleIdToUpdate; // var id = couponManager.ruleToUpdateId;
console.log('id to edit = ' + id); // console.log('id to edit = ' + id);
if(id) { // if(id) {
console.log('setint rulesToSave[' + id + ']'); // console.log('setint rulesToSave[' + id + ']');
console.log(couponManager.ruleToSave); // console.log(couponManager.ruleToSave);
couponManager.rulesToSave[id] = couponManager.ruleToSave; // couponManager.rulesToSave[id] = couponManager.ruleToSave;
} // }
}; };
// Save rules on click // Save rules on click
couponManager.onClickSaveRule = function() { couponManager.onClickSaveRule = function() {
$('#constraint-save-btn').on('click', function () { $('#constraint-save-btn').on('click', function () {
couponManager.addRuleAjax(couponManager.ruleIdToUpdate); couponManager.createOrUpdateRuleAjax();
}); });
}; };
couponManager.onClickSaveRule(); couponManager.onClickSaveRule();
@@ -114,7 +118,7 @@ $(function($){
$('.constraint-update-btn').on('click', function (e) { $('.constraint-update-btn').on('click', function (e) {
e.preventDefault(); e.preventDefault();
var $this = $(this); var $this = $(this);
couponManager.updateRuleAjax($this.attr('data-int')); couponManager.updateRuleSelectAjax($this.attr('data-int'));
// Hide row being updated // Hide row being updated
$this.parent().parent().remove(); $this.parent().parent().remove();
@@ -134,7 +138,7 @@ $(function($){
// Reload rule inputs when changing effect // Reload rule inputs when changing effect
couponManager.onRuleChange = function() { couponManager.onRuleChange = function() {
$('#category-rule').on('change', function () { $('#category-rule').on('change', function () {
couponManager.loadRuleInputs($(this).val(), function(ruleToSave) {}); couponManager.loadRuleInputs($(this).val(), function() {});
}); });
}; };
couponManager.onRuleChange(); couponManager.onRuleChange();
@@ -148,5 +152,12 @@ $(function($){
// Rule to save // Rule to save
var couponManager = {}; var couponManager = {};
// Rule to be saved
couponManager.ruleToSave = {}; couponManager.ruleToSave = {};
couponManager.ruleIdToUpdate = false; couponManager.ruleToSave.serviceId = false;
couponManager.ruleToSave.operators = {};
couponManager.ruleToSave.values = {};
// Rules payload to save
couponManager.rulesToSave = [];
// Rule being updated id
couponManager.ruleToUpdateId = false;

View File

@@ -87,6 +87,11 @@
}).done(function(data) { }).done(function(data) {
$('#constraint-list').html(data); $('#constraint-list').html(data);
$('#constraint-add-operators-values').html(''); $('#constraint-add-operators-values').html('');
// Set the rule selector
$("#category-rule option").filter(function() {
return $(this).val() == 'thelia.constraint.rule.available_for_everyone';
}).prop('selected', true);
couponManager.onClickUpdateRule(); couponManager.onClickUpdateRule();
couponManager.onClickDeleteRule(); couponManager.onClickDeleteRule();
}); });
@@ -108,6 +113,7 @@
} }
}).done(function(data) { }).done(function(data) {
$('#constraint-add-operators-values').html(data); $('#constraint-add-operators-values').html(data);
couponManager.ruleToSave.serviceId = ruleId;
return callBack(); return callBack();
}); });

View File

@@ -3,7 +3,7 @@
<div class="row"> <div class="row">
<div class="col-lg-6"> <div class="col-lg-6">
<select class="form-control" id="{$name}-operator" name="{$name}[operator]"> <select class="form-control" id="{$name}-operator" name="{$name}[operator]">
{foreach from=$input.availableOperators key=k item=availableOperator} {foreach from=$input.availableOperators key=k item=availableOperator name=availableOperators}
<option value="{$k}">{$availableOperator}</option> <option value="{$k}">{$availableOperator}</option>
{/foreach} {/foreach}
</select> </select>
@@ -11,7 +11,7 @@
<div class="input-group col-lg-6"> <div class="input-group col-lg-6">
{if $input.type == 'select'} {if $input.type == 'select'}
<select class="{$input.class}" id="{$name}-value" name="{$name}[value]"> <select class="{$input.class}" id="{$name}-value" name="{$name}[value]">
{foreach from=$input.availableValues key=code item=availableValue} {foreach from=$input.availableValues key=code item=availableValue name=availableValues}
<option value="{$code}">{$availableValue}</option> <option value="{$code}">{$availableValue}</option>
{/foreach} {/foreach}
</select> </select>
@@ -72,12 +72,20 @@
<script> <script>
// Init Rules to set // Init Rules to set
couponManager.ruleToSave['serviceId'] = '{$ruleId}'; // Update only if no rule are already set
couponManager.ruleToSave['operators'] = {literal}{}{/literal}; if(!couponManager.ruleToSave){
couponManager.ruleToSave['values'] = {literal}{}{/literal}; console.log('considering couponManager.ruleToSave as null');
console.log(couponManager.ruleToSave);
couponManager.ruleToSave['serviceId'] = '{$ruleId}';
couponManager.ruleToSave['operators'] = {literal}{}{/literal};
couponManager.ruleToSave['values'] = {literal}{}{/literal};
} else {
console.log('considering couponManager.ruleToSave as not null');
console.log(couponManager.ruleToSave);
}
{foreach from=$inputs.inputs key=name item=input} {foreach from=$inputs.inputs key=name item=input}
couponManager.ruleToSave['operators']['{$name nofilter}'] = '{foreach from=$inputs.inputs[$name].availableOperators key=keyOperator item=valueOperator name=operators}{if $smarty.foreach.operators.first}{$keyOperator nofilter}{/if}{/foreach}'; couponManager.ruleToSave['operators']['{$name nofilter}'] = '{foreach from=$inputs.inputs[$name].availableOperators key=keyOperator item=valueOperator name=operators}{if $smarty.foreach.operators.first}{$keyOperator nofilter}{/if}{/foreach}';
couponManager.ruleToSave['values']['{$name nofilter}'] = '{if count($inputs.inputs[$name].availableValues) != 0}{foreach from=$inputs.inputs[$name].availableValues key=keyValue item=valueValue name=values}{if $smarty.foreach.values.first}{$keyValue nofilter}{/if}{/foreach}{else}to set{/if}'; couponManager.ruleToSave['values']['{$name nofilter}'] = '{if count($inputs.inputs[$name].availableValues) != 0}{foreach from=$inputs.inputs[$name].availableValues key=keyValue item=valueValue name=values}{if $smarty.foreach.values.first}{$keyValue nofilter}{/if}{/foreach}{else}to set{/if}';
{/foreach} {/foreach}
@@ -86,15 +94,17 @@
{foreach from=$inputs.inputs key=name item=input} {foreach from=$inputs.inputs key=name item=input}
// Operator selector // Operator selector
$('#{$name}-operator').change(function (e) { $('#{$name}-operator').change(function (e) {
console.log('changin operator'); console.log('changin operator {$name nofilter}');
var $this = $(this); var $this = $(this);
couponManager.ruleToSave['operators']['{$name nofilter}'] = $this.val(); couponManager.ruleToSave['operators']['{$name nofilter}'] = $this.val();
console.log(couponManager.ruleToSave['operators']['{$name nofilter}']);
}); });
// Value input // Value input
$('#{$name}-value').change(function (e) { $('#{$name}-value').change(function (e) {
console.log('changin value'); console.log('changin value {$name nofilter}');
var $this = $(this); var $this = $(this);
couponManager.ruleToSave['values']['{$name nofilter}'] = $this.val(); couponManager.ruleToSave['values']['{$name nofilter}'] = $this.val();
console.log(couponManager.ruleToSave['values']['{$name nofilter}']);
}); });
{/foreach} {/foreach}
{literal}}{/literal} {literal}}{/literal}

View File

@@ -1,5 +1,15 @@
casper.test.comment('Testing coupons'); //
//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');
////LIST ////LIST
// @todo implement // @todo implement
@@ -9,11 +19,12 @@ casper.test.comment('Testing coupons');
//UPDATE COUPON RULE //UPDATE COUPON RULE
casper.start(thelia2_login_coupon_update_url, function() { casper.start(thelia2_login_coupon_update_url, function() {
this.test.comment('Now on : ' + this.getCurrentUrl());
this.capture('tests/functionnal/casperjs/screenshot/coupons/init.png'); this.capture('tests/functionnal/casperjs/screenshot/coupons/init.png');
this.echo('\nCOUPON RULE - EDIT'); this.test.comment('COUPON RULE - EDIT');
this.test.assertTitle('Update coupon - Thelia Back Office', 'Web page title OK'); 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','1st default rule found'); 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','2nd 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 // Create rule
this.evaluate(function() { this.evaluate(function() {
@@ -43,9 +54,9 @@ casper.wait(1000, function() {
casper.then(function(){ casper.then(function(){
this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-added.png'); 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','1st default rule found'); 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','2nd 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 equals to 4','3rd 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 // Click on Edit button
this.click('tbody#constraint-list tr:nth-child(3) .constraint-update-btn'); this.click('tbody#constraint-list tr:nth-child(3) .constraint-update-btn');
@@ -60,6 +71,20 @@ casper.then(function(){
$('#quantity-operator').val('==').change(); $('#quantity-operator').val('==').change();
return true; 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() {
$("#quantity-value").val('').change();
return true;
});
// Adding new value
this.sendKeys('#quantity-value', '5'); this.sendKeys('#quantity-value', '5');
this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-being-edited.png'); this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-being-edited.png');
this.click('#constraint-save-btn'); this.click('#constraint-save-btn');
@@ -71,31 +96,40 @@ casper.wait(2000, function() {
// Check if updated rule has been saved and list refreshed // Check if updated rule has been saved and list refreshed
casper.then(function(){ casper.then(function(){
this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-edited.png'); 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','1st default rule found'); 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','2nd 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 equals to 5','3rd rule updated found'); this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(3)', 'If cart products quantity is equal to 5','3) 3rd rule updated found');
}); });
// Check if updated rule has been well saved // Check if updated rule has been well saved
casper.start(thelia2_login_coupon_update_url, function() { casper.thenOpen(thelia2_login_coupon_update_url, function() {
this.test.comment('Now on : ' + this.getCurrentUrl());
this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-edited-refreshed.png'); 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','1st default rule found'); 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','2nd 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');
this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(3)', 'If cart products quantity is equals to 5','3rd rule updated found'); this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(3)', 'If cart products quantity is equal to 5','4) 3rd rule updated found');
// Click on Delete button // Click on Delete button
this.click('tbody#constraint-list tr:nth-child(2) .constraint-delete-btn'); this.click('tbody#constraint-list tr:nth-child(2) .constraint-delete-btn');
this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','1st default rule found'); });
this.test.assertSelectorDoesntHaveText('tbody#constraint-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','2nd default rule found');
this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(3)', 'If cart products quantity is equals to 5','3rd rule updated found'); 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 // Check if updated rule has been well saved
casper.start(thelia2_login_coupon_update_url, function() { casper.thenOpen(thelia2_login_coupon_update_url, function() {
this.test.comment('Now on : ' + this.getCurrentUrl());
this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-deleted-refreshed.png'); 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','1st default rule found'); 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','2nd 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(3)', 'If cart products quantity is equals to 5','3rd rule updated 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 // Test creating rule that won't be edited
@@ -108,7 +142,7 @@ casper.then(function(){
this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-selected2.png'); this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-selected2.png');
}); });
casper.wait(1000, function() { casper.wait(2000, function() {
this.echo("\nWaiting...."); this.echo("\nWaiting....");
}); });
@@ -118,32 +152,47 @@ casper.then(function(){
$('#price-operator').val('<=').change(); $('#price-operator').val('<=').change();
return true; 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.sendKeys('input#price-value', '401');
this.evaluate(function() { this.evaluate(function() {
$('#currency-value').val('GBP').change(); $('#currency-value').val('GBP').change();
return true; return true;
}); });
this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-saved-edited-before-click-save.png');
this.click('#constraint-save-btn'); this.click('#constraint-save-btn');
}); });
casper.wait(1000, function() { casper.wait(2000, function() {
this.echo("\nWaiting...."); this.echo("\nWaiting....");
}); });
casper.then(function(){ casper.then(function(){
this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','1st default rule found'); 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','2nd 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 equals to 5','3rd rule updated 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 equals to 401 GBP','4rd rule created 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 // Check if created rule has been well saved
casper.start(thelia2_login_coupon_update_url, function() { casper.thenOpen(thelia2_login_coupon_update_url, function() {
this.test.comment('Now on : ' + this.getCurrentUrl());
this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-added-refreshed.png'); 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','1st default rule found'); 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','2nd 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 equals to 5','3rd rule updated 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 equals to 401 GBP','4rd rule created 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');
}); });
////EDIT CHECK ////EDIT CHECK