2014-04-21 20:36:50 +00:00
|
|
|
// in order to see the app running inside the QUnit runner
|
|
|
|
App.rootElement = '#ember-testing';
|
|
|
|
|
|
|
|
// Common test setup
|
|
|
|
App.setupForTesting();
|
|
|
|
App.injectTestHelpers();
|
|
|
|
|
2014-06-09 21:29:35 +00:00
|
|
|
// Test "fixtures". We populate these based on the running consul
|
|
|
|
// on the machine where you run the tests.
|
|
|
|
var fixtures = {
|
|
|
|
dc: "dc1",
|
|
|
|
node: null,
|
|
|
|
service: null,
|
|
|
|
key: "fake",
|
|
|
|
value: "foobar"
|
|
|
|
}
|
|
|
|
|
2014-04-21 20:36:50 +00:00
|
|
|
module("Integration tests", {
|
|
|
|
setup: function() {
|
|
|
|
// before each test, ensure the application is ready to run.
|
|
|
|
Ember.run(App, App.advanceReadiness);
|
2014-06-09 21:29:35 +00:00
|
|
|
|
|
|
|
// Discover the service, node and dc info
|
|
|
|
Ember.$.getJSON('/v1/catalog/datacenters').then(function(data) {
|
|
|
|
fixtures.dc = data[0]
|
|
|
|
}).then(function(){
|
|
|
|
Ember.$.getJSON('/v1/internal/ui/nodes?dc=' + fixtures.dc).then(function(data) {
|
|
|
|
fixtures.node = data[0].Node
|
|
|
|
});
|
|
|
|
}).then(function(){
|
|
|
|
Ember.$.getJSON('/v1/internal/ui/services?dc=' + fixtures.dc).then(function(data) {
|
|
|
|
fixtures.service = data[0].Name
|
|
|
|
});
|
|
|
|
});
|
|
|
|
// Create a fake key
|
|
|
|
Ember.$.ajax({
|
|
|
|
url: ("/v1/kv/" + fixtures.key + '?dc=' + fixtures.dc),
|
|
|
|
type: 'PUT',
|
|
|
|
data: fixtures.value
|
|
|
|
})
|
2014-04-21 20:36:50 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
teardown: function() {
|
|
|
|
// reset the application state between each test
|
|
|
|
App.reset();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-06-09 21:29:35 +00:00
|
|
|
test("services", function() {
|
|
|
|
visit("/")
|
|
|
|
|
|
|
|
andThen(function() {
|
|
|
|
ok(find("a:contains('Services')").hasClass('active'), "highlights services in nav");
|
|
|
|
equal(find(".ember-list-item-view").length, 1, "renders one service");
|
|
|
|
ok(find(".ember-list-item-view .name:contains('"+ fixtures.service +"')"), "uses service name");
|
|
|
|
ok(find(".ember-list-item-view .name:contains('passing')"), "shows passing check num");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
test("servicesShow", function() {
|
|
|
|
visit("/");
|
|
|
|
// First item in list
|
|
|
|
click('.ember-list-item-view .list-group-item');
|
|
|
|
|
|
|
|
andThen(function() {
|
|
|
|
ok(find("a:contains('Services')").hasClass('active'), "highlights services in nav");
|
|
|
|
equal(find(".ember-list-item-view").length, 1, "renders one service");
|
|
|
|
ok(find(".ember-list-item-view .list-group-item").hasClass('active'), "highlights active service");
|
|
|
|
ok(find(".ember-list-item-view .name:contains('"+ fixtures.service +"')"), "uses service name");
|
|
|
|
ok(find(".ember-list-item-view .name:contains('passing')"), "shows passing check num");
|
|
|
|
equal(find("h5").text(), "Nodes", "Shows node list");
|
|
|
|
ok(find("h3.panel-title:contains('"+ fixtures.node +"')"), "Shows node name");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
test("nodes", function() {
|
|
|
|
visit("/");
|
|
|
|
click("a:contains('Nodes')");
|
|
|
|
|
|
|
|
andThen(function() {
|
|
|
|
ok(find("a:contains('Nodes')").hasClass('active'), "highlights nodes in nav");
|
|
|
|
equal(find(".ember-list-item-view").length, 1, "renders one node");
|
|
|
|
ok(find(".ember-list-item-view .name:contains('"+ fixtures.node +"')"), "contains node name");
|
|
|
|
ok(find(".ember-list-item-view .name:contains('services')"), "contains services num");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
test("kv", function() {
|
2014-04-21 20:36:50 +00:00
|
|
|
visit("/");
|
2014-06-09 21:29:35 +00:00
|
|
|
click("a:contains('Key/Value')");
|
2014-04-21 20:36:50 +00:00
|
|
|
|
|
|
|
andThen(function() {
|
2014-06-09 21:29:35 +00:00
|
|
|
ok(find("a:contains('Key/Value')").hasClass('active'), "highlights kv in nav");
|
|
|
|
equal(find(".list-group-item").length, 1, "renders one key");
|
|
|
|
ok(find(".list-group-item:contains('"+ fixtures.key +"')"), "contains key name");
|
2014-04-21 20:36:50 +00:00
|
|
|
});
|
|
|
|
});
|