Add History Api test

Add CasperJS Tests for History API (~80%). Also provides a few
resources like the generic.html site that can be used for more
setups

refs #4303
refs #4315
This commit is contained in:
Jannis Moßhammer 2013-06-17 17:18:35 +02:00
parent c126374807
commit e8d7971531
8 changed files with 119 additions and 1 deletions

View File

@ -0,0 +1,57 @@
var i2w = require('./i2w-config');
var casper = i2w.getTestEnv();
casper.start("http://localhost:12999/generic.html");
casper.then(function() {
casper.page.evaluate(i2w.setupRequireJs, {icinga: true});
});
casper.then(function() {
this.test.assertTitle("Icinga test page");
casper.page.evaluate(function() {
requirejs(["icinga/icinga"], function(icinga) {
icinga.loadUrl("/fragments/testFragment1.html");
});
});
/*this.waitFor(function() {
return document.querySelectorAll("#icinga-main a") ;
}, */
casper.waitForSelector("div#icinga-main a", onFirstLink);
});
var onFirstLink = function() {
var links = casper.page.evaluate(function() {
return document.querySelectorAll("div#icinga-main a");
});
// assert no reload
this.test.assertTitle("Icinga test page");
this.test.assertUrlMatch(/.*testFragment1.html/);
this.test.assertEquals(links.length, 2);
casper.clickLabel('Fragment 2');
casper.waitForText('Fragment 1', onSecondLink);
};
var onSecondLink = function() {
var links = casper.page.evaluate(function() {
return document.querySelectorAll("div#icinga-main a");
});
this.test.assertTitle("Icinga test page");
this.test.assertUrlMatch(/.*testFragment2.html/);
this.test.assertEquals(links.length, 2);
casper.page.evaluate(function() {
requirejs(["icinga/icinga"], function(icinga) {
icinga.loadUrl("/fragments/testFragment3.html?this=is_a_param", "icinga-detail");
console.log(document.location.href);
});
});
console.log(casper.page.evaluate(function() {
return document.location.href;
}));
};
casper.run(function() {
this.test.done();
});

View File

@ -11,7 +11,6 @@ casper.start("http://localhost:12999/empty.html");
casper.then(function() { casper.then(function() {
casper.log(this.test);
this.test.assertTitle("Just an empty page"); this.test.assertTitle("Just an empty page");
}); });

View File

@ -0,0 +1,6 @@
<div>
<h1>Test fragment</h1>
<a href="/fragments/testFragment2.html">Fragment 2</a>
<a href="/fragments/testFragment3.html">Fragment 3</a>
</div>

View File

@ -0,0 +1,6 @@
<div>
<h1>Test fragment 2</h1>
<a href="/fragments/testFragment1.html">Fragment 1</a>
<a href="/fragments/testFragment3.html">Fragment 3</a>
</div>

View File

@ -0,0 +1,6 @@
<div>
<h1>Test fragment 3</h1>
<a href="/fragments/testfragment1.html">Fragment 1</a>
<a href="/fragments/testfragment2.html">Fragment 2</a>
</div>

View File

@ -0,0 +1,39 @@
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta content="width=320; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Icinga test page</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<script>
window.base_url = "/public";
</script>
<link rel="stylesheet" href="/public/css/normalize.min.css">
<link rel="stylesheet" href="/public/css/vendor/bootstrap.css">
<link rel="stylesheet" href="/public/css/main.css">
<link rel="stylesheet" href="/public/css/vendor/jquery.qtip.min.css">
<script src="/public/js/vendor/modernizr-2.6.2.min.js"></script>
<link rel="stylesheet" href="/public/css/icinga.css">
<link rel="stylesheet" href="/public/css/vendor/bootstrap-responsive.min.css">
<script src="/public/js/vendor/require.js"></script>
</head>
<body class="cranberry">
<div class="main">
<div class="tabbable tabs-left" style="height:100%;">
</div>
<div class="layout-main-detail collapsed">
<div id="icinga-main" container-id="icinga-main" class="icinga-container">
</div>
<div id="icinga-detail" class="icinga-container " container-id="icinga-detail">
</div><!-- End of icinga-detail -->
</div><!-- End of layout-main-detail -->
</div><!-- End of main -->
</body>
</html>

View File

@ -0,0 +1,4 @@
define([], function() {
"use strict";
return {};
});

1
test/frontend/test.xml Normal file
View File

@ -0,0 +1 @@
<testsuite time="0"><testcase classname="cases/static-page-test" name="The jenkins page" time="0.626"><failure type="assertTitle">Page title is: "i4cinga-web test [Jenkins]"</failure></testcase></testsuite>