WIP : coupon refactor + fix
This commit is contained in:
@@ -9,31 +9,31 @@
|
||||
// verbose:true
|
||||
//});
|
||||
|
||||
casper.test.comment('Testing coupons rules');
|
||||
casper.test.comment('Testing coupons conditions');
|
||||
|
||||
//UPDATE COUPON RULE
|
||||
//UPDATE COUPON CONDITION
|
||||
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.comment('COUPON CONDITION - 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');
|
||||
this.test.assertSelectorHasText('tbody#condition-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','1) 1st default condition found');
|
||||
this.test.assertSelectorHasText('tbody#condition-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','1) 2nd default condition found');
|
||||
|
||||
// Create rule
|
||||
// Create condition
|
||||
this.evaluate(function() {
|
||||
$('#category-rule').val('thelia.condition.match_for_x_articles').change();
|
||||
$('#category-condition').val('thelia.condition.match_for_x_articles').change();
|
||||
return true;
|
||||
});
|
||||
this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-selected.png');
|
||||
this.capture('tests/functionnal/casperjs/screenshot/coupons/condition-selected.png');
|
||||
});
|
||||
|
||||
casper.wait(1000, function() {
|
||||
this.echo("\nWaiting....");
|
||||
});
|
||||
|
||||
// Test Rule updating
|
||||
// Test Condition updating
|
||||
casper.then(function(){
|
||||
this.evaluate(function() {
|
||||
$('#quantity-operator').val('>=').change();
|
||||
@@ -48,13 +48,13 @@ casper.wait(1000, function() {
|
||||
});
|
||||
|
||||
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');
|
||||
this.capture('tests/functionnal/casperjs/screenshot/coupons/condition-added.png');
|
||||
this.test.assertSelectorHasText('tbody#condition-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','2) 1st default condition found');
|
||||
this.test.assertSelectorHasText('tbody#condition-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','2) 2nd default condition found');
|
||||
this.test.assertSelectorHasText('tbody#condition-list tr:nth-child(3)', ' If cart products quantity is superior or equal to 4','2) 3rd condition found');
|
||||
|
||||
// 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) .condition-update-btn');
|
||||
});
|
||||
|
||||
casper.wait(2000, function() {
|
||||
@@ -81,32 +81,32 @@ casper.then(function(){
|
||||
|
||||
// Adding new value
|
||||
this.sendKeys('#quantity-value', '5');
|
||||
this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-being-edited.png');
|
||||
this.capture('tests/functionnal/casperjs/screenshot/coupons/condition-being-edited.png');
|
||||
this.click('#constraint-save-btn');
|
||||
});
|
||||
|
||||
casper.wait(2000, function() {
|
||||
this.echo("\nWaiting....");
|
||||
});
|
||||
// Check if updated rule has been saved and list refreshed
|
||||
// Check if updated condition has been saved and list refreshed
|
||||
casper.then(function(){
|
||||
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');
|
||||
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/condition-edited.png');
|
||||
this.test.assertSelectorHasText('tbody#condition-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','3) 1st default condition found');
|
||||
this.test.assertSelectorHasText('tbody#condition-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','3) 2nd default condition found');
|
||||
this.test.assertSelectorHasText('tbody#condition-list tr:nth-child(3)', 'If cart products quantity is equal to 5','3) 3rd condition updated found');
|
||||
});
|
||||
|
||||
// Check if updated rule has been well saved
|
||||
// Check if updated condition 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-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');
|
||||
this.test.assertSelectorHasText('tbody#constraint-list tr:nth-child(3)', 'If cart products quantity is equal to 5','4) 3rd rule updated found');
|
||||
this.capture('tests/functionnal/casperjs/screenshot/coupons/condition-edited-refreshed.png');
|
||||
this.test.assertSelectorHasText('tbody#condition-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','4) 1st default condition found');
|
||||
this.test.assertSelectorHasText('tbody#condition-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','4) 2nd default condition found');
|
||||
this.test.assertSelectorHasText('tbody#condition-list tr:nth-child(3)', 'If cart products quantity is equal to 5','4) 3rd condition updated found');
|
||||
|
||||
// Click on Delete button
|
||||
this.click('tbody#constraint-list tr:nth-child(2) .constraint-delete-btn');
|
||||
this.click('tbody#condition-list tr:nth-child(2) .condition-delete-btn');
|
||||
});
|
||||
|
||||
casper.wait(2000, function() {
|
||||
@@ -114,36 +114,36 @@ casper.wait(2000, function() {
|
||||
});
|
||||
|
||||
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');
|
||||
this.test.assertSelectorHasText('tbody#condition-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','5) 1st default condition found');
|
||||
this.test.assertSelectorDoesntHaveText('tbody#condition-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','5) 2nd default condition found');
|
||||
this.test.assertSelectorHasText('tbody#condition-list tr:nth-child(2)', 'If cart products quantity is equal to 5','5) 3rd condition updated found');
|
||||
});
|
||||
|
||||
// Check if updated rule has been well saved
|
||||
// Check if updated condition 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');
|
||||
this.capture('tests/functionnal/casperjs/screenshot/coupons/condition-deleted-refreshed.png');
|
||||
this.test.assertSelectorHasText('tbody#condition-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','6) 1st default condition found');
|
||||
this.test.assertSelectorDoesntHaveText('tbody#condition-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','6) 2nd default condition found');
|
||||
this.test.assertSelectorHasText('tbody#condition-list tr:nth-child(2)', 'If cart products quantity is equal to 5','6) 3rd condition updated found');
|
||||
});
|
||||
|
||||
// Test creating rule that won't be edited
|
||||
// Test creating condition that won't be edited
|
||||
casper.then(function(){
|
||||
// Create rule
|
||||
// Create condition
|
||||
this.evaluate(function() {
|
||||
$('#category-rule').val('thelia.condition.match_for_total_amount').change();
|
||||
$('#category-condition').val('thelia.condition.match_for_total_amount').change();
|
||||
return true;
|
||||
});
|
||||
this.capture('tests/functionnal/casperjs/screenshot/coupons/rule-selected2.png');
|
||||
this.capture('tests/functionnal/casperjs/screenshot/coupons/condition-selected2.png');
|
||||
});
|
||||
|
||||
casper.wait(2000, function() {
|
||||
this.echo("\nWaiting....");
|
||||
});
|
||||
|
||||
// Test Rule creation
|
||||
// Test Condition creation
|
||||
casper.then(function(){
|
||||
this.evaluate(function() {
|
||||
$('#price-operator').val('<=').change();
|
||||
@@ -167,8 +167,8 @@ casper.then(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');
|
||||
this.capture('tests/functionnal/casperjs/screenshot/coupons/condition-saved-edited-before-click-save.png');
|
||||
this.click('#condition-save-btn');
|
||||
});
|
||||
|
||||
casper.wait(2000, function() {
|
||||
@@ -176,65 +176,65 @@ casper.wait(2000, function() {
|
||||
});
|
||||
|
||||
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');
|
||||
this.test.assertSelectorHasText('tbody#condition-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','7) 1st default condition found');
|
||||
this.test.assertSelectorDoesntHaveText('tbody#condition-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','7) 2nd default condition found');
|
||||
this.test.assertSelectorHasText('tbody#condition-list tr:nth-child(2)', 'If cart products quantity is equal to 5','7) 3rd condition updated found');
|
||||
this.test.assertSelectorHasText('tbody#condition-list tr:nth-child(3)', 'If cart total amount is inferior or equal to 401 GBP','7) 4rd condition created found');
|
||||
});
|
||||
|
||||
// Check if created rule has been well saved
|
||||
// Check if created condition 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');
|
||||
this.capture('tests/functionnal/casperjs/screenshot/coupons/condition-added-refreshed.png');
|
||||
this.test.assertSelectorHasText('tbody#condition-list tr:nth-child(1)', 'If cart total amount is superior to 40 EUR','8) 1st default condition found');
|
||||
this.test.assertSelectorDoesntHaveText('tbody#condition-list tr:nth-child(2)', 'If cart total amount is inferior to 400 EUR','8) 2nd default condition found');
|
||||
this.test.assertSelectorHasText('tbody#condition-list tr:nth-child(2)', 'If cart products quantity is equal to 5','8) 3rd condition updated found');
|
||||
this.test.assertSelectorHasText('tbody#condition-list tr:nth-child(3)', 'If cart total amount is inferior or equal to 401 GBP','8) 4rd condition created found');
|
||||
});
|
||||
|
||||
// Testing deleting all rules
|
||||
// Testing deleting all conditions
|
||||
casper.then(function(){
|
||||
// Click on Delete button
|
||||
this.click('tbody#constraint-list tr:nth-child(1) .constraint-delete-btn');
|
||||
this.click('tbody#condition-list tr:nth-child(1) .condition-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');
|
||||
this.click('tbody#condition-list tr:nth-child(1) .condition-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');
|
||||
this.click('tbody#condition-list tr:nth-child(1) .condition-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)');
|
||||
this.capture('tests/functionnal/casperjs/screenshot/coupons/condition-all-deleted.png');
|
||||
this.test.assertSelectorHasText('tbody#condition-list tr:nth-child(1)', 'No conditions','9) 1st default condition found');
|
||||
test.assertDoesntExist('tbody#condition-list tr:nth-child(2)');
|
||||
});
|
||||
|
||||
// Check if created rule has been well saved
|
||||
// Check if created condition 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)');
|
||||
this.capture('tests/functionnal/casperjs/screenshot/coupons/condition-all-deleted-refreshed.png');
|
||||
this.test.assertSelectorHasText('tbody#condition-list tr:nth-child(1)', 'No conditions','10) 1st default condition found');
|
||||
test.assertDoesntExist('tbody#condition-list tr:nth-child(2)');
|
||||
});
|
||||
|
||||
|
||||
// Test add no condition rule
|
||||
casper.then(function(){
|
||||
this.evaluate(function() {
|
||||
$('#category-rule').val('thelia.condition.match_for_x_articles').change();
|
||||
$('#category-condition').val('thelia.condition.match_for_x_articles').change();
|
||||
return true;
|
||||
});
|
||||
});
|
||||
@@ -243,14 +243,14 @@ casper.wait(1000, function() {
|
||||
this.echo("\nWaiting....");
|
||||
});
|
||||
|
||||
// Test Rule updating
|
||||
// Test Condition updating
|
||||
casper.then(function(){
|
||||
this.evaluate(function() {
|
||||
$('#quantity-operator').val('>').change();
|
||||
return true;
|
||||
});
|
||||
this.sendKeys('input#quantity-value', '4');
|
||||
this.click('#constraint-save-btn');
|
||||
this.click('#condition-save-btn');
|
||||
});
|
||||
|
||||
casper.wait(1000, function() {
|
||||
@@ -258,23 +258,23 @@ casper.wait(1000, function() {
|
||||
});
|
||||
|
||||
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)');
|
||||
this.capture('tests/functionnal/casperjs/screenshot/coupons/condition-all-deleted.png');
|
||||
this.test.assertSelectorHasText('tbody#condition-list tr:nth-child(1)', 'If cart products quantity is superior to 4', '11) 1st default condition found');
|
||||
test.assertDoesntExist('tbody#condition-list tr:nth-child(2)');
|
||||
});
|
||||
|
||||
// Check if created rule has been well saved
|
||||
// Check if created condition 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)');
|
||||
this.capture('tests/functionnal/casperjs/screenshot/coupons/condition-all-deleted-refreshed.png');
|
||||
this.test.assertSelectorHasText('tbody#condition-list tr:nth-child(1)', 'If cart products quantity is superior to 4','12) 1st default condition found');
|
||||
test.assertDoesntExist('tbody#condition-list tr:nth-child(2)');
|
||||
});
|
||||
|
||||
casper.then(function(){
|
||||
this.evaluate(function() {
|
||||
$('#category-rule').val('thelia.condition.match_for_everyone').change();
|
||||
$('#category-condition').val('thelia.condition.match_for_everyone').change();
|
||||
return true;
|
||||
});
|
||||
});
|
||||
@@ -283,27 +283,27 @@ casper.wait(1000, function() {
|
||||
this.echo("\nWaiting....");
|
||||
});
|
||||
|
||||
// Test Rule updating
|
||||
// Test Condition updating
|
||||
casper.then(function(){
|
||||
this.click('#constraint-save-btn');
|
||||
this.click('#condition-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)');
|
||||
this.capture('tests/functionnal/casperjs/screenshot/coupons/condition-all-deleted.png');
|
||||
this.test.assertSelectorHasText('tbody#condition-list tr:nth-child(1)', 'No condition','13) 1st default condition found');
|
||||
test.assertDoesntExist('tbody#condition-list tr:nth-child(2)');
|
||||
});
|
||||
|
||||
// Check if created rule has been well saved
|
||||
// Check if created condition 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)');
|
||||
this.capture('tests/functionnal/casperjs/screenshot/coupons/condition-all-deleted-refreshed.png');
|
||||
this.test.assertSelectorHasText('tbody#condition-list tr:nth-child(1)', 'No condition','14) 1st default condition found');
|
||||
test.assertDoesntExist('tbody#condition-list tr:nth-child(2)');
|
||||
});
|
||||
|
||||
//RUN
|
||||
|
||||
Reference in New Issue
Block a user