fuel-web/nailgun/ui_tests/test_cluster_logs.js

58 lines
2.2 KiB
JavaScript

/*
* Copyright 2013 Mirantis, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License. You may obtain
* a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
**/
casper.start().authenticate().skipWelcomeScreen();
casper.createCluster({name: 'Test Cluster'});
casper.createNode({status: 'discover', mac: '84:AA:B8:E6:30:F0', cluster_id: 1});
casper.loadPage('#cluster/1/logs').waitForSelector('.logs-tab > *');
casper.then(function() {
if (this.loadJsFile('sinon-server')) {
this.evaluate(function() {
var server = sinon.fakeServer.create();
server.autoRespond = true;
server.respondWith(/\/api\/logs.*/, [
200, {"Content-Type": "application/json"},
JSON.stringify({
from: 1,
entries: [['Date', 'INFO', 'Test Log Entry']]
})
]);
});
} else {
this.test.error('Unable to load sinon');
this.test.done();
}
});
casper.then(function() {
this.test.comment('Testing logs tab');
this.test.assertSelectorAppears('.sticker select[name=source] option', 'Log source selection box appears and is not empty');
this.test.assertSelectorAppears('.sticker button:disabled', '"Show logs" button is locked');
this.then(function() {
this.fill('.sticker', {'level': 'DEBUG'});
});
this.test.assertSelectorAppears('.sticker button:not([disabled])', '"Show logs" button is enabled after "Levels" change');
this.then(function() {
this.click('.sticker button');
});
this.waitForSelector('.log-entries > *').then(function() {
this.test.assertSelectorHasText('.log-entries tr:first-child td:last-child', 'Test Log Entry', 'Log entry appears after clicking "Show logs" button');
});
});
casper.run(function() {
this.test.done();
});