Use sinon for mocking server response in UI func tests for logs

Closes-Bug: #1519752

Change-Id: I62859dca7fa5c138b012d4c5fd4e184c941fb992
This commit is contained in:
Vitaly Kramskikh 2016-01-02 16:20:07 +03:00
parent b32633dab8
commit 7e3efeb6ee
5 changed files with 25 additions and 4 deletions

View File

@ -286,6 +286,10 @@ gulp.task('build', function(cb) {
new webpack.DefinePlugin({'process.env': {NODE_ENV: '"production"'}})
);
}
if (argv['extra-entries']) {
config.entry = config.entry.concat(argv['extra-entries'].split(','));
}
if (argv.uglify !== false) {
config.devtool = 'source-map';
config.plugins.push(

View File

@ -81,7 +81,7 @@
"nlf": "~1.3.2",
"react-addons-test-utils": "0.14.3",
"selenium-standalone": "~4.4.0",
"sinon": "~1.15.3",
"sinon": "1.17.2",
"webpack-dev-server": "1.14.0"
}
}

View File

@ -57,9 +57,24 @@ define([
// Change the selected value for the "Level" dropdown to DEBUG
.clickByCssSelector('.sticker select[name=level] option[value=DEBUG]')
.assertElementEnabled(showLogsButtonSelector, '"Show" button is enabled after source change')
.execute(function() {
window.fakeServer = sinon.fakeServer.create();
window.fakeServer.autoRespond = true;
window.fakeServer.autoRespondAfter = 1000;
window.fakeServer.respondWith(/\/api\/logs.*/, [
200, {'Content-Type': 'application/json'},
JSON.stringify({
from: 1,
entries: [['Date', 'INFO', 'Test Log Entry']]
})
]);
})
.clickByCssSelector(showLogsButtonSelector)
.assertElementDisappears('.logs-tab div.progress', 5000, 'Wait till Progress bar disappears')
.assertElementsAppear('.log-entries > tbody > tr', 5000, 'Log entries are loaded')
.assertElementsAppear('.log-entries > tbody > tr', 5000, 'Log entries are shown')
.execute(function() {
window.fakeServer.restore();
})
// "Other servers" option is present in "Logs" dropdown
.clickByCssSelector('.sticker select[name=type] > option[value=remote]')
.assertElementExists('.sticker select[name=node] > option', '"Node" dropdown is present');

View File

@ -21,6 +21,7 @@ module.exports = {
},
{test: /\/expression\/parser\.js$/, loader: 'exports?parser'},
{test: require.resolve('jquery'), loader: 'expose?jQuery!expose?$'},
{test: /\/sinon\.js$/, loader: 'imports?this=>window,define=>false,exports=>false,module=>false,require=>false'},
{test: /\.css$/, loader: 'style!css!postcss'},
{test: /\.less$/, loader: 'style!css!postcss!less'},
{test: /\.html$/, loader: 'raw'},
@ -34,7 +35,8 @@ module.exports = {
modulesDirectories: ['static', 'node_modules', 'vendor/custom'],
extensions: ['', '.js'],
alias: {
underscore: 'lodash'
underscore: 'lodash',
sinon: 'sinon/pkg/sinon.js'
}
},
node: {},

View File

@ -271,7 +271,7 @@ function run_ui_func_tests {
if [ $no_ui_compression -ne 1 ]; then
echo "Compressing UI... "
${GULP} build --no-sourcemaps --static-dir=$COMPRESSED_STATIC_DIR
${GULP} build --no-sourcemaps --extra-entries=sinon --static-dir=$COMPRESSED_STATIC_DIR
if [ $? -ne 0 ]; then
popd >> /dev/null
return 1