Initial commit

This commit is contained in:
2021-03-23 13:54:38 +01:00
commit 82b142ff95
16941 changed files with 2617212 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
casper.test.comment('== Front Homepage ==');
casper.test.begin('Front Homepage', 2, function suite(test) {
casper.start(thelia2_base_url, function() {
test.assertTitle(thelia2_store_name, "This is the home page : " + this.getTitle());
test.assertExists('form#form-search', "main search form is found");
if (screenshot_enabled) {
this.capture(screenshot_dir + 'front/10_home.png');
}
});
casper.run(function() {
test.done();
});
});

View File

@@ -0,0 +1,139 @@
casper.test.comment('== Register ==');
casper.test.begin('Register', 15, function suite(test) {
var newEmail = '';
casper.start(thelia2_base_url + "register", function() {
test.assertTitle("Register - " + thelia2_store_name, "title is the one expected");
test.assertExists('form#form-register', "register form is found");
if (screenshot_enabled) {
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');
if (screenshot_enabled) {
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');
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[email_confirm]': '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.waitForSelector(
'.group-email .help-block',
function(){
test.assertSelectorHasText('.group-email .help-block', 'This email already exists.');
// generate a new email and save it
// we're going to use this new account later
newEmail = Math.random().toString(36).substr(2,7) + '@thelia.net';
thelia_customer.email = newEmail;
this.fill('form#form-register', {
'thelia_customer_create[email]': newEmail,
'thelia_customer_create[email_confirm]': newEmail,
'thelia_customer_create[password]': 'thelia',
'thelia_customer_create[password_confirm]': 'thelia'
}, false);
this.click('form#form-register button[type="submit"]');
},
function(){
this.die("Selector '.group-email .help-block' not found. It should contain 'This email already exists'");
},
thelia_default_timeout
);
casper.waitForSelector(
'.navbar-customer a.account',
function() {
if (screenshot_enabled) {
this.capture(screenshot_dir + 'front/20_register-ok.png');
}
test.assertSelectorHasText('.navbar-customer a.account', 'My Account');
test.assertExists('a.logout', 'Logout button exists');
casper.test.comment('== Logout');
this.click('a.logout');
},
function(){
this.die("'My account' button not found");
},
thelia_default_timeout
);
casper.waitForSelector(
'a.login',
function() {
test.assertExists('a.login', 'Login button exists');
},
function() {
this.die('Login button doesn\'t exist');
},
thelia_default_timeout
);
casper.run(function() {
test.done();
});
});

View File

@@ -0,0 +1,102 @@
casper.test.comment('== Login ==');
casper.test.begin('Login', 5, function suite(test) {
casper.start(thelia2_base_url + "login", function() {
test.assertTitle("Login - " + thelia2_store_name, "title is the one expected");
test.assertExists('form#form-login', "login form is found");
if (screenshot_enabled) {
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');
if (screenshot_enabled) {
this.capture(screenshot_dir + 'front/30_login-ko-0.png');
}
this.click('form#form-login button[type="submit"]');
});
casper.waitForSelector(
'form#form-login .alert-danger',
function(){
if (screenshot_enabled) {
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;
document.querySelector('#remerber_me').checked = false;
}, 'test@thelia.net', 'azerty');
this.click('form#form-login button[type="submit"]');
},
function(){
this.die("Selector 'form#form-login .alert-danger' not found. It should contain the message 'Wrong email or password. Please try again'");
},
thelia_default_timeout
);
casper.waitForSelector(
'a.logout',
function(){
if (screenshot_enabled) {
this.capture(screenshot_dir + 'front/30_login-ok.png');
}
test.assertExists('a.logout', 'Logout button exists');
casper.test.comment('== Logout');
this.click('a.logout');
},
function(){
this.die("Logout button not found");
},
thelia_default_timeout
);
casper.waitForSelector(
'a.login',
function() {
test.assertExists('a.login', 'Login button exists');
casper.evaluate(function(username, password) {
document.querySelector('#email-mini').value = username;
document.querySelector('#password-mini').value = password;
}, thelia_customer.email, thelia_customer.password);
this.click('form#form-login-mini button[type="submit"]');
},
function() {
this.die('Login button not found');
},
thelia_default_timeout
);
casper.run(function() {
test.done();
});
});

View File

@@ -0,0 +1,76 @@
casper.test.comment('== Cart ==');
casper.test.begin('Cart', 5, function suite(test) {
var productUrl = '';
casper.start(thelia2_base_url, function() {
var productsUrl = this.getElementsAttribute('a.product-info', 'href');
productUrl = productsUrl[Math.floor(Math.random() * productsUrl.length)];
this.echo("product : " + productUrl);
this.thenOpen(productUrl, function() {
this.echo(this.getTitle());
});
});
casper.waitForSelector(
"#pse-submit",
function(){
test.assertExists("#pse-submit", "Add to cart button exists");
if (screenshot_enabled) {
this.capture(screenshot_dir + 'front/40_product.png');
}
this.echo("Submit add to cart");
var isDisabled = this.evaluate(function() {
return document.querySelector("#pse-submit").hasAttribute('disabled');
});
if (isDisabled) {
this.skipTest("This product doesn't have any quantity")
}
this.click("#pse-submit");
},
function(){
this.die("Add to cart button not found");
},
thelia_default_timeout
);
casper.waitForSelector(
'.bootbox h3.text-center',
function() {
//this.echo(this.getHTML());
test.assertSelectorHasText('.bootbox h3.text-center', 'The product has been added to your cart');
if (screenshot_enabled) {
this.captureSelector(screenshot_dir + 'front/40_added-to-cart.png', '.bootbox');
}
},
function(){
this.die("'The product has been added to your cart' pop-in not found");
},
thelia_default_timeout
);
casper.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 h3.name a", 1, "Cart contains 1 product")
var link = this.getElementInfo('#cart .table-cart tbody tr h3.name a');
test.assertTruthy( link.attributes.href == productUrl, "This is the right product in cart");
if (screenshot_enabled) {
this.capture(screenshot_dir + 'front/40_cart.png');
}
});
casper.run(function() {
test.done();
});
});

View File

@@ -0,0 +1,54 @@
casper.test.comment('== Order process ==');
casper.test.begin('Order process', 4, function suite(test) {
casper.start(thelia2_base_url + "order/delivery", function goToDelivery() {
casper.waitForSelector(
'#delivery-module-list-block .radio',
function then() {
casper.test.comment('== Page loaded : ' + this.getCurrentUrl());
test.assertTitle("Billing and delivery - Cart - " + thelia2_store_name, "title is the one expected for url : " + this.getCurrentUrl());
if (screenshot_enabled) {
this.capture(screenshot_dir + 'front/50_delivery_list.png');
}
test.assertEval(function () {
return __utils__.findAll("#form-cart-delivery table.table-address tr").length >= 1;
}, "We expect at least one delivery address");
this.click('form#form-cart-delivery button[type="submit"]');
},
function timeout() {
test.assertElementCount("table.table-cart-mini tbody tr", 1, "cart contain 1 product");
if (this.getCurrentUrl() == thelia2_base_url + "order/invoice") {
test.info("with a virtual product, the delivery page is skipped");
test.skip(1);
} else {
this.die("impossible to load delivery methods");
}
}
);
});
casper.waitForSelector(
'.footer-container',
function(){
test.assertTitle("My order - Cart - " + thelia2_store_name, "title is the one expected for url : " + this.getCurrentUrl());
test.assertElementCount("table.table-cart tbody tr", 1, "cart contain 1 product");
if (screenshot_enabled) {
this.capture(screenshot_dir + 'front/50_delivery_order.png');
}
},
function(){
this.die("The 'title' tag didn't change");
},
thelia_default_timeout
);
casper.run(function() {
test.done();
});
});

View File

@@ -0,0 +1,249 @@
casper.test.comment('== Newsletter ==');
casper.test.begin('Newsletter', 12, function suite(test) {
var newEmail = '';
casper.start(thelia2_base_url + "newsletter", function() {
if (this.exists('.navbar-customer .logout')) {
this.click('.navbar-customer .logout');
}
});
casper.thenOpen(thelia2_base_url + "newsletter", function(){
test.assertTitle("Newsletter - Thelia V2", "title is the one expected");
});
casper.waitForSelector(
'.navbar-customer .register',
function() {
test.assertExists('.navbar-customer .register', 'user is disconnected');
test.assertExists('form#form-newsletter', "newsletter form is found");
casper.test.comment("== User isn't connected");
test.assertExists('form#form-newsletter #firstname_newsletter', 'firstname field is displayed');
test.assertExists('form#form-newsletter #lastname_newsletter', 'lastname field is displayed');
if (screenshot_enabled) {
this.capture(screenshot_dir + 'front/60_newsletter.png');
}
casper.test.comment('== Newsletter blank submission');
this.fill('form#form-newsletter', {
'thelia_newsletter[email]': '',
'thelia_newsletter[firstname]': 'Thelia',
'thelia_newsletter[lastname]': 'Thelia'
}, true);
},
function(){
this.die("Select '.navbar-customer .register' not found");
},
thelia_default_timeout
);
casper.waitForSelector(
'#email_newsletter',
function(){
casper.evaluate(function(email) {
document.querySelector('#email_newsletter').value = email;
}, '');
this.click('form#form-newsletter button[type="submit"]');
},
function(){
this.die("'email' field in newsletter form not found");
},
thelia_default_timeout
);
casper.waitForSelector(
'form#form-newsletter .group-email.has-error',
function(){
if (screenshot_enabled) {
this.capture(screenshot_dir + 'front/60_newsletter-ko-0.png');
}
test.assertExists('form#form-newsletter .group-email.has-error', 'email can not be empty');
},function(){
this.die("Can't find newsletter form error");
},
thelia_default_timeout
);
casper.waitForSelector(
'form#form-newsletter',
function(){
casper.test.comment('== Test submission');
this.fill('form#form-newsletter', {
'thelia_newsletter[email]': 'test@thelia.net',
'thelia_newsletter[firstname]': 'Thelia',
'thelia_newsletter[lastname]': 'Thelia'
}, true);
casper.evaluate(function(email) {
document.querySelector('#email_newsletter').value = email;
}, 'test@thelia.net');
this.click('form#form-newsletter button[type="submit"]');
},
function() {
this.die("Newsletter form not found");
},
thelia_default_timeout
);
casper.waitForSelector(
'form#form-newsletter',
function(){
casper.test.comment('== Existing email on submission');
this.fill('form#form-newsletter', {
'thelia_newsletter[email]': 'test@thelia.net',
'thelia_newsletter[firstname]': 'Thelia',
'thelia_newsletter[lastname]': 'Thelia'
}, true);
casper.evaluate(function(email) {
document.querySelector('#email_newsletter').value = email;
}, 'test@thelia.net');
this.click('form#form-newsletter button[type="submit"]');
},
function(){
this.die("Newsletter form not found");
},
thelia_default_timeout
);
casper.waitForSelector(
'form#form-newsletter .group-email.has-error',
function(){
if (screenshot_enabled) {
this.capture(screenshot_dir + 'front/60_newsletter-ko-0.png');
}
test.assertExists('form#form-newsletter .group-email.has-error', 'email already exist');
},
function(){
this.die("Newsletter form error message not found");
},
thelia_default_timeout
);
casper.waitForSelector(
'form#form-newsletter',
function(){
casper.test.comment('== Great email on submission');
newEmail = Math.random().toString(36).substr(2,7) + '@thelia.net';
this.fill('form#form-newsletter', {
'thelia_newsletter[email]': newEmail,
'thelia_newsletter[firstname]': 'Thelia',
'thelia_newsletter[lastname]': 'Thelia'
}, true);
casper.evaluate(function(email) {
document.querySelector('#email_newsletter').value = email;
}, newEmail);
this.click('form#form-newsletter button[type="submit"]');
},
function(){
this.die("Newsletter form not found");
},
thelia_default_timeout
);
casper.waitForSelector(
'form#form-newsletter .group-email.has-success',
function(){
if (screenshot_enabled) {
this.capture(screenshot_dir + 'front/60_newsletter-ok-0.png');
}
test.assertExists('form#form-newsletter .group-email.has-success', 'subscription with success');
},
function(){
this.die("Newsletter form success message not found");
},
thelia_default_timeout
);
casper.waitForSelector(
'#email-mini',
function(){
casper.test.comment('== Login user');
casper.evaluate(function(username, password) {
document.querySelector('#email-mini').value = username;
document.querySelector('#password-mini').value = password;
}, 'test@thelia.net', 'azerty');
this.click('form#form-login-mini button[type="submit"]');
},
function(){
this.die("Newsletter form 'email-mini' field not found");
},
thelia_default_timeout
);
casper.waitForSelector(
'a.logout',
function(){
if (screenshot_enabled) {
this.capture(screenshot_dir + 'front/60_newsletter-ok-1.png');
}
test.assertExists('a.logout', 'Logout button exists');
test.assertDoesntExist('form#form-newsletter #firstname_newsletter', "firstname field doesn't exist");
test.assertDoesntExist('form#form-newsletter #lastname_newsletter', "lastname field doesn't exist");
},
function(){
this.die("Logout button not found");
},
thelia_default_timeout
);
casper.waitForSelector(
'form#form-newsletter',
function(){
casper.test.comment('== Subscribe again');
this.fill('form#form-newsletter', {
'thelia_newsletter[email]': 'test@thelia.net'
}, true);
casper.evaluate(function(email) {
document.querySelector('#email_newsletter').value = email;
}, 'test@thelia.net');
this.click('form#form-newsletter button[type="submit"]');
},
function(){
this.die("Newsletter form not found");
},
thelia_default_timeout
);
casper.waitForSelector(
'form#form-newsletter .group-email.has-error',
function(){
if (screenshot_enabled) {
this.capture(screenshot_dir + 'front/60_newsletter-ko-1.png');
}
test.assertExists('form#form-newsletter .group-email.has-error', 'this user is already registered');
},
function(){
this.die("Newsletter form error message not found");
},
thelia_default_timeout
);
casper.run(function() {
test.done();
});
});